Storm nerf (#1107)

* weather lightning nerf

* port storm weather to gamerule events

* fix
This commit is contained in:
Ed
2025-03-31 23:46:21 +03:00
committed by GitHub
parent 05de87e9e9
commit edc67dd280
14 changed files with 225 additions and 97 deletions

View File

@@ -0,0 +1,58 @@
using Content.Server._CP14.GameTicking.Rules.Components;
using Content.Server._CP14.WeatherControl;
using Content.Server.GameTicking.Rules;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationEvents.Events;
using Content.Server.Weather;
using Content.Shared.GameTicking.Components;
using Content.Shared.Station.Components;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server._CP14.GameTicking.Rules;
public sealed class CP14WeatherRule : StationEventSystem<CP14WeatherRuleComponent>
{
[Dependency] private readonly WeatherSystem _weather = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IGameTiming _timing = default!;
protected override void Started(EntityUid uid, CP14WeatherRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
var query = EntityQueryEnumerator<MapComponent, BecomesStationComponent>();
while (query.MoveNext(out var mapUid, out var map, out var station))
{
if (!_proto.TryIndex(component.Weather, out var indexedWeather))
continue;
if (TryComp<CP14WeatherControllerComponent>(mapUid, out var controller))
{
controller.Enabled = false;
}
_weather.SetWeather(map.MapId, indexedWeather, null);
}
}
protected override void Ended(EntityUid uid, CP14WeatherRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
{
base.Ended(uid, component, gameRule, args);
var query = EntityQueryEnumerator<MapComponent, BecomesStationComponent>();
while (query.MoveNext(out var mapUid, out var map, out var station))
{
if (TryComp<CP14WeatherControllerComponent>(mapUid, out var controller))
{
controller.NextWeatherTime = _timing.CurTime + TimeSpan.FromSeconds(controller.ClearDuration.Max);
controller.Enabled = true;
}
_weather.SetWeather(map.MapId, null, null);
}
}
}

View File

@@ -0,0 +1,11 @@
using Content.Shared.Weather;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.GameTicking.Rules.Components;
[RegisterComponent]
public sealed partial class CP14WeatherRuleComponent : Component
{
[DataField(required: true)]
public ProtoId<WeatherPrototype> Weather = default!;
}

View File

@@ -1,3 +1,4 @@
using Content.Server._CP14.GameTicking.Rules;
using Content.Shared._CP14.WeatherControl;
using Content.Shared.Destructible.Thresholds;
@@ -6,9 +7,12 @@ namespace Content.Server._CP14.WeatherControl;
/// <summary>
/// is the controller that hangs on the prototype map. It regulates which weather rules are run and where they are run.
/// </summary>
[RegisterComponent, AutoGenerateComponentPause, Access(typeof(CP14WeatherControllerSystem))]
[RegisterComponent, AutoGenerateComponentPause, Access(typeof(CP14WeatherControllerSystem), typeof(CP14WeatherRule))]
public sealed partial class CP14WeatherControllerComponent : Component
{
[DataField]
public bool Enabled = true;
/// <summary>
/// random time with no weather.
/// </summary>

View File

@@ -29,6 +29,9 @@ public sealed class CP14WeatherControllerSystem : EntitySystem
if (_timing.CurTime <= weather.NextWeatherTime)
continue;
if (!weather.Enabled)
continue;
var weatherData = _random.Pick(weather.Entries);
if (!_proto.TryIndex(weatherData.Visuals, out var weatherVisualsIndexed))

View File

@@ -1,3 +1,4 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Content.Shared._CP14.WeatherEffect;
@@ -20,12 +21,12 @@ public sealed class CP14WeatherEffectJob : Job<bool>
private readonly Entity<MapGridComponent> _mapUid;
private readonly MapId _mapId;
private readonly List<CP14WeatherEffect> _effects;
private readonly CP14WeatherEffectConfig _config;
private EntityQuery<BlockWeatherComponent> _weatherBlockQuery;
private readonly HashSet<Entity<TransformComponent>> _entitiesOnMap = new();
private readonly HashSet<Entity<TransformComponent>> _affectedEntities = new();
private List<Entity<TransformComponent>> _affectedEntities = new();
public CP14WeatherEffectJob(
double maxTime,
@@ -36,7 +37,7 @@ public sealed class CP14WeatherEffectJob : Job<bool>
IRobustRandom random,
Entity<MapGridComponent> mapUid,
MapId mapId,
List<CP14WeatherEffect> effects,
CP14WeatherEffectConfig config,
EntityQuery<BlockWeatherComponent> weatherBlockQuery,
CancellationToken cancellation = default
) : base(maxTime, cancellation)
@@ -50,7 +51,7 @@ public sealed class CP14WeatherEffectJob : Job<bool>
_mapUid = mapUid;
_mapId = mapId;
_effects = effects;
_config = config;
_weatherBlockQuery = weatherBlockQuery;
}
@@ -64,7 +65,7 @@ public sealed class CP14WeatherEffectJob : Job<bool>
foreach (var ent in _entitiesOnMap)
{
//All weatherblocker entites should be affected by weather
if (_weatherBlockQuery.HasComp(ent))
if (_config.CanAffectOnWeatherBlocker && _weatherBlockQuery.HasComp(ent))
{
_affectedEntities.Add(ent);
continue;
@@ -79,10 +80,18 @@ public sealed class CP14WeatherEffectJob : Job<bool>
}
}
_random.Shuffle(_affectedEntities);
// Limit the number of affected entities if specified
if (_config.MaxEntities.HasValue && _affectedEntities.Count > _config.MaxEntities.Value)
{
_affectedEntities = _affectedEntities.Take(_config.MaxEntities.Value).ToList();
}
//Apply weather effects to affected entities
foreach (var entity in _affectedEntities)
{
foreach (var effect in _effects)
foreach (var effect in _config.Effects)
{
effect.ApplyEffect(_entManager, _random, entity);
}

View File

@@ -22,17 +22,12 @@ public sealed class CP14WeatherEffectSystem : EntitySystem
private readonly List<(CP14WeatherEffectJob Job, CancellationTokenSource CancelToken)> _weatherJobs = new();
private const double JobMaxTime = 0.002;
private readonly TimeSpan ProcessFreq = TimeSpan.FromSeconds(5f);
private TimeSpan NextProcessTime = TimeSpan.Zero;
private EntityQuery<BlockWeatherComponent> _weatherBlockQuery;
public override void Initialize()
{
base.Initialize();
_weatherBlockQuery = GetEntityQuery<BlockWeatherComponent>();
NextProcessTime = _timing.CurTime + ProcessFreq;
}
public override void Update(float frameTime)
@@ -50,10 +45,6 @@ public sealed class CP14WeatherEffectSystem : EntitySystem
}
}
if (_timing.CurTime <= NextProcessTime)
return;
NextProcessTime = _timing.CurTime + ProcessFreq;
ProcessWeather();
}
@@ -62,26 +53,34 @@ public sealed class CP14WeatherEffectSystem : EntitySystem
var query = EntityQueryEnumerator<WeatherComponent, MapGridComponent>();
while (query.MoveNext(out var mapUid, out var weather, out var mapComp))
{
foreach (var (proto, data) in weather.Weather)
foreach (var (proto, _) in weather.Weather)
{
if (!_proto.TryIndex(proto, out var indexedWeather))
continue;
var cancelToken = new CancellationTokenSource();
var job = new CP14WeatherEffectJob(
JobMaxTime,
EntityManager,
_lookup,
_weather,
_mapSystem,
_random,
(mapUid, mapComp),
Transform(mapUid).MapID,
indexedWeather.Effects,
_weatherBlockQuery);
foreach (var config in indexedWeather.Config)
{
if (_timing.CurTime <= config.NextEffectTime)
continue;
_weatherJobs.Add((job, cancelToken));
_weatherQueue.EnqueueJob(job);
config.NextEffectTime = _timing.CurTime + config.Frequency;
var cancelToken = new CancellationTokenSource();
var job = new CP14WeatherEffectJob(
JobMaxTime,
EntityManager,
_lookup,
_weather,
_mapSystem,
_random,
(mapUid, mapComp),
Transform(mapUid).MapID,
config,
_weatherBlockQuery);
_weatherJobs.Add((job, cancelToken));
_weatherQueue.EnqueueJob(job);
}
}
}
}

View File

@@ -39,5 +39,5 @@ public sealed partial class WeatherPrototype : IPrototype
/// CP14 Effects
/// </summary>
[DataField]
public List<CP14WeatherEffect> Effects = new();
public List<CP14WeatherEffectConfig> Config = new();
}

View File

@@ -12,3 +12,22 @@ public abstract partial class CP14WeatherEffect
public abstract void ApplyEffect(IEntityManager entManager, IRobustRandom random, EntityUid target);
}
[DataDefinition]
public sealed partial class CP14WeatherEffectConfig
{
[DataField]
public List<CP14WeatherEffect> Effects = new();
[DataField]
public int? MaxEntities = null;
[DataField]
public TimeSpan Frequency = TimeSpan.FromSeconds(5f);
[DataField]
public TimeSpan NextEffectTime = TimeSpan.Zero;
[DataField]
public bool CanAffectOnWeatherBlocker = true;
}

View File

@@ -1,2 +1,2 @@
cp14-event-announcement-demiplane-outbreak = A sense of danger pierces the air... Something from other worlds is invading your town.
cp14-event-announcement-unstable-demiplane = Tension is building... an wild demiplane has opened somewhere in the settlement. Close it down before the monsters come out.
cp14-event-announcement-storm = Storm clouds are gathering on the horizon....

View File

@@ -1,2 +1,2 @@
cp14-event-announcement-demiplane-outbreak = Воздух пронзает чувство опасности... Что-то из других миров вторгается в ваш городок.
cp14-event-announcement-unstable-demiplane = Нарастает напряжение... где-то в городе открылся дикий демиплан. Закройте его, до того как из него вырвутся толпы монстров.
cp14-event-announcement-storm = На горизонте сгущаются грозовые тучи...

View File

@@ -67,7 +67,6 @@ entities:
entries:
- visuals: CP14Mist
- visuals: CP14Rain
- visuals: CP14Storm
- type: LightCycle
- type: SunShadow
- type: SunShadowCycle

View File

@@ -17,7 +17,6 @@
- type: Tag
tags:
- HideContextMenu
- type: AnimationPlayer
- type: PointLight
color: "#73efff"
enabled: true

View File

@@ -27,9 +27,10 @@
- id: CP14MosquitoSpawn
- id: CP14RabbitsSpawn
- id: CP14FrogsSpawn
- id: CP14Storm
- type: entity
parent: CP14BaseStationEventShortDelay
parent: CP14BaseStationEventLongDelay
id: CP14ZombiesSpawn
components:
- type: StationEvent
@@ -46,7 +47,7 @@
prob: 0.08
- type: entity
parent: CP14BaseStationEventShortDelay
parent: CP14BaseStationEventLongDelay
id: CP14HydrasSpawn
components:
- type: StationEvent
@@ -63,7 +64,7 @@
prob: 0.08
- type: entity
parent: CP14BaseStationEventShortDelay
parent: CP14BaseStationEventLongDelay
id: CP14MosquitoSpawn
components:
- type: StationEvent
@@ -111,4 +112,19 @@
- type: VentCrittersRule
entries:
- id: CP14MobGroupSpawnerFrogs
prob: 0.08
prob: 0.08
- type: entity
parent: CP14BaseStationEventLongDelay
id: CP14Storm
components:
- type: StationEvent
startAnnouncement: cp14-event-announcement-storm
startAudio:
collection: CP14LightningFar
earliestStart: 45
minimumPlayers: 10
duration: 180
maxDuration: 600
- type: CP14WeatherRule
weather: CP14Storm

View File

@@ -8,11 +8,12 @@
params:
loop: true
volume: -6
effects:
- !type:ApplyEntityEffect
prob: 0.2
effects:
- !type:ExtinguishReaction
config:
- effects:
- !type:ApplyEntityEffect
prob: 0.2
effects:
- !type:ExtinguishReaction
- type: weather
id: CP14Storm
@@ -24,14 +25,18 @@
params:
loop: true
volume: -6
effects:
- !type:ApplyEntityEffect
prob: 0.4
config:
- maxEntities: 2
frequency: 10
canAffectOnWeatherBlocker: false
effects:
- !type:ExtinguishReaction
- !type:SpawnEntityOnTop
prob: 0.0001
entity: CP14SkyLightning
- !type:ApplyEntityEffect
prob: 0.4
effects:
- !type:ExtinguishReaction
- !type:SpawnEntityOnTop
prob: 0.25
entity: CP14SkyLightning
- type: weather
id: CP14Mist
@@ -45,23 +50,24 @@
- type: weather
id: CP14ManaMist
offsetSpeed: 0.56, -0.36
color: "#3d81ff"
color: "#91a1bf"
alpha: 0.7
sprite:
sprite: /Textures/_CP14/Effects/parallax.rsi
state: noise
effects:
- !type:ApplyEntityEffect
prob: 0.5
effects:
- !type:CP14ManaChange
manaDelta: 8
safe: true
config:
- effects:
- !type:ApplyEntityEffect
prob: 0.5
effects:
- !type:CP14ManaChange
manaDelta: 8
safe: true
- type: weather
id: CP14AntiManaMist
offsetSpeed: -0.56, -0.31
color: "#d929d9"
color: "#302a2a"
alpha: 0.8
sprite:
sprite: /Textures/_CP14/Effects/parallax.rsi
@@ -71,25 +77,27 @@
params:
loop: true
volume: -18
effects:
- !type:ApplyEntityEffect
prob: 0.5
effects:
- !type:CP14ManaChange
manaDelta: -10
safe: true
config:
- effects:
- !type:ApplyEntityEffect
prob: 0.5
effects:
- !type:CP14ManaChange
manaDelta: -10
safe: true
- type: weather
id: CP14SnowLight
sprite:
sprite: /Textures/_CP14/Effects/weather.rsi
state: snowfall_light
#effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -20000
#config:
#- effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -20000
- type: weather
id: CP14SnowMedium
@@ -101,12 +109,13 @@
params:
loop: true
volume: -18
#effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -40000
#config:
#- effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -40000
- type: weather
id: CP14SnowHeavy
@@ -118,12 +127,13 @@
params:
loop: true
volume: -6
#effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -60000
#config:
#- effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: -60000
- type: weather
id: CP14FireStorm
@@ -136,14 +146,15 @@
params:
loop: true
volume: -6
effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: 40000
- !type:ApplyEntityEffect
effects:
- !type:FlammableReaction
multiplier: 1
- !type:Ignite
config:
- effects:
#- !type:ApplyEntityEffect
# prob: 1
# effects:
# - !type:AdjustTemperature
# amount: 40000
- !type:ApplyEntityEffect
effects:
- !type:FlammableReaction
multiplier: 1
- !type:Ignite