Remove IDestroyAct, IBreakAct (#7876)

This commit is contained in:
Alex Evgrashin
2022-05-03 01:43:25 +03:00
committed by GitHub
parent 5d23100af3
commit 50ae467c76
21 changed files with 135 additions and 151 deletions

View File

@@ -1,5 +1,4 @@
using Content.Server.Light.EntitySystems;
using Content.Shared.Acts;
using Content.Shared.Light;
using Content.Shared.Sound;
using Robust.Shared.Analyzers;
@@ -13,7 +12,7 @@ namespace Content.Server.Light.Components
/// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless.
/// </summary>
[RegisterComponent, Friend(typeof(LightBulbSystem))]
public sealed class LightBulbComponent : Component, IBreakAct
public sealed class LightBulbComponent : Component
{
[DataField("color")]
public Color Color = Color.White;
@@ -41,12 +40,5 @@ namespace Content.Server.Light.Components
[DataField("breakSound")]
public SoundSpecifier BreakSound = new SoundCollectionSpecifier("GlassBreak");
// TODO: move me to ECS
public void OnBreak(BreakageEventArgs eventArgs)
{
EntitySystem.Get<LightBulbSystem>()
.SetState(Owner, LightBulbState.Broken, this);
}
}
}

View File

@@ -1,10 +1,8 @@
using Content.Server.Light.Components;
using Content.Server.Light.Events;
using Content.Shared.Destructible;
using Content.Shared.Light;
using Content.Shared.Throwing;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Player;
namespace Content.Server.Light.EntitySystems
@@ -17,6 +15,7 @@ namespace Content.Server.Light.EntitySystems
SubscribeLocalEvent<LightBulbComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<LightBulbComponent, LandEvent>(HandleLand);
SubscribeLocalEvent<LightBulbComponent, BreakageEventArgs>(OnBreak);
}
private void OnInit(EntityUid uid, LightBulbComponent bulb, ComponentInit args)
@@ -32,6 +31,11 @@ namespace Content.Server.Light.EntitySystems
SetState(uid, LightBulbState.Broken, bulb);
}
private void OnBreak(EntityUid uid, LightBulbComponent component, BreakageEventArgs args)
{
SetState(uid, LightBulbState.Broken, component);
}
/// <summary>
/// Set a new color for a light bulb and raise event about change
/// </summary>