Example #1
0
 private void SetWireCuts(EntityUid owner, bool isCut)
 {
     if (WiresSystem.TryGetData(owner, PowerWireActionKey.CutWires, out int?cut))
     {
         cut = isCut ? cut + 1 : cut - 1;
         WiresSystem.SetData(owner, PowerWireActionKey.CutWires, cut);
     }
 }
Example #2
0
    private void SetWireCuts(EntityUid owner, bool isCut)
    {
        if (WiresSystem.TryGetData(owner, PowerWireActionKey.CutWires, out int?cut) &&
            WiresSystem.TryGetData(owner, PowerWireActionKey.WireCount, out int?count))
        {
            if (cut == count && isCut ||
                cut <= 0 && !isCut)
            {
                return;
            }

            cut = isCut ? cut + 1 : cut - 1;
            WiresSystem.SetData(owner, PowerWireActionKey.CutWires, cut);
        }
    }
Example #3
0
    // This should add a wire into the entity's state, whether it be
    // in WiresComponent or ApcPowerReceiverComponent.
    public override bool AddWire(Wire wire, int count)
    {
        if (!WiresSystem.HasData(wire.Owner, PowerWireActionKey.CutWires))
        {
            WiresSystem.SetData(wire.Owner, PowerWireActionKey.CutWires, 0);
        }

        if (count == 1)
        {
            WiresSystem.SetData(wire.Owner, PowerWireActionKey.MainWire, wire.Id);
        }

        WiresSystem.SetData(wire.Owner, PowerWireActionKey.WireCount, count);

        return(true);
    }
Example #4
0
    public override bool Pulse(EntityUid user, Wire wire)
    {
        WiresSystem.TryCancelWireAction(wire.Owner, PowerWireActionKey.ElectrifiedCancel);

        var electrocuted = !TrySetElectrocution(user, wire, true);

        if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsedKey) &&
            pulsedKey)
        {
            return(false);
        }

        WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, true);
        WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.PulseCancel, new TimedWireEvent(AwaitPulseCancel, wire));

        if (electrocuted)
        {
            return(false);
        }

        SetPower(wire.Owner, true);
        return(true);
    }
Example #5
0
 private void AwaitPulseCancel(Wire wire)
 {
     WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, false);
     SetPower(wire.Owner, false);
 }