Remove day cycle shit (#400)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System.Numerics;
|
||||
using Content.Client.Parallax;
|
||||
using Content.Client.Weather;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.DayCycle.Components;
|
||||
using Content.Shared._CP14.WorldEdge;
|
||||
using Content.Shared.Salvage;
|
||||
using Content.Shared.Weather;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.DayCycle.Components;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -53,7 +53,7 @@ public sealed partial class StencilOverlay
|
||||
worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilMask").Instance());
|
||||
worldHandle.DrawTextureRect(_blep!.Texture, worldBounds);
|
||||
var curTime = _timing.RealTime;
|
||||
var sprite = _sprite.GetFrame(new SpriteSpecifier.Texture(new ResPath(cloudComp.ParallaxPath)), curTime);
|
||||
var sprite = _sprite.GetFrame(new SpriteSpecifier.Texture(cloudComp.ParallaxPath), curTime);
|
||||
|
||||
// Draw the rain
|
||||
worldHandle.UseShader(_protoManager.Index<ShaderPrototype>("StencilDraw").Instance());
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.DayCycle.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server._CP14.DayCycle;
|
||||
|
||||
public sealed partial class CP14CloudShadowsSystem : EntitySystem
|
||||
public sealed class CP14CloudShadowsSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
@@ -15,10 +14,8 @@ public sealed partial class CP14CloudShadowsSystem : EntitySystem
|
||||
SubscribeLocalEvent<CP14CloudShadowsComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<CP14CloudShadowsComponent> ent, ref MapInitEvent args)
|
||||
private void OnMapInit(Entity<CP14CloudShadowsComponent> entity, ref MapInitEvent args)
|
||||
{
|
||||
ent.Comp.CloudSpeed = new Vector2(
|
||||
_random.NextFloat(-ent.Comp.MaxSpeed, ent.Comp.MaxSpeed),
|
||||
_random.NextFloat(-ent.Comp.MaxSpeed, ent.Comp.MaxSpeed));
|
||||
entity.Comp.CloudSpeed = _random.NextVector2(-entity.Comp.MaxSpeed, entity.Comp.MaxSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
using System.Diagnostics;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.DayCycle.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
namespace Content.Server._CP14.DayCycle;
|
||||
|
||||
public sealed partial class CP14DayCycleSystem : EntitySystem
|
||||
public sealed partial class CP14DayCycleSystem : CP14SharedDayCycleSystem
|
||||
{
|
||||
public const int MinTimeEntryCount = 2;
|
||||
private const float MaxTimeDiff = 0.05f;
|
||||
|
||||
private static readonly ProtoId<CP14DayCyclePeriodPrototype> DayPeriod = "Day";
|
||||
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedMapSystem _maps = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -21,17 +24,8 @@ public sealed partial class CP14DayCycleSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14DayCycleComponent, MapInitEvent>(OnMapInitDayCycle);
|
||||
SubscribeLocalEvent<CP14DayCycleComponent, DayCycleDayStartedEvent>(OnDayStarted);
|
||||
SubscribeLocalEvent<CP14DayCycleComponent, DayCycleNightStartedEvent>(OnNightStarted);
|
||||
}
|
||||
|
||||
private void OnDayStarted(Entity<CP14DayCycleComponent> dayCycle, ref DayCycleDayStartedEvent args)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnNightStarted(Entity<CP14DayCycleComponent> dayCycle, ref DayCycleNightStartedEvent args)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnMapInitDayCycle(Entity<CP14DayCycleComponent> dayCycle, ref MapInitEvent args)
|
||||
{
|
||||
@@ -88,22 +82,8 @@ public sealed partial class CP14DayCycleSystem : EntitySystem
|
||||
dayCycle.Comp.EntryStartTime = dayCycle.Comp.EntryEndTime;
|
||||
dayCycle.Comp.EntryEndTime += dayCycle.Comp.CurrentTimeEntry.Duration;
|
||||
|
||||
// TODO: Made with states,we might need an evening or something, and besides, it's too much hardcore
|
||||
if (dayCycle.Comp.IsNight && !dayCycle.Comp.CurrentTimeEntry.IsNight) // Day started
|
||||
{
|
||||
dayCycle.Comp.IsNight = false;
|
||||
|
||||
var ev = new DayCycleDayStartedEvent(dayCycle);
|
||||
RaiseLocalEvent(dayCycle, ref ev, true);
|
||||
}
|
||||
|
||||
if (!dayCycle.Comp.IsNight && dayCycle.Comp.CurrentTimeEntry.IsNight) // Night started
|
||||
{
|
||||
dayCycle.Comp.IsNight = true;
|
||||
|
||||
var ev = new DayCycleNightStartedEvent(dayCycle);
|
||||
RaiseLocalEvent(dayCycle, ref ev, true);
|
||||
}
|
||||
var ev = new DayCycleChangedEvent(dayCycle.Comp.CurrentTimeEntry);
|
||||
RaiseLocalEvent(dayCycle, ref ev, true);
|
||||
|
||||
Dirty(dayCycle);
|
||||
}
|
||||
@@ -113,28 +93,22 @@ public sealed partial class CP14DayCycleSystem : EntitySystem
|
||||
/// </summary>
|
||||
/// <param name="target">An entity being tested to see if it is in daylight</param>
|
||||
/// <param name="checkRoof">Checks if the tile covers the weather (the only "roof" factor at the moment)</param>
|
||||
/// <param name="isDaylight">daylight test result returned</param>
|
||||
public bool TryDaylightThere(EntityUid target, bool checkRoof)
|
||||
{
|
||||
if (!TryComp<TransformComponent>(target, out var xform))
|
||||
return false;
|
||||
|
||||
var xform = Transform(target);
|
||||
if (!TryComp<CP14DayCycleComponent>(xform.MapUid, out var dayCycle))
|
||||
return false;
|
||||
|
||||
if (checkRoof)
|
||||
{
|
||||
if (!TryComp<MapGridComponent>(xform.GridUid, out var mapGrid))
|
||||
return !dayCycle.IsNight;
|
||||
if (!checkRoof || !TryComp<MapGridComponent>(xform.GridUid, out var mapGrid))
|
||||
return dayCycle.CurrentPeriod == DayPeriod;
|
||||
|
||||
var tileRef = _maps.GetTileRef(xform.GridUid.Value, mapGrid, xform.Coordinates);
|
||||
var tileDef = (ContentTileDefinition) _tileDefManager[tileRef.Tile.TypeId];
|
||||
var tileRef = _maps.GetTileRef(xform.GridUid.Value, mapGrid, xform.Coordinates);
|
||||
var tileDef = (ContentTileDefinition) _tileDefManager[tileRef.Tile.TypeId];
|
||||
|
||||
if (!tileDef.Weather)
|
||||
return false;
|
||||
}
|
||||
if (!tileDef.Weather)
|
||||
return false;
|
||||
|
||||
return !dayCycle.IsNight;
|
||||
return dayCycle.CurrentPeriod == DayPeriod;
|
||||
}
|
||||
|
||||
private void SetAmbientColor(Entity<MapLightComponent> light, Color color)
|
||||
@@ -1,9 +1,11 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared._CP14.DayCycle.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._CP14.DayCycle;
|
||||
namespace Content.Server._CP14.DayCycle.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.VarEdit)]
|
||||
public sealed class CP14AddTimeEntryCommand : LocalizedCommands
|
||||
@@ -13,7 +15,7 @@ public sealed class CP14AddTimeEntryCommand : LocalizedCommands
|
||||
|
||||
public override string Command => Name;
|
||||
public override string Description => "Allows you to add a new time entry to the map list";
|
||||
public override string Help => $"{Name} <mapUid> <color> <duration> <isNight>";
|
||||
public override string Help => $"{Name} <mapUid> <color> <duration> <periodId>";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
@@ -29,7 +31,9 @@ public sealed class CP14AddTimeEntryCommand : LocalizedCommands
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<EntityManager>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
var dayCycleSystem = entityManager.System<CP14DayCycleSystem>();
|
||||
var entity = entityManager.GetEntity(netEntity);
|
||||
|
||||
@@ -51,9 +55,9 @@ public sealed class CP14AddTimeEntryCommand : LocalizedCommands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bool.TryParse(args[3], out var isNight))
|
||||
if (!prototypeManager.TryIndex<CP14DayCyclePeriodPrototype>(args[3], out var prototype))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("parse-bool-fail", ("args", args[3])));
|
||||
shell.WriteError(Loc.GetString("parse-prototype-fail", ("args", args[3])));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,7 +65,7 @@ public sealed class CP14AddTimeEntryCommand : LocalizedCommands
|
||||
{
|
||||
Color = color,
|
||||
Duration = TimeSpan.FromSeconds(duration),
|
||||
IsNight = isNight
|
||||
Period = prototype.ID,
|
||||
};
|
||||
|
||||
dayCycleSystem.AddTimeEntry((entity, dayCycle), entry);
|
||||
@@ -72,7 +76,7 @@ public sealed class CP14AddTimeEntryCommand : LocalizedCommands
|
||||
return args.Length switch
|
||||
{
|
||||
1 => CompletionResult.FromOptions(CompletionHelper.Components<CP14DayCycleComponent>(args[0])),
|
||||
4 => CompletionResult.FromOptions(CompletionHelper.Booleans),
|
||||
4 => CompletionResult.FromOptions(CompletionHelper.PrototypeIDs<CP14DayCyclePeriodPrototype>()),
|
||||
_ => CompletionResult.Empty,
|
||||
};
|
||||
}
|
||||
@@ -2,8 +2,9 @@ using Content.Server.Administration;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using CP14DayCycleComponent = Content.Shared._CP14.DayCycle.Components.CP14DayCycleComponent;
|
||||
|
||||
namespace Content.Server._CP14.DayCycle;
|
||||
namespace Content.Server._CP14.DayCycle.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.VarEdit)]
|
||||
public sealed class CP14InitDayCycleCommand : LocalizedCommands
|
||||
@@ -2,8 +2,9 @@ using Content.Server.Administration;
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using CP14DayCycleComponent = Content.Shared._CP14.DayCycle.Components.CP14DayCycleComponent;
|
||||
|
||||
namespace Content.Server._CP14.DayCycle;
|
||||
namespace Content.Server._CP14.DayCycle.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.VarEdit)]
|
||||
public sealed class CP14SetTimeEntryCommand : LocalizedCommands
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server._CP14.DayCycle;
|
||||
using Content.Server._CP14.Farming.Components;
|
||||
using Content.Server.Destructible;
|
||||
using Content.Server.DoAfter;
|
||||
|
||||
10
Content.Shared/_CP14/DayCycle/CP14DayCyclePeriodPrototype.cs
Normal file
10
Content.Shared/_CP14/DayCycle/CP14DayCyclePeriodPrototype.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
|
||||
[Prototype("CP14DayCyclePeriod")]
|
||||
public sealed class CP14DayCyclePeriodPrototype : IPrototype
|
||||
{
|
||||
[IdDataField]
|
||||
public string ID { get; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
|
||||
public abstract class CP14SharedDayCycleSystem : EntitySystem;
|
||||
@@ -1,16 +1,17 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
namespace Content.Shared._CP14.DayCycle.Components;
|
||||
|
||||
/// <summary>
|
||||
/// if added to the map, renders cloud shadows on the map
|
||||
/// If added to the map, renders cloud shadows on the map
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class CP14CloudShadowsComponent : Component
|
||||
{
|
||||
[DataField, AutoNetworkedField]
|
||||
public Vector2 CloudSpeed = new Vector2(0.5f, 0f);
|
||||
public Vector2 CloudSpeed = new(0.5f, 0f);
|
||||
|
||||
[DataField]
|
||||
public float MaxSpeed = 1.5f;
|
||||
@@ -22,5 +23,5 @@ public sealed partial class CP14CloudShadowsComponent : Component
|
||||
public float Scale = 2.5f;
|
||||
|
||||
[DataField]
|
||||
public string ParallaxPath = "/Textures/_CP14/Parallaxes/Shadows.png";
|
||||
public ResPath ParallaxPath = new("/Textures/_CP14/Parallaxes/Shadows.png");
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._CP14.DayCycle;
|
||||
namespace Content.Shared._CP14.DayCycle.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Stores all the necessary data for the day and night cycle system to work
|
||||
/// Stores all the necessary data for the day and night cycle system to work.
|
||||
/// </summary>
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(CP14DayCycleSystem))]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(CP14SharedDayCycleSystem))]
|
||||
public sealed partial class CP14DayCycleComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
@@ -25,12 +25,12 @@ public sealed partial class CP14DayCycleComponent : Component
|
||||
[ViewVariables]
|
||||
public Color EndColor => NextCurrentTimeEntry.Color;
|
||||
|
||||
[ViewVariables]
|
||||
public ProtoId<CP14DayCyclePeriodPrototype> CurrentPeriod => CurrentTimeEntry.Period;
|
||||
|
||||
[DataField(required: true), ViewVariables, AutoNetworkedField]
|
||||
public List<DayCycleEntry> TimeEntries = new();
|
||||
|
||||
[DataField, ViewVariables, AutoNetworkedField]
|
||||
public bool IsNight; // TODO: Rewrite this shit
|
||||
|
||||
[DataField, ViewVariables, AutoNetworkedField]
|
||||
public int CurrentTimeEntryIndex;
|
||||
|
||||
@@ -57,17 +57,11 @@ public readonly partial record struct DayCycleEntry()
|
||||
public TimeSpan Duration { get; init; } = TimeSpan.FromSeconds(60);
|
||||
|
||||
[DataField]
|
||||
public bool IsNight { get; init; } = false;
|
||||
public ProtoId<CP14DayCyclePeriodPrototype> Period { get; init; } = "Day";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised on map entity, wen night is started
|
||||
/// Event raised on map entity, wen day cycle changed.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct DayCycleNightStartedEvent(EntityUid Map);
|
||||
|
||||
/// <summary>
|
||||
/// Event raised on map entity, wen night is started
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct DayCycleDayStartedEvent(EntityUid Map);
|
||||
public readonly record struct DayCycleChangedEvent(DayCycleEntry Entry);
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Shared._CP14.DayCycle;
|
||||
using Content.Shared.Random.Rules;
|
||||
|
||||
namespace Content.Shared._CP14.Random.Rules;
|
||||
@@ -11,7 +10,9 @@ public sealed partial class IsDaylight : RulesRule
|
||||
public override bool Check(EntityManager entManager, EntityUid uid)
|
||||
{
|
||||
var transform = entManager.System<SharedTransformSystem>();
|
||||
var dayCycle = entManager.System<CP14DayCycleSystem>();
|
||||
|
||||
// Not shared yet, use raw component data from map
|
||||
// var dayCycle = entManager.System<CP14DayCycleSystem>();
|
||||
|
||||
//черт, нужны комиты из ветки фермерства
|
||||
return !Inverted;
|
||||
|
||||
@@ -47,18 +47,18 @@ entities:
|
||||
color: '#E0BA87FF'
|
||||
- duration: 80
|
||||
color: '#BFEEFFFF'
|
||||
- isNight: True
|
||||
duration: 80
|
||||
- duration: 80
|
||||
color: '#385163FF'
|
||||
- isNight: True
|
||||
duration: 80
|
||||
period: Night
|
||||
- duration: 80
|
||||
color: '#060D12FF'
|
||||
- isNight: True
|
||||
duration: 80
|
||||
period: Night
|
||||
- duration: 80
|
||||
color: '#000000FF'
|
||||
- isNight: True
|
||||
duration: 80
|
||||
period: Night
|
||||
- duration: 80
|
||||
color: '#000000FF'
|
||||
period: Night
|
||||
- duration: 80
|
||||
color: '#120906FF'
|
||||
- uid: 2
|
||||
|
||||
@@ -42,16 +42,16 @@ entities:
|
||||
color: '#E0BA87FF'
|
||||
- duration: 80
|
||||
color: '#BFEEFFFF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#385163FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#060D12FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#000000FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#000000FF'
|
||||
- duration: 80
|
||||
|
||||
@@ -38,16 +38,16 @@ entities:
|
||||
color: '#E0BA87FF'
|
||||
- duration: 80
|
||||
color: '#BFEEFFFF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#385163FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#060D12FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#000000FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#000000FF'
|
||||
- duration: 80
|
||||
|
||||
@@ -35,16 +35,16 @@ entities:
|
||||
color: '#E0BA87FF'
|
||||
- duration: 80
|
||||
color: '#BFEEFFFF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#385163FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#060D12FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#000000FF'
|
||||
- isNight: True
|
||||
- period: Night
|
||||
duration: 80
|
||||
color: '#000000FF'
|
||||
- duration: 80
|
||||
|
||||
11
Resources/Prototypes/_CP14/DayCycle/periods.yml
Normal file
11
Resources/Prototypes/_CP14/DayCycle/periods.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
- type: CP14DayCyclePeriod
|
||||
id: Sunrise # HOLY SHIT!
|
||||
|
||||
- type: CP14DayCyclePeriod
|
||||
id: Day
|
||||
|
||||
- type: CP14DayCyclePeriod
|
||||
id: Night
|
||||
|
||||
- type: CP14DayCyclePeriod
|
||||
id: Evening
|
||||
Reference in New Issue
Block a user