Hot Fix of Gravity Grenades (#19414)

* Supermatter grenade fix

* taking out the trash

* Removing debug Console.Log() in twostage

* More fixes

* Better to put LoadComponents on Update, else it will modify list of other untriggered components
This commit is contained in:
AlexMorgan3817
2023-09-04 19:23:48 +07:00
committed by GitHub
parent 91cfabd6f6
commit 61b0e6abcd
4 changed files with 21 additions and 17 deletions

View File

@@ -19,12 +19,15 @@ public sealed partial class TwoStageTriggerComponent : Component
/// <summary> /// <summary>
/// This list of components that will be added for the second trigger. /// This list of components that will be added for the second trigger.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("components", required: true)] [DataField("components", required: true)]
public ComponentRegistry SecondStageComponents = new(); public ComponentRegistry SecondStageComponents = new();
[DataField("nextTriggerTime", customTypeSerializer: typeof(TimeOffsetSerializer))] [DataField("nextTriggerTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan? NextTriggerTime; public TimeSpan? NextTriggerTime;
[ViewVariables(VVAccess.ReadWrite), DataField("triggered")] public bool Triggered = false; [DataField("triggered")]
public bool Triggered = false;
[DataField("ComponentsIsLoaded")]
public bool ComponentsIsLoaded = false;
} }

View File

@@ -107,7 +107,7 @@ namespace Content.Server.Explosion.EntitySystems
_transformSystem.AnchorEntity(uid, xform); _transformSystem.AnchorEntity(uid, xform);
if(component.RemoveOnTrigger) if (component.RemoveOnTrigger)
RemCompDeferred<AnchorOnTriggerComponent>(uid); RemCompDeferred<AnchorOnTriggerComponent>(uid);
} }

View File

@@ -33,7 +33,7 @@ public sealed class TwoStageTriggerSystem : EntitySystem
component.NextTriggerTime = _timing.CurTime + component.TriggerDelay; component.NextTriggerTime = _timing.CurTime + component.TriggerDelay;
} }
public void LoadComponents(EntityUid uid, TwoStageTriggerComponent component) private void LoadComponents(EntityUid uid, TwoStageTriggerComponent component)
{ {
foreach (var (name, entry) in component.SecondStageComponents) foreach (var (name, entry) in component.SecondStageComponents)
{ {
@@ -47,6 +47,7 @@ public sealed class TwoStageTriggerSystem : EntitySystem
_serializationManager.CopyTo(entry.Component, ref temp); _serializationManager.CopyTo(entry.Component, ref temp);
EntityManager.AddComponent(uid, comp); EntityManager.AddComponent(uid, comp);
} }
component.ComponentsIsLoaded = true;
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -54,17 +55,18 @@ public sealed class TwoStageTriggerSystem : EntitySystem
base.Update(frameTime); base.Update(frameTime);
var enumerator = EntityQueryEnumerator<TwoStageTriggerComponent>(); var enumerator = EntityQueryEnumerator<TwoStageTriggerComponent>();
while (enumerator.MoveNext(out var uid, out var component)) while (enumerator.MoveNext(out var uid, out var component))
{ {
if (component.NextTriggerTime == null) if (!component.Triggered)
continue; continue;
if (!component.ComponentsIsLoaded)
LoadComponents(uid, component);
if (_timing.CurTime < component.NextTriggerTime) if (_timing.CurTime < component.NextTriggerTime)
continue; continue;
component.NextTriggerTime = null; component.NextTriggerTime = null;
LoadComponents(uid, component);
_triggerSystem.Trigger(uid); _triggerSystem.Trigger(uid);
} }
} }

View File

@@ -148,7 +148,7 @@
- type: AnchorOnTrigger - type: AnchorOnTrigger
removeOnTrigger: true removeOnTrigger: true
- type: TwoStageTrigger - type: TwoStageTrigger
triggerDelay: 10 triggerDelay: 10.45
components: components:
- type: AmbientSound - type: AmbientSound
enabled: true enabled: true
@@ -194,15 +194,15 @@
sound: sound:
path: /Audio/Effects/Grenades/Supermatter/whitehole_start.ogg path: /Audio/Effects/Grenades/Supermatter/whitehole_start.ogg
volume: 5 volume: 5
- type: AmbientSound
enabled: false
volume: -5
range: 14
sound:
path: /Audio/Effects/Grenades/Supermatter/whitehole_loop.ogg
- type: TwoStageTrigger - type: TwoStageTrigger
triggerDelay: 10 triggerDelay: 11.14
components: components:
- type: AmbientSound
enabled: true
volume: -5
range: 14
sound:
path: /Audio/Effects/Grenades/Supermatter/whitehole_loop.ogg
- type: GravityWell - type: GravityWell
maxRange: 10 maxRange: 10
baseRadialAcceleration: -180 baseRadialAcceleration: -180
@@ -222,10 +222,9 @@
sound: sound:
path: /Audio/Effects/Grenades/Supermatter/supermatter_end.ogg path: /Audio/Effects/Grenades/Supermatter/supermatter_end.ogg
params: params:
volume: 5 volume: 15
- type: DeleteOnTrigger - type: DeleteOnTrigger
- type: entity - type: entity
name: the nuclear option name: the nuclear option
description: Please don't throw it, think of the children. description: Please don't throw it, think of the children.