Gravity generator rewrite (#4828)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2021-11-02 01:12:55 +01:00
committed by GitHub
parent 0e33b246db
commit 059fa9ae48
17 changed files with 739 additions and 361 deletions

View File

@@ -72,6 +72,8 @@ namespace Content.Server.Power.Components
DesiredPower = 5
};
public float PowerReceived => NetworkLoad.ReceivingPower;
protected override void OnRemove()
{
Provider?.RemoveReceiver(this);
@@ -81,15 +83,10 @@ namespace Content.Server.Power.Components
public void ApcPowerChanged()
{
OnNewPowerState();
}
private void OnNewPowerState()
{
#pragma warning disable 618
SendMessage(new PowerChangedMessage(Powered));
#pragma warning restore 618
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerChangedEvent(Powered));
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower));
if (Owner.TryGetComponent<AppearanceComponent>(out var appearance))
{
@@ -126,10 +123,12 @@ namespace Content.Server.Power.Components
public sealed class PowerChangedEvent : EntityEventArgs
{
public readonly bool Powered;
public readonly float ReceivingPower;
public PowerChangedEvent(bool powered)
public PowerChangedEvent(bool powered, float receivingPower)
{
Powered = powered;
ReceivingPower = receivingPower;
}
}
}