Beispiel #1
0
        private void ProviderChanged(ApcPowerReceiverComponent receiver)
        {
            receiver.NetworkLoad.LinkedNetwork = default;

            RaiseLocalEvent(receiver.Owner, new PowerChangedEvent(receiver.Powered, receiver.NetworkLoad.ReceivingPower), true);

            if (TryComp(receiver.Owner, out AppearanceComponent? appearance))
            {
                appearance.SetData(PowerDeviceVisuals.Powered, receiver.Powered);
            }
        }
Beispiel #2
0
        private void OnProviderConnected(EntityUid uid, ApcPowerReceiverComponent receiver, ExtensionCableSystem.ProviderConnectedEvent args)
        {
            var providerUid = args.Provider.Owner;

            if (!EntityManager.TryGetComponent <ApcPowerProviderComponent>(providerUid, out var provider))
            {
                return;
            }

            receiver.Provider = provider;

            ProviderChanged(receiver);
        }
        private bool TryGetWireNet(ApcPowerReceiverComponent apcPowerReceiver, [NotNullWhen(true)] out INodeGroup?net)
        {
            var provider = apcPowerReceiver.Provider;

            if (provider != null && provider.ProviderOwner.TryGetComponent <NodeContainerComponent>(out var nodeContainer))
            {
                var nodes = nodeContainer.Nodes;

                foreach (var node in nodes.Values)
                {
                    if (node.NodeGroupID == NodeGroupID.WireNet && node.NodeGroup != null)
                    {
                        net = node.NodeGroup;
                        return(true);
                    }
                }
            }

            net = default;
            return(false);
        }
 private static void UpdatePowerState(
     GravityGeneratorComponent component,
     ApcPowerReceiverComponent powerReceiver)
 {
     powerReceiver.Load = component.SwitchedOn ? component.ActivePowerUse : component.IdlePowerUse;
 }
Beispiel #5
0
 private static void ProviderChanged(ApcPowerReceiverComponent receiver)
 {
     receiver.NetworkLoad.LinkedNetwork = default;
     receiver.ApcPowerChanged();
 }
Beispiel #6
0
        private void OnProviderDisconnected(EntityUid uid, ApcPowerReceiverComponent receiver, ExtensionCableSystem.ProviderDisconnectedEvent args)
        {
            receiver.Provider = null;

            ProviderChanged(receiver);
        }
Beispiel #7
0
 ///<summary>
 ///Adds some markup to the examine text of whatever object is using this component to tell you if it's powered or not, even if it doesn't have an icon state to do this for you.
 ///</summary>
 private void OnExamined(EntityUid uid, ApcPowerReceiverComponent component, ExaminedEvent args)
 {
     args.PushMarkup(Loc.GetString("power-receiver-component-on-examine-main",
                                   ("stateText", Loc.GetString(component.Powered ? "power-receiver-component-on-examine-powered" :
                                                               "power-receiver-component-on-examine-unpowered"))));
 }