示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggeringTeslaEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="teslaGate"><inheritdoc cref="Tesla"/></param>
 public TriggeringTeslaEventArgs(Player player, TeslaGate teslaGate)
 {
     Player           = player;
     Tesla            = teslaGate;
     IsInHurtingRange = Tesla.PlayerInHurtRange(player);
     IsTriggerable    = Tesla.PlayerInTriggerRange(player);
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractingTeslaEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="tesla"><inheritdoc cref="Tesla"/></param>
 /// <param name="auxiliaryPowerCost"><inheritdoc cref="AuxiliaryPowerCost"/></param>
 public InteractingTeslaEventArgs(Player player, TeslaGate tesla, float auxiliaryPowerCost)
 {
     Player             = player;
     Tesla              = tesla;
     AuxiliaryPowerCost = auxiliaryPowerCost;
     IsAllowed          = auxiliaryPowerCost <= player.Energy;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractingTeslaEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="tesla"><inheritdoc cref="Tesla"/></param>
 /// <param name="auxiliaryPowerCost"><inheritdoc cref="AuxiliaryPowerCost"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public InteractingTeslaEventArgs(Player player, TeslaGate tesla, float auxiliaryPowerCost, bool isAllowed = true)
 {
     Player             = player;
     Tesla              = tesla;
     AuxiliaryPowerCost = auxiliaryPowerCost;
     IsAllowed          = isAllowed;
 }
示例#4
0
        public static void Postfix(TeslaGate __instance, bool hurtRange, ref List <PlayerStats> __result)
        {
            try
            {
                __result = new List <PlayerStats>();

                foreach (var player in Player.GetAllPlayers())
                {
                    var triggerable = true;

                    if (!(Vector3.Distance(__instance.transform.position, player.Position) <
                          __instance.sizeOfTrigger) || player.Role == RoleType.Spectator)
                    {
                        continue;
                    }
                    Events.InvokeTeslaTrigger(player, hurtRange, ref triggerable);

                    if (triggerable)
                    {
                        __result.Add(player.GetComponent <PlayerStats>());
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error($"TriggerTeslaEvent error: {e}");
            }
        }
示例#5
0
        private static void Postfix(TeslaGate __instance, bool hurtRange, ref List <PlayerStats> __result)
        {
            try
            {
                __result = new List <PlayerStats>();
                var Tesla = Map.Get.Teslas.FirstOrDefault(x => x.GameObject == __instance.gameObject);

                foreach (var player in SynapseController.Server.Players)
                {
                    if (Vector3.Distance(Tesla.Position, player.Position) > Tesla.SizeOfTrigger || player.IsDead)
                    {
                        continue;
                    }

                    if (player.Invisible)
                    {
                        continue;
                    }

                    SynapseController.Server.Events.Map.InvokeTriggerTeslaEv(player, Tesla, hurtRange, out var trigger);

                    if (trigger)
                    {
                        __result.Add(player.PlayerStats);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: TriggerTesla failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
            }
        }
示例#6
0
        public static void Postfix(TeslaGate __instance, bool hurtRange, ref List <PlayerStats> __result)
        {
            if (EventPlugin.TriggerTeslaPatchDisable)
            {
                return;
            }

            try
            {
                __result = new List <PlayerStats>();
                foreach (GameObject player in PlayerManager.players)
                {
                    bool triggerable = true;
                    if (Vector3.Distance(__instance.transform.position, player.transform.position) <
                        __instance.sizeOfTrigger &&
                        player.GetComponent <CharacterClassManager>().CurClass != RoleType.Spectator)
                    {
                        Events.InvokeTriggerTesla(player, hurtRange, ref triggerable);
                        if (triggerable)
                        {
                            __result.Add(player.GetComponent <PlayerStats>());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error($"Tesla trigger event error: {e}");
            }
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractingTeslaEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="teslaGate"><inheritdoc cref="Tesla"/></param>
 /// <param name="auxiliaryPowerCost"><inheritdoc cref="AuxiliaryPowerCost"/></param>
 public InteractingTeslaEventArgs(Player player, global::TeslaGate teslaGate, float auxiliaryPowerCost)
 {
     Player             = player;
     Tesla              = TeslaGate.Get(teslaGate);
     AuxiliaryPowerCost = auxiliaryPowerCost;
     IsAllowed          = auxiliaryPowerCost <= player.Role.As <Scp079Role>().Energy;
 }
示例#8
0
        private static bool OnRange(TeslaGate __instance, out bool __result, ReferenceHub player)
        {
            __result = false;
            try
            {
                var synapseplayer = player.GetPlayer();
                if (synapseplayer.Invisible)
                {
                    return(false);
                }

                __result = __instance.InRange(synapseplayer.Position);

                if (__result)
                {
                    Server.Get.Events.Map.InvokeTriggerTeslaEv(synapseplayer, __instance.GetTesla(), ref __result);
                }

                return(false);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: TriggerTesla failed!!\n{e}");
                return(true);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggeringTeslaEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="tesla"><inheritdoc cref="Tesla"/></param>
 /// <param name="isInHurtingRange"><inheritdoc cref="IsInHurtingRange"/></param>
 /// <param name="isTriggerable"><inheritdoc cref="IsTriggerable"/></param>
 /// <param name="isInIdleRange"><inheritdoc cref="IsInIdleRange"/></param>
 public TriggeringTeslaEventArgs(Player player, TeslaGate tesla, bool isInHurtingRange, bool isTriggerable, bool isInIdleRange = true)
 {
     Player           = player;
     Tesla            = tesla;
     IsInHurtingRange = isInHurtingRange;
     IsTriggerable    = isTriggerable;
     IsInIdleRange    = isInIdleRange;
 }
示例#10
0
 public static Tesla GetTesla(this TeslaGate teslaGate) => Map.Get.Teslas.FirstOrDefault(x => x.GameObject == teslaGate.gameObject);
示例#11
0
        private static bool Scp079Interact(Scp079PlayerScript __instance, Command079 command, string args, GameObject target)
        {
            args ??= "";
            try
            {
                if (!__instance._interactRateLimit.CanExecute(true))
                {
                    return(false);
                }
                if (!__instance.iAm079)
                {
                    return(false);
                }
                string[] array = args.Split(':');
                GameCore.Console.AddDebugLog("SCP079", "Command received from a client: " + command, MessageImportance.LessImportant, false);
                __instance.RefreshCurrentRoom();
                if (!__instance.CheckInteractableLegitness(__instance.CurrentRoom, target, true))
                {
                    return(false);
                }

                DoorVariant   doorVariant    = null; // F you, compiler
                bool          gotDoorVariant = target?.TryGetComponent(out doorVariant) ?? false;
                List <string> list           = GameCore.ConfigFile.ServerConfig.GetStringList("scp079_door_blacklist") ?? new List <string>();

                switch (command)
                {
                case Command079.Door:
                {
                    if (AlphaWarheadController.Host.inProgress)
                    {
                        return(false);
                    }
                    if (target == null)
                    {
                        GameCore.Console.AddDebugLog("SCP079", "The door command requires a target.", MessageImportance.LessImportant, false);
                        return(false);
                    }
                    if (!gotDoorVariant)
                    {
                        return(false);
                    }
                    if (doorVariant.TryGetComponent(out DoorNametagExtension doorNametagExtension) && list.Count > 0 && list.Contains(doorNametagExtension.GetName))
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant, false);
                        return(false);
                    }
                    string text          = doorVariant.RequiredPermissions.RequiredPermissions.ToString();
                    float  manaFromLabel = __instance.GetManaFromLabel("Door Interaction " + (text.Contains(",") ? text.Split(',')[0] : text), __instance.abilities);



                    var action         = doorVariant.TargetState ? Scp079EventMisc.DoorAction.Closing : Scp079EventMisc.DoorAction.Opening;
                    var intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy;

                    SynapseController.Server.Events.Scp.Scp079.Invoke079DoorInteract(
                        __instance.gameObject.GetPlayer(),
                        action,
                        intendedResult,
                        manaFromLabel,
                        doorVariant.GetDoor(),
                        out var actualResult
                        );

                    switch (actualResult)
                    {
                    case Scp079EventMisc.InteractionResult.Allow:
                    {
                        bool targetState = doorVariant.TargetState;
                        doorVariant.ServerInteract(ReferenceHub.GetHub(__instance.gameObject), 0);
                        if (targetState != doorVariant.TargetState)
                        {
                            __instance.Mana -= manaFromLabel;
                            __instance.AddInteractionToHistory(target, true);
                            GameCore.Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant, false);
                            return(false);
                        }
                        GameCore.Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant, false);
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.Disallow:
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant, false);
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.NoEnergy:
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant, false);
                        // might wanna change __instance.Mana to 0,
                        // the client may do another check when being told that the player has not enough mana,
                        // resulting in realizing they do indeed have enough mana
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                        return(false);
                    }
                    }
                    return(false);
                }

                case Command079.Doorlock:
                {
                    if (AlphaWarheadController.Host.inProgress)
                    {
                        return(false);
                    }
                    if (target == null)
                    {
                        GameCore.Console.AddDebugLog("SCP079", "The door lock command requires a target.", MessageImportance.LessImportant, false);
                        return(false);
                    }
                    if (doorVariant == null)
                    {
                        return(false);
                    }
                    ;
                    if (doorVariant.TryGetComponent(out DoorNametagExtension doorNametagExtension2) && list.Count > 0 && list.Contains(doorNametagExtension2.GetName))
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant, false);
                        return(false);
                    }

                    float manaFromLabel = __instance.GetManaFromLabel("Door Lock Minimum", __instance.abilities);
                    var   action        = ((DoorLockReason)doorVariant.ActiveLocks).HasFlag(DoorLockReason.Regular079) ? Scp079EventMisc.DoorAction.Unlocking : Scp079EventMisc.DoorAction.Locking;

                    Scp079EventMisc.InteractionResult intendedResult;
                    if (action == Scp079EventMisc.DoorAction.Unlocking)
                    {
                        intendedResult = __instance.lockedDoors.Contains(doorVariant.netId) ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.Disallow;
                    }
                    else
                    {
                        intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy;
                    }

                    SynapseController.Server.Events.Scp.Scp079.Invoke079DoorInteract(
                        __instance.gameObject.GetPlayer(),
                        action,
                        intendedResult,
                        manaFromLabel,
                        doorVariant.GetDoor(),
                        out var actualResult
                        );

                    switch (actualResult)
                    {
                    case Scp079EventMisc.InteractionResult.Allow when action == Scp079EventMisc.DoorAction.Unlocking:
                    {
                        if (!__instance.lockedDoors.Contains(doorVariant.netId))
                        {
                            return(false);
                        }
                        __instance.lockedDoors.Remove(doorVariant.netId);
                        doorVariant.ServerChangeLock(DoorLockReason.Regular079, false);
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.Allow when action == Scp079EventMisc.DoorAction.Locking:
                    {
                        if (!__instance.lockedDoors.Contains(doorVariant.netId))
                        {
                            __instance.lockedDoors.Add(doorVariant.netId);
                        }
                        doorVariant.ServerChangeLock(DoorLockReason.Regular079, true);
                        __instance.AddInteractionToHistory(doorVariant.gameObject, true);
                        __instance.Mana -= __instance.GetManaFromLabel("Door Lock Start", __instance.abilities);
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.Disallow:
                    {
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.NoEnergy:
                    {
                        // might wanna change __instance.Mana to 0,
                        // the client may do another check when being told that the player has not enough mana,
                        // resulting in realizing they do indeed have enough mana
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                        return(false);
                    }
                    }
                    return(false);
                }

                case Command079.Speaker:
                {
                    string     speakerQualifiedName = __instance.CurrentRoom.transform.parent.name + "/" + __instance.CurrentRoom.name + "/Scp079Speaker";
                    GameObject speaker       = GameObject.Find(speakerQualifiedName);
                    float      manaFromLabel = __instance.GetManaFromLabel("Speaker Start", __instance.abilities);

                    Scp079EventMisc.InteractionResult intendedResult;
                    if (speaker == null)
                    {
                        intendedResult = Scp079EventMisc.InteractionResult.Disallow;
                    }
                    else if (manaFromLabel * 1.5f <= __instance.Mana)
                    {
                        intendedResult = Scp079EventMisc.InteractionResult.Allow;
                    }
                    else
                    {
                        intendedResult = Scp079EventMisc.InteractionResult.NoEnergy;
                    }

                    SynapseController.Server.Events.Scp.Scp079.Invoke079SpeakerInteract(
                        __instance.gameObject.GetPlayer(),
                        manaFromLabel,
                        intendedResult,
                        out var actualResult
                        );

                    switch (actualResult)
                    {
                    case Scp079EventMisc.InteractionResult.Allow:
                    {
                        __instance.Mana   -= manaFromLabel;
                        __instance.Speaker = speakerQualifiedName;
                        __instance.AddInteractionToHistory(speaker, true);
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.Disallow:
                    {
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.NoEnergy:
                    {
                        // might wanna change __instance.Mana to 0,
                        // the client may do another check when being told that the player has not enough mana,
                        // resulting in realizing they do indeed have enough mana
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                        return(false);
                    }
                    }

                    return(false);
                }

                case Command079.StopSpeaker:
                    __instance.Speaker = string.Empty;
                    return(false);

                case Command079.ElevatorTeleport:
                {
                    Synapse.Api.Logger.Get.Debug("Teleport");
                    float manaFromLabel = __instance.GetManaFromLabel("Elevator Teleport", __instance.abilities);
                    if (manaFromLabel > __instance.Mana)
                    {
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                        return(false);
                    }
                    Camera079 camera = null;
                    foreach (Scp079Interactable scp079Interactable in __instance.nearbyInteractables)
                    {
                        if (scp079Interactable.type == Scp079Interactable.InteractableType.ElevatorTeleport)
                        {
                            camera = scp079Interactable.optionalObject.GetComponent <Camera079>();
                        }
                    }
                    if (camera != null)
                    {
                        __instance.RpcSwitchCamera(camera.cameraId, false);
                        __instance.Mana -= manaFromLabel;
                        __instance.AddInteractionToHistory(target, true);
                        return(false);
                    }
                    if (ConsoleDebugMode.CheckImportance("SCP079", MessageImportance.LeastImportant, out Color32 color))
                    {
                        Scp079Interactable scp079Interactable2 = null;
                        Dictionary <Scp079Interactable.InteractableType, byte> dictionary = new Dictionary <Scp079Interactable.InteractableType, byte>();
                        foreach (Scp079Interactable scp079Interactable3 in __instance.nearbyInteractables)
                        {
                            if (dictionary.ContainsKey(scp079Interactable3.type))
                            {
                                Dictionary <Scp079Interactable.InteractableType, byte> dictionary2 = dictionary;
                                Scp079Interactable.InteractableType type = scp079Interactable3.type;
                                byte b = dictionary2[type];
                                dictionary2[type] = (byte)(b + 1);
                            }
                            else
                            {
                                dictionary[scp079Interactable3.type] = 1;
                            }
                            if (scp079Interactable3.type == Scp079Interactable.InteractableType.ElevatorTeleport)
                            {
                                scp079Interactable2 = scp079Interactable3;
                            }
                        }
                        string text2;
                        if (scp079Interactable2 == null)
                        {
                            text2 = "None of the " + __instance.nearbyInteractables.Count + " were an ElevatorTeleport, found: ";
                            using (Dictionary <Scp079Interactable.InteractableType, byte> .Enumerator enumerator2 = dictionary.GetEnumerator())
                            {
                                while (enumerator2.MoveNext())
                                {
                                    KeyValuePair <Scp079Interactable.InteractableType, byte> keyValuePair = enumerator2.Current;
                                    text2 = string.Concat(new object[]
                                        {
                                            text2,
                                            keyValuePair.Value,
                                            "x",
                                            keyValuePair.Key.ToString().Substring(keyValuePair.Key.ToString().Length - 4),
                                            " "
                                        });
                                }
                                goto IL_755;
                            }
                        }
                        if (scp079Interactable2.optionalObject == null)
                        {
                            text2 = "Optional object is missing.";
                        }
                        else if (scp079Interactable2.optionalObject.GetComponent <Camera079>() == null)
                        {
                            string    str       = "";
                            Transform transform = scp079Interactable2.optionalObject.transform;
                            for (int i = 0; i < 5; i++)
                            {
                                str = transform.name + str;
                                if (!(transform.parent != null))
                                {
                                    break;
                                }
                                transform = transform.parent;
                            }
                            text2 = "Camera is missing at " + str;
                        }
                        else
                        {
                            text2 = "Unknown error";
                        }
IL_755:
                        GameCore.Console.AddDebugLog("SCP079", "Could not find the second elevator: " + text2, MessageImportance.LeastImportant, false);
                        return(false);
                    }
                    return(false);
                }

                case Command079.ElevatorUse:
                {
                    float  manaFromLabel = __instance.GetManaFromLabel("Elevator Use", __instance.abilities);
                    string elevatorName  = string.Empty;
                    if (array.Length > 0)
                    {
                        elevatorName = array[0];
                    }

                    Elevator synElevator = Map.Get.Elevators.Find(_ => _.Name == elevatorName);
                    Scp079EventMisc.InteractionResult intendedResult;
                    if (manaFromLabel <= __instance.Mana)
                    {
                        intendedResult = Scp079EventMisc.InteractionResult.NoEnergy;
                    }
                    else if (synElevator == null || (AlphaWarheadController.Host.timeToDetonation == 0f || !synElevator.Operative || synElevator.Locked))
                    {
                        intendedResult = Scp079EventMisc.InteractionResult.Disallow;
                    }
                    else
                    {
                        intendedResult = Scp079EventMisc.InteractionResult.Allow;
                    }

                    intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy;

                    SynapseController.Server.Events.Scp.Scp079.Invoke079ElevatorUse(
                        __instance.gameObject.GetPlayer(),
                        manaFromLabel,
                        synElevator,
                        intendedResult,
                        out var actualResult
                        );

                    switch (actualResult)
                    {
                    case Scp079EventMisc.InteractionResult.Allow:
                    {
                        if (synElevator.Use())
                        {
                            __instance.Mana -= manaFromLabel;
                            bool flag3 = false;
                            foreach (Lift.Elevator elevator in synElevator.Lift.elevators)
                            {
                                __instance.AddInteractionToHistory(elevator.door.GetComponentInParent <Scp079Interactable>().gameObject, !flag3);
                                flag3 = true;
                            }
                        }

                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.Disallow:
                    {
                        return(false);
                    }

                    case Scp079EventMisc.InteractionResult.NoEnergy:
                    {
                        // might wanna change __instance.Mana to 0,
                        // the client may do another check when being told that the player has not enough mana,
                        // resulting in realizing they do indeed have enough mana
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                        return(false);
                    }
                    }

                    return(false);
                }

                case Command079.Tesla:
                {
                    float manaFromLabel = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                    if (__instance.CurrentRoom != null)
                    {
                        TeslaGate vanillaTesla = __instance.CurrentRoom.GetComponentInChildren <TeslaGate>();
                        Tesla     synapseTesla = vanillaTesla != null?Server.Get.Map.Teslas.Find(_ => _.Gate == vanillaTesla) : null;

                        var intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy;

                        SynapseController.Server.Events.Scp.Scp079.Invoke079TeslaInteract(
                            __instance.gameObject.GetPlayer(),
                            manaFromLabel,
                            synapseTesla?.Room,
                            synapseTesla,
                            intendedResult,
                            out var actualResult
                            );

                        switch (actualResult)
                        {
                        case Scp079EventMisc.InteractionResult.Allow:
                        {
                            if (vanillaTesla != null)
                            {
                                vanillaTesla.RpcInstantBurst();
                            }
                            __instance.AddInteractionToHistory(vanillaTesla.gameObject, true);
                            __instance.Mana -= manaFromLabel;
                            return(false);
                        }

                        case Scp079EventMisc.InteractionResult.Disallow:
                        {
                            return(false);
                        }

                        case Scp079EventMisc.InteractionResult.NoEnergy:
                        {
                            // might wanna change __instance.Mana to 0,
                            // the client may do another check when being told that the player has not enough mana,
                            // resulting in realizing they do indeed have enough mana
                            __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                            return(false);
                        }
                        }
                        return(false);
                    }
                    throw new Exception("Unable to find Tesla Gate in a null room");
                }

                case Command079.Lockdown:
                {
                    if (AlphaWarheadController.Host.inProgress)
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Lockdown cannot commence, Warhead in progress.", MessageImportance.LessImportant, false);
                        return(false);
                    }
                    float manaFromLabel = __instance.GetManaFromLabel("Room Lockdown", __instance.abilities);
                    GameCore.Console.AddDebugLog("SCP079", "Attempting lockdown...", MessageImportance.LeastImportant, false);

                    if (__instance.CurrentRoom != null)
                    {
                        HashSet <Scp079Interactable> roomInteractablesHashSet = Scp079Interactable.InteractablesByRoomId[__instance.CurrentRoom.UniqueId];
                        HashSet <DoorVariant>        doorHashSet = new HashSet <DoorVariant>();

                        GameCore.Console.AddDebugLog("SCP079", "Loaded all interactables", MessageImportance.LeastImportant, false);
                        GameObject lockdownInteractable = null;
                        foreach (Scp079Interactable interactable in roomInteractablesHashSet)
                        {
                            if (interactable != null)
                            {
                                if (interactable.type != Scp079Interactable.InteractableType.Door)
                                {
                                    if (interactable.type == Scp079Interactable.InteractableType.Lockdown)
                                    {
                                        lockdownInteractable = interactable.gameObject;
                                    }
                                }
                                else if (interactable.TryGetComponent(out DoorVariant doorVariant2) && (object)doorVariant2 is IDamageableDoor damageableDoor && damageableDoor.IsDestroyed)
                                {
                                    GameCore.Console.AddDebugLog("SCP079", "Lockdown can't initiate, one of the doors were destroyed.", MessageImportance.LessImportant, false);
                                    return(false);
                                }
                            }
                        }

                        if (__instance.CurrentLDCooldown > 0f)
                        {
                            GameCore.Console.AddDebugLog("SCP079", "Lockdown still on cooldown.", MessageImportance.LessImportant, false);
                            return(false);
                        }

                        GameCore.Console.AddDebugLog("SCP079", "Looking for doors to lock...", MessageImportance.LeastImportant, false);
                        foreach (Scp079Interactable scp079Interactable5 in roomInteractablesHashSet)
                        {
                            if (!(scp079Interactable5 == null) && scp079Interactable5.TryGetComponent(out DoorVariant doorVariant3))
                            {
                                bool doorLocked = doorVariant3.ActiveLocks == (ushort)DoorLockReason.None;
                                if (!doorLocked)
                                {
                                    DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)doorVariant3.ActiveLocks);
                                    doorLocked = (mode.HasFlagFast(DoorLockMode.CanClose) || mode.HasFlagFast(DoorLockMode.ScpOverride));
                                }
                                if (doorLocked)
                                {
                                    if (doorVariant3.TargetState)
                                    {
                                        doorVariant3.NetworkTargetState = false;
                                    }
                                    doorVariant3.ServerChangeLock(DoorLockReason.Lockdown079, true);
                                    doorVariant3.UnlockLater(__instance.LockdownDuration, DoorLockReason.Lockdown079);
                                    doorHashSet.Add(doorVariant3);
                                }
                            }
                        }

                        var  intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy;
                        bool lightsOut      = true;

                        SynapseController.Server.Events.Scp.Scp079.Invoke079RoomLockdown(
                            __instance.gameObject.GetPlayer(),
                            manaFromLabel,
                            Server.Get.Map.Rooms.Find(_ => _.GameObject == __instance.CurrentRoom),         // FIX
                            ref lightsOut,
                            intendedResult,
                            out var actualResult
                            );

                        switch (actualResult)
                        {
                        case Scp079EventMisc.InteractionResult.Allow:
                        {
                            foreach (FlickerableLightController flickerableLightController in __instance.CurrentRoom.GetComponentsInChildren <FlickerableLightController>())
                            {
                                if (flickerableLightController != null)
                                {
                                    flickerableLightController.ServerFlickerLights(8f);
                                }
                            }
                            __instance.CurrentLDCooldown = __instance.LockdownCooldown + __instance.LockdownDuration;
                            __instance.TargetSetLockdownCooldown(__instance.connectionToClient, __instance.CurrentLDCooldown);
                            GameCore.Console.AddDebugLog("SCP079", "Lockdown initiated.", MessageImportance.LessImportant, false);
                            __instance.AddInteractionToHistory(lockdownInteractable, true);
                            __instance.Mana -= __instance.GetManaFromLabel("Room Lockdown", __instance.abilities);
                            return(false);
                        }

                        case Scp079EventMisc.InteractionResult.Disallow:
                        {
                            return(false);
                        }

                        case Scp079EventMisc.InteractionResult.NoEnergy:
                        {
                            // might wanna change __instance.Mana to 0,
                            // the client may do another check when being told that the player has not enough mana,
                            // resulting in realizing they do indeed have enough mana
                            __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana);
                            GameCore.Console.AddDebugLog("SCP079", "Lockdown cannot commence, not enough mana.", MessageImportance.LessImportant, false);
                            return(false);
                        }
                        }
                    }
                    else
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Room couldn't be specified.", MessageImportance.Normal, false);
                    }
                    return(false);
                }

                default:
                    return(false);
                }
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp079BulkPatch failed!!\n{e}");
                return(false);
            }
        }
示例#12
0
        private static bool Prefix(TeslaGateController __instance)
        {
            try
            {
                if (!Round.IsStarted)
                {
                    return(false);
                }

                if (TeslaGate.TeslasValue.Count == 0)
                {
                    return(true);
                }
                foreach (BaseTeslaGate baseTeslaGate in __instance.TeslaGates)
                {
                    if (!baseTeslaGate.isActiveAndEnabled || baseTeslaGate.InProgress)
                    {
                        continue;
                    }

                    if (baseTeslaGate.NetworkInactiveTime > 0f)
                    {
                        baseTeslaGate.NetworkInactiveTime = Mathf.Max(0f, baseTeslaGate.InactiveTime - Time.fixedDeltaTime);
                        continue;
                    }

                    TeslaGate teslaGate     = TeslaGate.Get(baseTeslaGate);
                    bool      inIdleRange   = false;
                    bool      isTriggerable = false;

                    foreach (Player player in Player.List)
                    {
                        try
                        {
                            if (player is null || !teslaGate.CanBeIdle(player))
                            {
                                continue;
                            }

                            TriggeringTeslaEventArgs ev = new(player, teslaGate);
                            Handlers.Player.OnTriggeringTesla(ev);

                            if (ev.IsTriggerable && !isTriggerable)
                            {
                                isTriggerable = ev.IsTriggerable;
                            }

                            if (ev.IsInIdleRange && !inIdleRange)
                            {
                                inIdleRange = ev.IsInIdleRange;
                            }
                        }
#pragma warning disable CS0168
                        catch (Exception e)
#pragma warning restore CS0168
                        {
#if DEBUG
                            Log.Error($"{nameof(TriggeringTesla)}.Prefix: {e}");
#endif
                        }
                    }

                    if (isTriggerable)
                    {
                        teslaGate.Trigger();
                    }

                    if (inIdleRange != teslaGate.IsIdling)
                    {
                        teslaGate.IsIdling = inIdleRange;
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"Exiled.Events.Patches.Events.Player.TriggeringTesla: {e}\n{e.StackTrace}");
                return(true);
            }
        }
示例#13
0
 public static bool Prefix(TeslaGate __instance, bool hurtRange)
 {
     return(EventPlugin.TriggerTeslaPatchDisable);
 }
示例#14
0
        /// <inheritdoc/>
        protected override void OnExploding(ExplodingGrenadeEventArgs ev)
        {
            ev.IsAllowed = false;
            Room      room = Exiled.API.Features.Map.FindParentRoom(ev.Grenade.gameObject);
            TeslaGate gate = null;

            Log.Debug($"{ev.Grenade.transform.position} - {room.Position} - {Room.List.Count()}", CustomItems.Instance.Config.IsDebugEnabled);

            LockedRooms079.Add(room);

            room.TurnOffLights(Duration);

            if (DisableTeslaGates)
            {
                foreach (TeslaGate teslaGate in TeslaGate.List)
                {
                    if (Exiled.API.Features.Map.FindParentRoom(teslaGate.GameObject) == room)
                    {
                        disabledTeslaGates.Add(teslaGate);
                        gate = teslaGate;
                        break;
                    }
                }
            }

            Log.Debug($"{room.Doors.Count()} - {room.Type}", CustomItems.Instance.Config.IsDebugEnabled);

            foreach (Door door in room.Doors)
            {
                if (door == null ||
                    (!string.IsNullOrEmpty(door.Nametag) && BlacklistedDoorNames.Contains(door.Nametag)) ||
                    (door.DoorLockType > 0 && !OpenLockedDoors) ||
                    (door.RequiredPermissions.RequiredPermissions != KeycardPermissions.None && !OpenKeycardDoors))
                {
                    continue;
                }

                Log.Debug("Opening a door!", CustomItems.Instance.Config.IsDebugEnabled);

                door.IsOpen = true;
                door.ChangeLock(DoorLockType.NoPower);

                if (!lockedDoors.Contains(door))
                {
                    lockedDoors.Add(door);
                }

                Timing.CallDelayed(Duration, () =>
                {
                    door.Unlock();
                    lockedDoors.Remove(door);
                });
            }

            foreach (Player player in Player.List)
            {
                if (player.Role.As <Scp079Role>() is Scp079Role scp079)
                {
                    if (scp079.Camera != null && scp079.Camera.Room == room)
                    {
                        scp079.SetCamera(198);
                    }
                }

                if (player.CurrentRoom != room)
                {
                    continue;
                }

                foreach (Item item in player.Items)
                {
                    switch (item)
                    {
                    case Radio radio:
                        radio.Disable();
                        break;

                    case Flashlight flashlight:
                        flashlight.Active = false;
                        break;

                    case Firearm firearm:
                    {
                        foreach (FirearmAttachment attachment in firearm.Attachments)
                        {
                            if (attachment.Name == AttachmentNameTranslation.Flashlight)
                            {
                                attachment.IsEnabled = false;
                            }
                        }
                        break;
                    }
                    }
                }
            }

            Timing.CallDelayed(Duration, () =>
            {
                try
                {
                    LockedRooms079.Remove(room);
                }
                catch (Exception e)
                {
                    Log.Debug($"REMOVING LOCKED ROOM: {e}");
                }

                if (gate != null)
                {
                    try
                    {
                        disabledTeslaGates.Remove(gate);
                    }
                    catch (Exception e)
                    {
                        Log.Debug($"REMOVING DISABLED TESLA: {e}");
                    }
                }
            });
        }
示例#15
0
 public Player079TeslaGateEvent(Player player, TeslaGate teslaGate, bool allow, float apDrain) : base(player)
 {
     TeslaGate = teslaGate;
     Allow     = allow;
     APDrain   = apDrain;
 }
示例#16
0
        /// <summary>
        /// Prefix of <see cref="Scp079PlayerScript.CallCmdInteract(string, GameObject)"/>.
        /// </summary>
        /// <param name="__instance">The <see cref="Scp079PlayerScript"/> instance.</param>
        /// <param name="command">The command to be executed.</param>
        /// <param name="target">The target game object.</param>
        /// <returns>Returns a value indicating whether the original method has to be executed or not.</returns>
        private static bool Prefix(Scp079PlayerScript __instance, string command, GameObject target)
        {
            try
            {
                if (!__instance._interactRateLimit.CanExecute())
                {
                    return(false);
                }

                if (!__instance.iAm079)
                {
                    return(false);
                }

                Console.AddDebugLog("SCP079", "Command received from a client: " + command, MessageImportance.LessImportant);
                if (!command.Contains(":"))
                {
                    return(false);
                }

                string[] array = command.Split(':');
                __instance.RefreshCurrentRoom();
                if (!__instance.CheckInteractableLegitness(__instance.currentRoom, __instance.currentZone, target, true))
                {
                    return(false);
                }

                List <string> list = ListPool <string> .Shared.Rent();

                ConfigFile.ServerConfig.GetStringCollection("scp079_door_blacklist", list);

                bool result = true;
                switch (array[0])
                {
                case "TESLA":
                {
                    GameObject gameObject3 = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                    if (gameObject3 == null)
                    {
                        result = false;
                        break;
                    }

                    Player    player    = Player.Get(__instance.gameObject);
                    TeslaGate teslaGate = gameObject3.GetComponent <TeslaGate>();
                    float     apDrain   = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                    bool      isAllowed = apDrain <= __instance.curMana;

                    InteractingTeslaEventArgs ev = new InteractingTeslaEventArgs(player, teslaGate, isAllowed);
                    Handlers.Scp079.OnInteractingTesla(ev);

                    if (!ev.IsAllowed)
                    {
                        if (apDrain > __instance.curMana)
                        {
                            __instance.RpcNotEnoughMana(apDrain, __instance.curMana);
                            result = false;
                            break;
                        }
                    }
                    else
                    {
                        teslaGate.RpcInstantBurst();
                        __instance.AddInteractionToHistory(gameObject3, array[0], addMana: true);
                        __instance.Mana -= apDrain;
                        result           = false;
                        break;
                    }

                    result = false;
                    break;
                }

                case "DOOR":
                {
                    if (AlphaWarheadController.Host.inProgress)
                    {
                        result = false;
                        break;
                    }

                    if (target == null)
                    {
                        Console.AddDebugLog("SCP079", "The door command requires a target.", MessageImportance.LessImportant);
                        result = false;
                        break;
                    }

                    if (!target.TryGetComponent <DoorVariant>(out var component))
                    {
                        result = false;
                        break;
                    }

                    if (component.TryGetComponent <DoorNametagExtension>(out var component5) && list != null && list.Count > 0 && list != null && list.Contains(component5.GetName))
                    {
                        GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant);
                        result = false;
                        break;
                    }

                    Player player      = Player.Get(__instance.gameObject);
                    var    permissions = component.RequiredPermissions.RequiredPermissions.ToString();
                    float  apDrain     = __instance.GetManaFromLabel("Door Interaction " + (permissions.Contains(",") ? permissions.Split(',')[0] : permissions), __instance.abilities);
                    bool   isAllowed   = apDrain <= __instance.curMana;

                    InteractingDoorEventArgs ev = new InteractingDoorEventArgs(player, component, isAllowed);
                    Handlers.Scp079.OnInteractingDoor(ev);

                    if (!ev.IsAllowed)
                    {
                        if (apDrain > __instance.curMana)
                        {
                            Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant);
                            __instance.RpcNotEnoughMana(apDrain, __instance.curMana);
                            result = false;
                            break;
                        }
                    }
                    else
                    {
                        bool targetState = component.TargetState;
                        component.ServerInteract(ReferenceHub.GetHub(__instance.gameObject), 0);
                        if (targetState != component.TargetState)
                        {
                            __instance.Mana -= apDrain;
                            __instance.AddInteractionToHistory(target, array[0], addMana: true);
                            Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant);
                            result = false;
                            break;
                        }
                        else
                        {
                            Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant);
                        }
                    }

                    result = false;
                    break;
                }

                case "SPEAKER":
                {
                    GameObject scp079SpeakerObject = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Scp079Speaker");
                    if (scp079SpeakerObject == null)
                    {
                        result = false;
                        break;
                    }

                    Player player = Player.Get(__instance.gameObject);
                    Room   room   = Map.FindParentRoom(__instance.currentCamera.gameObject);

                    float apDrain   = __instance.GetManaFromLabel("Speaker Start", __instance.abilities);
                    bool  isAllowed = apDrain * 1.5f <= __instance.curMana;

                    StartingSpeakerEventArgs ev = new StartingSpeakerEventArgs(player, room, apDrain, isAllowed);
                    Handlers.Scp079.OnStartingSpeaker(ev);

                    if (!ev.IsAllowed)
                    {
                        if (ev.APDrain * 1.5f > __instance.curMana)
                        {
                            __instance.RpcNotEnoughMana(ev.APDrain, __instance.curMana);
                            result = false;
                            break;
                        }
                    }
                    else if (scp079SpeakerObject != null)
                    {
                        __instance.Mana   -= ev.APDrain;
                        __instance.Speaker = __instance.currentZone + "/" + __instance.currentRoom + "/Scp079Speaker";
                        __instance.AddInteractionToHistory(scp079SpeakerObject, array[0], addMana: true);
                        result = false;
                        break;
                    }

                    result = false;
                    break;
                }

                case "STOPSPEAKER":
                {
                    void ResetSpeaker() => __instance.Speaker = string.Empty;

                    // Somehow it can be empty
                    if (string.IsNullOrEmpty(__instance.Speaker))
                    {
                        ResetSpeaker();
                        result = false;
                        break;
                    }

                    string[] array7 = __instance.Speaker.Substring(0, __instance.Speaker.Length - 14).Split('/');

                    StoppingSpeakerEventArgs ev = new StoppingSpeakerEventArgs(
                        Player.Get(__instance.gameObject),
                        Map.FindParentRoom(__instance.currentCamera.gameObject));

                    Handlers.Scp079.OnStoppingSpeaker(ev);

                    if (ev.IsAllowed)
                    {
                        ResetSpeaker();
                        result = false;
                        break;
                    }

                    result = false;
                    break;
                }

                case "ELEVATORTELEPORT":
                    float             manaFromLabel = __instance.GetManaFromLabel("Elevator Teleport", __instance.abilities);
                    global::Camera079 camera        = null;
                    foreach (global::Scp079Interactable scp079Interactable in __instance.nearbyInteractables)
                    {
                        if (scp079Interactable.type == global::Scp079Interactable.InteractableType.ElevatorTeleport)
                        {
                            camera = scp079Interactable.optionalObject.GetComponent <global::Camera079>();
                        }
                    }

                    if (camera != null)
                    {
                        ElevatorTeleportEventArgs ev = new ElevatorTeleportEventArgs(Player.Get(__instance.gameObject), camera, manaFromLabel, manaFromLabel <= __instance.curMana);

                        Handlers.Scp079.OnElevatorTeleport(ev);

                        if (ev.IsAllowed)
                        {
                            __instance.RpcSwitchCamera(ev.Camera.cameraId, false);
                            __instance.Mana -= ev.APCost;
                            __instance.AddInteractionToHistory(target, array[0], true);
                        }
                        else
                        {
                            if (ev.APCost > __instance.curMana)
                            {
                                __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                            }
                        }
                    }

                    result = false;
                    break;

                default:
                    result = true;
                    break;
                }

                ListPool <string> .Shared.Return(list);

                return(result);
            }
            catch (Exception e)
            {
                Log.Error($"{typeof(Interacting).FullName}.{nameof(Prefix)}:\n{e}");

                return(true);
            }
        }
示例#17
0
        /// <summary>
        /// Prefix of <see cref="Scp079PlayerScript.CallCmdInteract(string, GameObject)"/>.
        /// </summary>
        /// <param name="__instance">The <see cref="Scp079PlayerScript"/> instance.</param>
        /// <param name="command">The command to be executed.</param>
        /// <param name="target">The target game object.</param>
        /// <returns>Returns a value indicating whether the original method has to be executed or not.</returns>
        private static bool Prefix(Scp079PlayerScript __instance, string command, GameObject target)
        {
            try
            {
                if (!__instance._interactRateLimit.CanExecute())
                {
                    return(false);
                }

                if (!__instance.iAm079)
                {
                    return(false);
                }

                Console.AddDebugLog("SCP079", "Command received from a client: " + command, MessageImportance.LessImportant);
                if (!command.Contains(":"))
                {
                    return(false);
                }

                string[] array = command.Split(':');
                __instance.RefreshCurrentRoom();
                if (!__instance.CheckInteractableLegitness(__instance.currentRoom, __instance.currentZone, target, true))
                {
                    return(false);
                }

                List <string> list = ListPool <string> .Shared.Rent();

                ConfigFile.ServerConfig.GetStringCollection("scp079_door_blacklist", list);

                bool result = true;
                switch (array[0])
                {
                case "TESLA":
                {
                    GameObject gameObject3 = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                    if (gameObject3 == null)
                    {
                        result = false;
                        break;
                    }

                    Player    player    = Player.Get(__instance.gameObject);
                    TeslaGate teslaGate = gameObject3.GetComponent <TeslaGate>();
                    float     apDrain   = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                    bool      isAllowed = apDrain <= __instance.curMana;

                    InteractingTeslaEventArgs ev = new InteractingTeslaEventArgs(player, teslaGate, isAllowed);
                    Handlers.Scp079.OnInteractingTesla(ev);

                    if (!ev.IsAllowed)
                    {
                        if (apDrain > __instance.curMana)
                        {
                            __instance.RpcNotEnoughMana(apDrain, __instance.curMana);
                            result = false;
                            break;
                        }
                    }
                    else
                    {
                        teslaGate.RpcInstantBurst();
                        __instance.AddInteractionToHistory(gameObject3, array[0], addMana: true);
                        __instance.Mana -= apDrain;
                        result           = true;
                        break;
                    }

                    result = false;
                    break;
                }

                case "DOOR":
                {
                    if (AlphaWarheadController.Host.inProgress)
                    {
                        result = false;
                        break;
                    }

                    if (target == null)
                    {
                        Console.AddDebugLog("SCP079", "The door command requires a target.", MessageImportance.LessImportant);
                        result = false;
                        break;
                    }

                    Door door = target.GetComponent <Door>();
                    if (door == null)
                    {
                        result = false;
                        break;
                    }

                    if (list != null && list.Count > 0 && list != null && list.Contains(door.DoorName))
                    {
                        Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant);
                        result = false;
                        break;
                    }

                    Player player    = Player.Get(__instance.gameObject);
                    float  apDrain   = __instance.GetManaFromLabel("Door Interaction " + (string.IsNullOrEmpty(door.permissionLevel) ? "DEFAULT" : door.permissionLevel), __instance.abilities);
                    bool   isAllowed = apDrain <= __instance.curMana;

                    InteractingDoorEventArgs ev = new InteractingDoorEventArgs(player, door, isAllowed);
                    Handlers.Scp079.OnInteractingDoor(ev);

                    if (!ev.IsAllowed)
                    {
                        if (apDrain > __instance.curMana)
                        {
                            Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant);
                            __instance.RpcNotEnoughMana(apDrain, __instance.curMana);
                            result = false;
                            break;
                        }
                    }
                    else if (door != null && door.ChangeState079())
                    {
                        __instance.Mana -= apDrain;
                        __instance.AddInteractionToHistory(target, array[0], addMana: true);
                        Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant);
                        result = true;
                        break;
                    }
                    else
                    {
                        Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant);
                    }

                    result = false;
                    break;
                }

                case "SPEAKER":
                {
                    GameObject scp079SpeakerObject = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Scp079Speaker");
                    if (scp079SpeakerObject == null)
                    {
                        result = false;
                        break;
                    }

                    Transform roomTransform = scp079SpeakerObject.transform.parent;

                    Player player = Player.Get(__instance.gameObject);
                    Room   room   = new Room(roomTransform.name, roomTransform.transform, roomTransform.position);

                    float apDrain   = __instance.GetManaFromLabel("Speaker Start", __instance.abilities);
                    bool  isAllowed = apDrain * 1.5f <= __instance.curMana;

                    StartingSpeakerEventArgs ev = new StartingSpeakerEventArgs(player, room, apDrain, isAllowed);
                    Handlers.Scp079.OnStartingSpeaker(ev);

                    if (!ev.IsAllowed)
                    {
                        if (ev.APDrain * 1.5f > __instance.curMana)
                        {
                            __instance.RpcNotEnoughMana(ev.APDrain, __instance.curMana);
                            result = false;
                            break;
                        }
                    }
                    else if (scp079SpeakerObject != null)
                    {
                        __instance.Mana   -= ev.APDrain;
                        __instance.Speaker = __instance.currentZone + "/" + __instance.currentRoom + "/Scp079Speaker";
                        __instance.AddInteractionToHistory(scp079SpeakerObject, array[0], addMana: true);
                        result = true;
                        break;
                    }

                    result = false;
                    break;
                }

                case "STOPSPEAKER":
                {
                    string[]   array7     = __instance.Speaker.Substring(0, __instance.Speaker.Length - 14).Split('/');
                    GameObject roomObject = GameObject.Find(array7[0] + "/" + array7[1]);

                    StoppingSpeakerEventArgs ev = new StoppingSpeakerEventArgs(
                        Player.Get(__instance.gameObject),
                        new Room(roomObject.name, roomObject.transform, roomObject.transform.position));
                    Handlers.Scp079.OnStoppingSpeaker(ev);

                    if (ev.IsAllowed)
                    {
                        __instance.Speaker = string.Empty;
                        result             = true;
                        break;
                    }

                    result = false;
                    break;
                }

                default:
                    result = true;
                    break;
                }

                ListPool <string> .Shared.Return(list);

                return(result);
            }
            catch (Exception e)
            {
                Log.Error($"Exiled.Events.Patches.Events.Scp079.Interacting: {e}\n{e.StackTrace}");

                return(true);
            }
        }
示例#18
0
 internal Tesla(TeslaGate gate) => Gate = gate;
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractingTeslaEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="tesla"><inheritdoc cref="Tesla"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public InteractingTeslaEventArgs(Player player, TeslaGate tesla, bool isAllowed = true)
 {
     Player    = player;
     Tesla     = tesla;
     IsAllowed = isAllowed;
 }
示例#20
0
 internal Tesla(TeslaGate gate)
 {
     Gate = gate;
     Room = Server.Get.Map.Rooms.OrderBy(room => Vector3.Distance(room.Position, gate.localPosition)).First();
 }
示例#21
0
 public PlayerTriggerTeslaEvent(Player player, TeslaGate teslaGate, bool triggerable) : base(player)
 {
     this.TeslaGate   = teslaGate;
     this.Triggerable = triggerable;
 }
示例#22
0
        private void OnExplodingGrenade(ExplodingGrenadeEventArgs ev)
        {
            if (!Check(ev.Grenade))
            {
                return;
            }

            ev.IsAllowed = false;

            Room      room = Exiled.API.Features.Map.FindParentRoom(ev.Grenade);
            TeslaGate gate = null;

            Log.Debug($"{ev.Grenade.transform.position} - {room.Position} - {Exiled.API.Features.Map.Rooms.Count}", CustomItems.Instance.Config.IsDebugEnabled);

            LockedRooms079.Add(room);

            room.TurnOffLights(Duration);

            if (DisableTeslaGates)
            {
                foreach (TeslaGate teslaGate in Exiled.API.Features.Map.TeslaGates)
                {
                    if (Exiled.API.Features.Map.FindParentRoom(teslaGate.gameObject) == room)
                    {
                        disabledTeslaGates.Add(teslaGate);
                        gate = teslaGate;
                        break;
                    }
                }
            }

            Log.Debug($"{room.Doors.Count()} - {room.Type}", CustomItems.Instance.Config.IsDebugEnabled);

            foreach (DoorVariant door in room.Doors)
            {
                if (door == null ||
                    (!string.IsNullOrEmpty(door.GetNametag()) && BlacklistedDoorNames.Contains(door.GetNametag())) ||
                    (door.NetworkActiveLocks > 0 && !OpenLockedDoors) ||
                    (door.RequiredPermissions.RequiredPermissions != KeycardPermissions.None && !OpenKeycardDoors))
                {
                    continue;
                }

                Log.Debug("Opening a door!", CustomItems.Instance.Config.IsDebugEnabled);

                door.NetworkTargetState = true;
                door.ServerChangeLock(DoorLockReason.NoPower, true);

                if (lockedDoors.Contains(door))
                {
                    lockedDoors.Add(door);
                }

                Timing.CallDelayed(Duration, () =>
                {
                    door.ServerChangeLock(DoorLockReason.NoPower, false);
                    lockedDoors.Remove(door);
                });
            }

            foreach (Player player in Player.List)
            {
                if (player.Role == RoleType.Scp079)
                {
                    if (player.Camera != null && player.Camera.Room() == room)
                    {
                        player.SetCamera(198);
                    }
                }
                if (player.CurrentRoom != room)
                {
                    continue;
                }

                foreach (Inventory.SyncItemInfo item in player.ReferenceHub.inventory.items)
                {
                    if (item.id == ItemType.Radio)
                    {
                        player.ReferenceHub.inventory.items.ModifyDuration(player.ReferenceHub.GetComponent <Radio>().myRadio, 0f);
                    }
                    else if (player.ReferenceHub.weaponManager.syncFlash)
                    {
                        player.ReferenceHub.weaponManager.syncFlash = false;
                    }
                }
            }

            Timing.CallDelayed(Duration, () =>
            {
                LockedRooms079.Remove(room);
                if (gate != null)
                {
                    disabledTeslaGates.Remove(gate);
                }
            });
        }