Replaces AnchoredChanged C# event with ComponentMessage (#2905)
* Replaces AnchoredChanged C# event with ComponentMessage * Removes unneeded fields Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -614,22 +614,12 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
Logger.WarningS("VitalComponentMissing", $"Disposal unit {Owner.Uid} is missing an anchorable component");
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
|
||||
{
|
||||
physics.AnchoredChanged += UpdateVisualState;
|
||||
}
|
||||
|
||||
UpdateTargetList();
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
|
||||
{
|
||||
physics.AnchoredChanged -= UpdateVisualState;
|
||||
}
|
||||
|
||||
if (_container != null)
|
||||
{
|
||||
foreach (var entity in _container.ContainedEntities.ToArray())
|
||||
@@ -671,6 +661,10 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
Remove(msg.Entity);
|
||||
break;
|
||||
|
||||
case AnchoredChangedMessage:
|
||||
UpdateVisualState();
|
||||
break;
|
||||
|
||||
case PowerChangedMessage powerChanged:
|
||||
PowerStateChanged(powerChanged);
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
@@ -231,10 +231,6 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
|
||||
Contents = ContainerManagerComponent.Ensure<Container>(Name, Owner);
|
||||
Owner.EnsureComponent<AnchorableComponent>();
|
||||
|
||||
var physics = Owner.EnsureComponent<PhysicsComponent>();
|
||||
|
||||
physics.AnchoredChanged += AnchoredChanged;
|
||||
}
|
||||
|
||||
protected override void Startup()
|
||||
@@ -254,9 +250,6 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
{
|
||||
base.OnRemove();
|
||||
|
||||
var physics = Owner.EnsureComponent<PhysicsComponent>();
|
||||
physics.AnchoredChanged -= AnchoredChanged;
|
||||
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
@@ -275,6 +268,10 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
_lastClang = _gameTiming.CurTime;
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_clangSound, Owner.Transform.Coordinates);
|
||||
break;
|
||||
|
||||
case AnchoredChangedMessage:
|
||||
AnchoredChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -569,21 +569,11 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
Logger.WarningS("VitalComponentMissing", $"Disposal unit {Owner.Uid} is missing an anchorable component");
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
|
||||
{
|
||||
physics.AnchoredChanged += UpdateVisualState;
|
||||
}
|
||||
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
|
||||
{
|
||||
physics.AnchoredChanged -= UpdateVisualState;
|
||||
}
|
||||
|
||||
foreach (var entity in _container.ContainedEntities.ToArray())
|
||||
{
|
||||
_container.ForceRemove(entity);
|
||||
@@ -617,6 +607,10 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
Remove(msg.Entity);
|
||||
break;
|
||||
|
||||
case AnchoredChangedMessage:
|
||||
UpdateVisualState();
|
||||
break;
|
||||
|
||||
case PowerChangedMessage powerChanged:
|
||||
PowerStateChanged(powerChanged);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user