Adjust day/night cycle logic and lighting parameters (#1705)
Increased minimum light level and updated sun shadow directions for smoother transitions. Changed light curve calculation to use cosine, adjusted day detection threshold, and added a console command to check current light level. Renamed and fixed logic in CP14IsNight rule. Updated map and prototype files to use new ambient light colors and ensure consistency.
This commit is contained in:
@@ -34,7 +34,7 @@ public sealed partial class LightCycleComponent : Component
|
||||
/// Trench of the oscillation.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public float MinLightLevel = 0f;
|
||||
public float MinLightLevel = 0.3f; //CP14 increase from 0 to 0.3
|
||||
|
||||
/// <summary>
|
||||
/// Peak of the oscillation
|
||||
|
||||
@@ -26,12 +26,12 @@ public sealed partial class SunShadowCycleComponent : Component
|
||||
/// Time to have each direction applied. Will lerp from the current value to the next one.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public List<SunShadowCycleDirection> Directions = new()
|
||||
public List<SunShadowCycleDirection> Directions = new() //CP14 replaced vectors
|
||||
{
|
||||
new SunShadowCycleDirection(0f, new Vector2(0f, 3f), 0f),
|
||||
new SunShadowCycleDirection(0.25f, new Vector2(-3f, -0.1f), 0.5f),
|
||||
new SunShadowCycleDirection(0.5f, new Vector2(0f, -3f), 0.8f),
|
||||
new SunShadowCycleDirection(0.75f, new Vector2(3f, -0.1f), 0.5f),
|
||||
new SunShadowCycleDirection(0f, new Vector2(0.1f, 3f), 0f),
|
||||
new SunShadowCycleDirection(0.25f,new Vector2(3f, 0f), 0.5f),
|
||||
new SunShadowCycleDirection(0.5f, new Vector2(-0.1f,-3f), 0.8f),
|
||||
new SunShadowCycleDirection(0.75f,new Vector2(-3f, 0f), 0.5f),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -124,7 +124,9 @@ public abstract class SharedLightCycleSystem : EntitySystem
|
||||
float exponent,
|
||||
float phase = 0)
|
||||
{
|
||||
var sen = MathF.Pow(MathF.Sin((MathF.PI * (phase + x)) / waveLength), exponent);
|
||||
//var sen = MathF.Pow(MathF.Sin((MathF.PI * (phase + x)) / waveLength), exponent);
|
||||
var sen = MathF.Pow(MathF.Cos((MathF.PI * (phase + x)) / waveLength), exponent); //CP14 edited light curve calculation
|
||||
|
||||
return (crest - shift) * sen + shift;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ using Content.Shared.GameTicking;
|
||||
using Content.Shared.Light.Components;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Weather;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -83,14 +86,13 @@ public sealed class CP14DayCycleSystem : EntitySystem
|
||||
.TotalSeconds;
|
||||
|
||||
var normalizedTime = time % map.Comp.Duration.TotalSeconds;
|
||||
var lightLevel = Math.Sin((normalizedTime / map.Comp.Duration.TotalSeconds) * MathF.PI);
|
||||
var lightLevel = 1 - Math.Sin((normalizedTime / map.Comp.Duration.TotalSeconds) * MathF.PI);
|
||||
return (float)lightLevel;
|
||||
}
|
||||
|
||||
public bool IsDayNow(Entity<LightCycleComponent?> map)
|
||||
{
|
||||
var lightLevel = GetLightLevel(map);
|
||||
return lightLevel >= 0.5;
|
||||
return GetLightLevel(map) >= 0.4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,3 +136,36 @@ public sealed class CP14StartDayEvent(EntityUid map) : EntityEventArgs
|
||||
{
|
||||
public EntityUid Map = map;
|
||||
}
|
||||
|
||||
internal sealed class CheckLightLevel : LocalizedCommands
|
||||
{
|
||||
[Dependency] private readonly IEntitySystemManager _entityManager = default!;
|
||||
|
||||
public override string Command => "cp14_check_light";
|
||||
|
||||
public override string Help => "Checks the light level of the map you are on.";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var entity = shell.Player?.AttachedEntity;
|
||||
|
||||
if (entity is null)
|
||||
{
|
||||
shell.WriteLine("You don't have an attached entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var transformSys = _entityManager.GetEntitySystem<TransformSystem>();
|
||||
|
||||
var map = transformSys.GetMap(entity.Value);
|
||||
|
||||
if (map is null)
|
||||
{
|
||||
shell.WriteLine("You are not on a map.");
|
||||
return;
|
||||
}
|
||||
|
||||
var dayCycle = _entityManager.GetEntitySystem<CP14DayCycleSystem>();
|
||||
shell.WriteLine("Current light level: " + dayCycle.GetLightLevel(map.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ public sealed partial class CP14IsNight : RulesRule
|
||||
|
||||
var isDay = dayCycle.IsDayNow(map.Value);
|
||||
|
||||
return Inverted ? !isDay : isDay;
|
||||
return Inverted ? isDay : !isDay;
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ entities:
|
||||
- type: GridPathfinding
|
||||
- type: CP14CloudShadows
|
||||
- type: MapLight
|
||||
ambientLightColor: '#D8B059FF'
|
||||
ambientLightColor: "#7bc2e0"
|
||||
- type: Gravity
|
||||
gravityShakeSound: !type:SoundPathSpecifier
|
||||
path: /Audio/Effects/alert.ogg
|
||||
|
||||
@@ -88,6 +88,8 @@
|
||||
components:
|
||||
- type: LightCycle
|
||||
originalColor: "#7bc2e0"
|
||||
- type: MapLight
|
||||
ambientLightColor: "#7bc2e0"
|
||||
|
||||
- type: cp14LocationModifier
|
||||
id: MapLightCycleHot
|
||||
@@ -102,6 +104,8 @@
|
||||
components:
|
||||
- type: LightCycle
|
||||
originalColor: "#ff8929"
|
||||
- type: MapLight
|
||||
ambientLightColor: "#ff8929"
|
||||
|
||||
- type: cp14LocationModifier
|
||||
id: MapLightCycleHot2
|
||||
@@ -116,4 +120,6 @@
|
||||
components:
|
||||
- type: LightCycle
|
||||
originalColor: "#d68787"
|
||||
- type: MapLight
|
||||
ambientLightColor: "#d68787"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user