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>
/// This list of components that will be added for the second trigger.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("components", required: true)]
public ComponentRegistry SecondStageComponents = new();
[DataField("nextTriggerTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
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);
if(component.RemoveOnTrigger)
if (component.RemoveOnTrigger)
RemCompDeferred<AnchorOnTriggerComponent>(uid);
}

View File

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

View File

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