Portable flasher tweaks (#6517)

This commit is contained in:
metalgearsloth
2022-02-08 14:08:21 +11:00
committed by GitHub
parent 70c0a502cf
commit 310f6e14f1
9 changed files with 145 additions and 115 deletions

View File

@@ -4,6 +4,7 @@ using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using System.Collections.Generic;
using Content.Shared.Explosion;
namespace Content.Server.Explosion.Components
{
@@ -12,7 +13,7 @@ namespace Content.Server.Explosion.Components
/// Raises a <see cref="TriggerEvent"/> whenever an entity collides with a fixture attached to the owner of this component.
/// </summary>
[RegisterComponent]
public sealed class TriggerOnProximityComponent : Component
public sealed class TriggerOnProximityComponent : SharedTriggerOnProximityComponent
{
public const string FixtureID = "trigger-on-proximity-fixture";

View File

@@ -73,14 +73,11 @@ public sealed partial class TriggerSystem
component.Colliding.Add(args.OtherFixture.Body);
}
private void OnProximityEndCollide(EntityUid uid, TriggerOnProximityComponent component, EndCollideEvent args)
private static void OnProximityEndCollide(EntityUid uid, TriggerOnProximityComponent component, EndCollideEvent args)
{
if (args.OurFixture.ID != TriggerOnProximityComponent.FixtureID) return;
component.Colliding.Remove(args.OtherFixture.Body);
if (component.Colliding.Count == 0)
_activeProximities.Remove(component);
}
private void SetProximityAppearance(EntityUid uid, TriggerOnProximityComponent component)
@@ -103,10 +100,14 @@ public sealed partial class TriggerSystem
}
else
{
component.Accumulator = component.Cooldown;
component.Accumulator += component.Cooldown;
}
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent))
{
appearanceComponent.SetData(ProximityTriggerVisualState.State, ProximityTriggerVisuals.Active);
}
SetProximityAppearance(component.Owner, component);
Trigger(component.Owner);
}
@@ -116,12 +117,6 @@ public sealed partial class TriggerSystem
foreach (var comp in _activeProximities)
{
if (!comp.Enabled)
{
toRemove.Add(comp);
continue;
}
MetaDataComponent? metadata = null;
if (Deleted(comp.Owner, metadata))
@@ -130,12 +125,22 @@ public sealed partial class TriggerSystem
continue;
}
SetProximityAppearance(comp.Owner, comp);
if (Paused(comp.Owner, metadata)) continue;
comp.Accumulator -= frameTime;
if (comp.Accumulator > 0f) continue;
// Only remove it from accumulation when nothing colliding anymore.
if (!comp.Enabled || comp.Colliding.Count == 0)
{
comp.Accumulator = 0f;
toRemove.Add(comp);
continue;
}
// Alright now that we have no cd check everything in range.
foreach (var colliding in comp.Colliding)