Power Rework (#863)

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2020-06-28 09:23:26 -06:00
committed by GitHub
parent ffe25de723
commit 23cc6b1d4e
154 changed files with 11253 additions and 3913 deletions

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.VendingMachines;
@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
#pragma warning restore 649
private AppearanceComponent _appearance;
private BoundUserInterface _userInterface;
private PowerDeviceComponent _powerDevice;
private PowerReceiverComponent _powerReceiver;
private bool _ejecting = false;
private TimeSpan _animationDuration = TimeSpan.Zero;
@@ -39,7 +39,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
private string _description;
private string _spriteName;
private bool Powered => _powerDevice.Powered;
private bool Powered => _powerReceiver.Powered;
private bool _broken = false;
public void Activate(ActivateEventArgs eventArgs)
@@ -103,16 +103,17 @@ namespace Content.Server.GameObjects.Components.VendingMachines
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
.GetBoundUserInterface(VendingMachineUiKey.Key);
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
_powerDevice.OnPowerStateChanged += UpdatePower;
_powerReceiver = Owner.GetComponent<PowerReceiverComponent>();
_powerReceiver.OnPowerStateChanged += UpdatePower;
TrySetVisualState(_powerReceiver.Powered ? VendingMachineVisualState.Normal : VendingMachineVisualState.Off);
InitializeFromPrototype();
}
public override void OnRemove()
{
_appearance = null;
_powerDevice.OnPowerStateChanged -= UpdatePower;
_powerDevice = null;
_powerReceiver.OnPowerStateChanged -= UpdatePower;
_powerReceiver = null;
base.OnRemove();
}