Remove usages of AnchoredChangedMessage.

It was a component message which is now deprecated.
This commit is contained in:
Pieter-Jan Briers
2021-05-13 02:05:46 +02:00
parent 4903c3bbc6
commit 251df93b71
16 changed files with 225 additions and 75 deletions

View File

@@ -94,17 +94,6 @@ namespace Content.Server.GameObjects.Components.Atmos
UpdateAppearance(); UpdateAppearance();
} }
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case AnchoredChangedMessage:
AnchorUpdate();
break;
}
}
#region Connector port methods #region Connector port methods
public override void OnRemove() public override void OnRemove()
@@ -139,7 +128,7 @@ namespace Content.Server.GameObjects.Components.Atmos
ConnectedPort = null; ConnectedPort = null;
} }
private void AnchorUpdate() public void AnchorUpdate()
{ {
if (Anchored) if (Anchored)
{ {

View File

@@ -445,7 +445,7 @@ namespace Content.Server.GameObjects.Components.Disposal
_tag = tag; _tag = tag;
} }
private void UpdateVisualState() public void UpdateVisualState()
{ {
UpdateVisualState(false); UpdateVisualState(false);
} }
@@ -620,10 +620,6 @@ namespace Content.Server.GameObjects.Components.Disposal
Remove(msg.Entity); Remove(msg.Entity);
break; break;
case AnchoredChangedMessage:
UpdateVisualState();
break;
case PowerChangedMessage powerChanged: case PowerChangedMessage powerChanged:
PowerStateChanged(powerChanged); PowerStateChanged(powerChanged);
break; break;

View File

@@ -194,7 +194,7 @@ namespace Content.Server.GameObjects.Components.Disposal
appearance.SetData(DisposalTubeVisuals.VisualState, state); appearance.SetData(DisposalTubeVisuals.VisualState, state);
} }
private void AnchoredChanged() public void AnchoredChanged()
{ {
if (!Owner.TryGetComponent(out PhysicsComponent? physics)) if (!Owner.TryGetComponent(out PhysicsComponent? physics))
{ {
@@ -267,10 +267,6 @@ namespace Content.Server.GameObjects.Components.Disposal
_lastClang = _gameTiming.CurTime; _lastClang = _gameTiming.CurTime;
SoundSystem.Play(Filter.Pvs(Owner), _clangSound, Owner.Transform.Coordinates); SoundSystem.Play(Filter.Pvs(Owner), _clangSound, Owner.Transform.Coordinates);
break; break;
case AnchoredChangedMessage:
AnchoredChanged();
break;
} }
} }

View File

@@ -382,7 +382,7 @@ namespace Content.Server.GameObjects.Components.Disposal
} }
} }
private void UpdateVisualState() public void UpdateVisualState()
{ {
UpdateVisualState(false); UpdateVisualState(false);
} }
@@ -547,10 +547,6 @@ namespace Content.Server.GameObjects.Components.Disposal
Remove(msg.Entity); Remove(msg.Entity);
break; break;
case AnchoredChangedMessage:
UpdateVisualState();
break;
case PowerChangedMessage powerChanged: case PowerChangedMessage powerChanged:
PowerStateChanged(powerChanged); PowerStateChanged(powerChanged);
break; break;

View File

@@ -16,17 +16,6 @@ namespace Content.Server.GameObjects.Components.PA
Owner.Transform.Anchored = true; Owner.Transform.Anchored = true;
} }
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case AnchoredChangedMessage:
OnAnchorChanged();
break;
}
}
public void OnAnchorChanged() public void OnAnchorChanged()
{ {
RescanIfPossible(); RescanIfPossible();

View File

@@ -106,17 +106,6 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
} }
} }
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case AnchoredChangedMessage:
AnchorUpdate();
break;
}
}
public void ApcPowerChanged() public void ApcPowerChanged()
{ {
var oldPowered = Powered; var oldPowered = Powered;
@@ -211,7 +200,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
} }
} }
private void AnchorUpdate() public void AnchorUpdate()
{ {
if (Anchored) if (Anchored)
{ {

View File

@@ -25,18 +25,7 @@ namespace Content.Server.GameObjects.Components.Power.PowerNetComponents
[ComponentDependency] private readonly PhysicsComponent? _collidableComponent = default!; [ComponentDependency] private readonly PhysicsComponent? _collidableComponent = default!;
public override void HandleMessage(ComponentMessage message, IComponent? component) public void OnAnchoredChanged()
{
base.HandleMessage(message, component);
switch (message)
{
case AnchoredChangedMessage:
OnAnchoredChanged();
break;
}
}
private void OnAnchoredChanged()
{ {
if(_collidableComponent != null && _collidableComponent.BodyType == BodyType.Static) if(_collidableComponent != null && _collidableComponent.BodyType == BodyType.Static)
Owner.SnapToGrid(); Owner.SnapToGrid();

View File

@@ -5,7 +5,6 @@ using System.Linq;
using Content.Shared.GameObjects.Components.Tag; using Content.Shared.GameObjects.Components.Tag;
using Content.Shared.Physics; using Content.Shared.Physics;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
@@ -70,18 +69,7 @@ namespace Content.Server.GameObjects.Components.Singularity
public bool CanRepell(IEntity toRepell) => _connection1?.Item2?.CanRepell(toRepell) == true || public bool CanRepell(IEntity toRepell) => _connection1?.Item2?.CanRepell(toRepell) == true ||
_connection2?.Item2?.CanRepell(toRepell) == true; _connection2?.Item2?.CanRepell(toRepell) == true;
public override void HandleMessage(ComponentMessage message, IComponent? component) public void OnAnchoredChanged()
{
base.HandleMessage(message, component);
switch (message)
{
case AnchoredChangedMessage:
OnAnchoredChanged();
break;
}
}
private void OnAnchoredChanged()
{ {
if(_collidableComponent?.BodyType != BodyType.Static) if(_collidableComponent?.BodyType != BodyType.Static)
{ {

View File

@@ -0,0 +1,30 @@
using Content.Server.GameObjects.Components.Singularity;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
{
public sealed class ContainmentFieldGeneratorSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ContainmentFieldGeneratorComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<ContainmentFieldGeneratorComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
ContainmentFieldGeneratorComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.OnAnchoredChanged();
}
}
}

View File

@@ -0,0 +1,30 @@
using Content.Server.GameObjects.Components.Disposal;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems.Disposal
{
public sealed class DisposalMailingUnitSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DisposalMailingUnitComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<DisposalMailingUnitComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
DisposalMailingUnitComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.UpdateVisualState();
}
}
}

View File

@@ -0,0 +1,30 @@
using Content.Server.GameObjects.Components.Disposal;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems.Disposal
{
public sealed class DisposalTubeSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
DisposalTubeComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.AnchoredChanged();
}
}
}

View File

@@ -0,0 +1,30 @@
using Content.Server.GameObjects.Components.Disposal;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems.Disposal
{
public sealed class DisposalUnitSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DisposalUnitComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<DisposalUnitComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
DisposalUnitComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.UpdateVisualState();
}
}
}

View File

@@ -7,6 +7,28 @@ namespace Content.Server.GameObjects.EntitySystems
[UsedImplicitly] [UsedImplicitly]
internal sealed class GasCanisterSystem : EntitySystem internal sealed class GasCanisterSystem : EntitySystem
{ {
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GasCanisterComponent, PhysicsBodyTypeChangedEvent>(OnBodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<GasCanisterComponent, PhysicsBodyTypeChangedEvent>();
}
private static void OnBodyTypeChanged(
EntityUid uid,
GasCanisterComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.AnchorUpdate();
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var component in ComponentManager.EntityQuery<GasCanisterComponent>(true)) foreach (var component in ComponentManager.EntityQuery<GasCanisterComponent>(true))

View File

@@ -13,6 +13,22 @@ namespace Content.Server.GameObjects.EntitySystems
base.Initialize(); base.Initialize();
EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent); EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
SubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
ParticleAcceleratorPartComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.OnAnchorChanged();
} }
private static void RotateEvent(RotateEvent ev) private static void RotateEvent(RotateEvent ev)

View File

@@ -0,0 +1,30 @@
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
{
public sealed class PowerReceiverSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PowerReceiverComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<PowerReceiverComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
PowerReceiverComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.AnchorUpdate();
}
}
}

View File

@@ -0,0 +1,30 @@
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
{
public sealed class RadiationCollectorSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RadiationCollectorComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public override void Shutdown()
{
base.Shutdown();
UnsubscribeLocalEvent<RadiationCollectorComponent, PhysicsBodyTypeChangedEvent>();
}
private static void BodyTypeChanged(
EntityUid uid,
RadiationCollectorComponent component,
PhysicsBodyTypeChangedEvent args)
{
component.OnAnchoredChanged();
}
}
}