Some work on the mess that is this power code.
Jesus. Tons of fixes, refactors and other things. The powernet's code is still awful though.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using SS14.Server.GameObjects;
|
||||
using SS14.Shared.Enums;
|
||||
using SS14.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Power
|
||||
{
|
||||
public class PoweredLightComponent : Component
|
||||
{
|
||||
public override string Name => "PoweredLight";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var device = Owner.GetComponent<PowerDeviceComponent>();
|
||||
var sprite = Owner.GetComponent<SpriteComponent>();
|
||||
var light = Owner.GetComponent<PointLightComponent>();
|
||||
device.OnPowerStateChanged += (sender, args) =>
|
||||
{
|
||||
if (args.Powered)
|
||||
{
|
||||
sprite.LayerSetTexture(0, "Objects/wall_light.png");
|
||||
light.State = LightState.On;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetTexture(0, "Objects/wall_light_off.png");
|
||||
light.State = LightState.Off;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user