示例#1
0
    /// <returns>false if failed, true otherwise, or if the entity cannot be electrified</returns>
    private bool TrySetElectrocution(EntityUid user, Wire wire, bool timed = false)
    {
        if (!EntityManager.TryGetComponent <ElectrifiedComponent>(wire.Owner, out var electrified))
        {
            return(true);
        }

        var allCut = AllWiresCut(wire.Owner);

        // always set this to true
        SetElectrified(wire.Owner, true, electrified);

        // if we were electrified, then return false
        var electrifiedAttempt = _electrocutionSystem.TryDoElectrifiedAct(wire.Owner, user);

        // if this is timed, we set up a doAfter so that the
        // electrocution continues - unless cancelled
        //
        // if the power is disabled however, just don't bother
        if (timed && IsPowered(wire.Owner) && !allCut)
        {
            WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.ElectrifiedCancel, new TimedWireEvent(AwaitElectrifiedCancel, wire));
        }
        else
        {
            if (allCut)
            {
                SetElectrified(wire.Owner, false, electrified);
            }
        }

        return(!electrifiedAttempt);
    }
示例#2
0
    private void OnCableCut(EntityUid uid, CableComponent cable, CuttingFinishedEvent args)
    {
        if (_electrocutionSystem.TryDoElectrifiedAct(uid, args.User))
        {
            return;
        }

        Spawn(cable.CableDroppedOnCutPrototype, Transform(uid).Coordinates);
        QueueDel(uid);
    }
    private void OnCableCut(EntityUid uid, CableComponent cable, CuttingFinishedEvent args)
    {
        if (_electrocutionSystem.TryDoElectrifiedAct(uid, args.User))
        {
            return;
        }

        _adminLogs.Add(LogType.CableCut, LogImpact.Medium, $"The {ToPrettyString(uid)} at {Transform(uid).Coordinates} was cut by {ToPrettyString(args.User)}.");

        Spawn(cable.CableDroppedOnCutPrototype, Transform(uid).Coordinates);
        QueueDel(uid);
    }
示例#4
0
    /// <returns>false if failed, true otherwise, or if the entity cannot be electrified</returns>
    private bool TrySetElectrocution(EntityUid user, Wire wire, bool timed = false)
    {
        if (!EntityManager.TryGetComponent <ElectrifiedComponent>(wire.Owner, out var electrified))
        {
            return(true);
        }

        // always set this to true
        SetElectrified(wire.Owner, true, electrified);

        var electrifiedAttempt = _electrocutionSystem.TryDoElectrifiedAct(wire.Owner, user);

        // if we were electrified, then return false
        return(!electrifiedAttempt);
    }