コード例 #1
0
        private static bool SwitchCamera(Scp079PlayerScript __instance, ushort camId, bool lookatRotation)
        {
            try
            {
                var    camera   = Server.Get.Map.Cameras.Find(cam => cam.ID == camId);
                Player player   = __instance.GetPlayer();
                bool   spawning = false;
                if (!player.Scp079Controller.Spawned)
                {
                    spawning = true;
                    player.Scp079Controller.Spawned = true;
                }

                SynapseController.Server.Events.Scp.Scp079.Invoke079CameraSwitch(
                    __instance.gameObject.GetPlayer(),
                    camera,
                    lookatRotation,
                    spawning,
                    out var allowed
                    );

                return(allowed);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp079CameraSwitchEvent failed!!\n{e}");
                return(true);
            }
        }
コード例 #2
0
 public static void Postfix(Scp079PlayerScript __instance)
 {
     foreach (Scp079PlayerScript.Ability079 ability in __instance.abilities)
     {
         if (SanyaPlugin.Instance.Config.Scp079ManaCost.TryGetValue(ability.label, out var value))
         {
             ability.mana = value;
         }
     }
 }
コード例 #3
0
ファイル: GainingLevel.cs プロジェクト: iRebbok/EXILED
        private static bool Prefix(Scp079PlayerScript __instance, ref int newLvl)
        {
            var ev = new GainingLevelEventArgs(API.Features.Player.Get(__instance.gameObject), __instance.curLvl, newLvl);

            Scp079.OnGainingLevel(ev);

            newLvl = ev.NewLevel;

            return(ev.IsAllowed);
        }
コード例 #4
0
 public static bool Prefix(Scp079PlayerScript __instance, ref int newLvl)
 {
     try
     {
         bool allow = true;
         Events.InvokeScp079LvlEvent(__instance.GetPlayer(), ref newLvl, ref allow);
         return(allow);
     }
     catch (Exception e)
     {
         Log.Error($"Scp079GainLevelEvent Error: {e}");
         return(true);
     }
 }
コード例 #5
0
ファイル: ReferenceHub.cs プロジェクト: mattymatty97/MattyMod
 private void Copy079(Scp079PlayerScript dst, Scp079PlayerScript src)
 {
     dst.currentCamera       = src.currentCamera;
     dst.currentRoom         = src.currentRoom;
     dst.currentZone         = src.currentZone;
     dst.lockedDoors         = src.lockedDoors;
     dst.maxMana             = src.maxMana;
     dst.nearbyInteractables = src.nearbyInteractables;
     dst.nearestCameras      = src.nearestCameras;
     dst.NetworkcurExp       = src.NetworkcurExp;
     dst.NetworkcurLvl       = src.NetworkcurLvl;
     dst.NetworkcurMana      = src.NetworkcurMana;
     dst.NetworkcurSpeaker   = src.NetworkcurSpeaker;
     dst.NetworkmaxMana      = src.NetworkmaxMana;
 }
コード例 #6
0
ファイル: Scp079Events.cs プロジェクト: js6pak/EXILED
        public static bool Prefix(Scp079PlayerScript __instance, NetworkConnection conn, int newLvl)
        {
            try
            {
                bool allow = true;

                Events.InvokeScp079LvlGain(__instance.gameObject, __instance.curLvl, ref newLvl, ref allow);

                return(allow);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp079LvlGainEvent error: {exception}");
                return(true);
            }
        }
コード例 #7
0
        private static bool Prefix(Scp079PlayerScript __instance, ushort cameraId, bool lookatRotation)
        {
            try
            {
                if (!__instance._interactRateLimit.CanExecute(true))
                {
                    return(false);
                }

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

                Camera079 camera = API.Features.Map.GetCameraById(cameraId);

                if (camera == null)
                {
                    return(false);
                }

                float num                  = __instance.CalculateCameraSwitchCost(camera.transform.position);
                bool  isAllowed            = num <= __instance.curMana;
                ChangingCameraEventArgs ev = new ChangingCameraEventArgs(API.Features.Player.Get(__instance.gameObject), camera, num, isAllowed);
                Scp079.OnChangingCamera(ev);
                if (ev.IsAllowed)
                {
                    __instance.RpcSwitchCamera(ev.Camera.cameraId, lookatRotation);
                    __instance.Mana          = Mathf.Clamp(__instance.Mana - ev.APCost, 0, __instance.maxMana);
                    __instance.currentCamera = ev.Camera;
                }
                else if (ev.APCost > __instance.curMana)
                {
                    __instance.RpcNotEnoughMana(ev.APCost, __instance.curMana);
                }

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"{typeof(ChangingCamera).FullName}.{nameof(Prefix)}:\n{e}");

                return(true);
            }
        }
コード例 #8
0
        public static bool Prefix(Scp079PlayerScript __instance)
        {
            if (!NetworkServer.active || !NetworkServer.active || !__instance.iAm079)
            {
                return(false);
            }

            bool isDraining = false;

            if (!string.IsNullOrEmpty(__instance.Speaker))
            {
                isDraining       = true;
                __instance.Mana -= __instance.GetManaFromLabel("Speaker Update", __instance.abilities) * Time.deltaTime;
                if (__instance.Mana <= 0f)
                {
                    __instance.Speaker = string.Empty;
                }
            }

            if (__instance.lockedDoors.Count > 0)
            {
                isDraining       = true;
                __instance.Mana -= __instance.GetManaFromLabel("Door Lock", __instance.abilities) * Time.deltaTime *
                                   __instance.lockedDoors.Count;
                if (__instance.Mana <= 0f)
                {
                    __instance.lockedDoors.Clear();
                }
            }

            if (!isDraining)
            {
                __instance.Mana =
                    Mathf.Clamp(
                        __instance.curMana + __instance.levels[__instance.curLvl].manaPerSecond * Time.deltaTime *
                        __instance.generatorAuxRegenerationFactor[Generator079.mainGenerator.totalVoltage], 0f,
                        __instance.levels[__instance.curLvl].maxMana);
            }

            return(true);
        }
コード例 #9
0
        private static bool Prefix(Scp079PlayerScript __instance, ExpGainType type, RoleType details)
        {
            var ev = new GainingExperienceEventArgs(API.Features.Player.Get(__instance.gameObject), type, (float)details);

            switch (type)
            {
            case ExpGainType.KillAssist:
            case ExpGainType.PocketAssist:
            {
                Team team = __instance.GetComponent <CharacterClassManager>().Classes.SafeGet(details).team;
                int  num  = 6;

                switch (team)
                {
                case Team.SCP:
                    ev.Amount = __instance.GetManaFromLabel("SCP Kill Assist", __instance.expEarnWays);
                    num       = 11;
                    break;

                case Team.MTF:
                    ev.Amount = __instance.GetManaFromLabel("MTF Kill Assist", __instance.expEarnWays);
                    num       = 9;
                    break;

                case Team.CHI:
                    ev.Amount = __instance.GetManaFromLabel("Chaos Kill Assist", __instance.expEarnWays);
                    num       = 8;
                    break;

                case Team.RSC:
                    ev.Amount = __instance.GetManaFromLabel("Scientist Kill Assist", __instance.expEarnWays);
                    num       = 10;
                    break;

                case Team.CDP:
                    ev.Amount = __instance.GetManaFromLabel("Class-D Kill Assist", __instance.expEarnWays);
                    num       = 7;
                    break;

                default:
                    ev.Amount = 0f;
                    break;
                }

                num--;

                if (type == ExpGainType.PocketAssist)
                {
                    ev.Amount /= 2f;
                }

                break;
            }

            case ExpGainType.DirectKill:
            case ExpGainType.HardwareHack:
                break;

            case ExpGainType.AdminCheat:
                ev.Amount = (float)details;
                break;

            case ExpGainType.GeneralInteractions:
            {
                switch (details)
                {
                case RoleType.ClassD:
                    ev.Amount = __instance.GetManaFromLabel("Door Interaction", __instance.expEarnWays);
                    break;

                case RoleType.Spectator:
                    ev.Amount = __instance.GetManaFromLabel("Tesla Gate Activation", __instance.expEarnWays);
                    break;

                case RoleType.Scientist:
                    ev.Amount = __instance.GetManaFromLabel("Lockdown Activation", __instance.expEarnWays);
                    break;

                case RoleType.Scp079:
                    ev.Amount = __instance.GetManaFromLabel("Elevator Use", __instance.expEarnWays);
                    break;
                }

                if (ev.Amount != 0f)
                {
                    float num4 = 1f / Mathf.Clamp(__instance.levels[__instance.curLvl].manaPerSecond / 1.5f, 1f, 7f);

                    ev.Amount = Mathf.Round(ev.Amount * num4 * 10f) / 10f;
                }

                break;
            }

            default:
                return(false);
            }

            Scp079.OnGainingExperience(ev);

            if (ev.IsAllowed && ev.Amount > 0)
            {
                __instance.AddExperience(ev.Amount);
                return(false);
            }

            return(false);
        }
コード例 #10
0
ファイル: Interacting.cs プロジェクト: gamehunt/EXILED
        /// <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);
            }
        }
コード例 #11
0
 public static bool Prefix(Scp079PlayerScript __instance)
 {
     return(!FacilityControl.ScpRoomLockdown[RoleType.Scp079]);
 }
コード例 #12
0
ファイル: Scp079.cs プロジェクト: PintTheDragon/MoreConfig
 private static void Postfix(Scp079PlayerScript __instance)
 {
     __instance.NetworkcurMana = MoreConfig.singleton.Config.Scp079Config.startingMana;
     __instance.NetworkmaxMana = MoreConfig.singleton.Config.Scp079Config.maxMana;
 }
コード例 #13
0
ファイル: Interacting.cs プロジェクト: helightdev/EXILED
        /// <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>
        public static bool Prefix(Scp079PlayerScript __instance, string command, GameObject target)
        {
            if (!__instance._interactRateLimit.CanExecute(true))
            {
                return(false);
            }

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

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

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

            List <string> list = ConfigFile.ServerConfig.GetStringList("scp079_door_blacklist") ?? new List <string>();
            string        s    = array[0];

            switch (s)
            {
            case "TESLA":
            {
                float manaFromLabel = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                if (manaFromLabel > __instance.curMana)
                {
                    __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                    return(false);
                }

                GameObject gameObject = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                if (gameObject != null)
                {
                    gameObject.GetComponent <global::TeslaGate>().RpcInstantBurst();
                    __instance.AddInteractionToHistory(gameObject, array[0], true);
                    __instance.Mana -= manaFromLabel;
                    return(false);
                }

                return(false);
            }

            case "DOOR":
            {
                if (AlphaWarheadController.Host.inProgress)
                {
                    return(false);
                }

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

                Door component = target.GetComponent <Door>();
                if (component == null)
                {
                    return(false);
                }

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

                float manaFromLabel = __instance.GetManaFromLabel("Door Interaction " + (string.IsNullOrEmpty(component.permissionLevel) ? "DEFAULT" : component.permissionLevel), __instance.abilities);
                if (manaFromLabel > __instance.curMana)
                {
                    Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant, false);
                    __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                    return(false);
                }

                if (component != null && component.ChangeState079())
                {
                    __instance.Mana -= manaFromLabel;
                    __instance.AddInteractionToHistory(target, array[0], true);
                    Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant, false);
                    return(true);
                }

                Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant, false);
                return(false);
            }

            default:
                return(true);
            }
        }
コード例 #14
0
ファイル: Scp079BulkPatch.cs プロジェクト: SynapseSL/Synapse
        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);
            }
        }
コード例 #15
0
        public static bool Prefix(Scp079PlayerScript __instance, string command, GameObject target)
        {
            if (EventPlugin.Scp079TriggerTeslaPatchDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._interactRateLimit.CanExecute() || !__instance.iAm079)
                {
                    return(false);
                }
                Console.AddDebugLog("SCP079", "Command received from a client: " + command,
                                    MessageImportance.LessImportant);
                if (!command.Contains(":"))
                {
                    return(false);
                }
                string[] strArray = command.Split(':');
                __instance.RefreshCurrentRoom();
                if (!__instance.CheckInteractableLegitness(__instance.currentRoom, __instance.currentZone, target,
                                                           true))
                {
                    return(false);
                }

                string s = strArray[0];

                if (s != "TESLA")
                {
                    return(true);
                }
                float manaFromLabel2 = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                if (manaFromLabel2 > (double)__instance.curMana)
                {
                    __instance.RpcNotEnoughMana(manaFromLabel2, __instance.curMana);
                    return(false);
                }

                GameObject go1 = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                if (!(go1 != null))
                {
                    return(false);
                }

                bool allow = true;
                Events.InvokeScp079TriggerTesla(__instance.gameObject, ref allow);
                if (!allow)
                {
                    return(false);
                }

                go1.GetComponent <TeslaGate>().RpcInstantBurst();
                __instance.AddInteractionToHistory(go1, strArray[0], true);
                __instance.Mana -= manaFromLabel2;
                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp079TriggerTeslaEvent error: {exception}");
                return(true);
            }
        }
コード例 #16
0
ファイル: Scp079Events.cs プロジェクト: js6pak/EXILED
        public static bool Prefix(Scp079PlayerScript __instance, ExpGainType type, RoleType details)
        {
            if (EventPlugin.Scp079ExpGainEventDisable)
            {
                return(true);
            }

            try
            {
                bool  allow  = true;
                float amount = 0f;

                switch (type)
                {
                case ExpGainType.KillAssist:
                case ExpGainType.PocketAssist:
                {
                    Team team = __instance.GetComponent <CharacterClassManager>().Classes.SafeGet(details).team;
                    int  num  = 6;

                    switch (team)
                    {
                    case Team.SCP:
                        amount = __instance.GetManaFromLabel("SCP Kill Assist", __instance.expEarnWays);
                        num    = 11;
                        break;

                    case Team.MTF:
                        amount = __instance.GetManaFromLabel("MTF Kill Assist", __instance.expEarnWays);
                        num    = 9;
                        break;

                    case Team.CHI:
                        amount = __instance.GetManaFromLabel("Chaos Kill Assist", __instance.expEarnWays);
                        num    = 8;
                        break;

                    case Team.RSC:
                        amount = __instance.GetManaFromLabel("Scientist Kill Assist", __instance.expEarnWays);
                        num    = 10;
                        break;

                    case Team.CDP:
                        amount = __instance.GetManaFromLabel("Class-D Kill Assist", __instance.expEarnWays);
                        num    = 7;
                        break;

                    default:
                        amount = 0f;
                        break;
                    }

                    num--;

                    if (type == ExpGainType.PocketAssist)
                    {
                        amount /= 2f;
                    }

                    break;
                }

                case ExpGainType.DirectKill:
                case ExpGainType.HardwareHack:
                    break;

                case ExpGainType.AdminCheat:
                    amount = (float)details;
                    break;

                case ExpGainType.GeneralInteractions:
                {
                    switch (details)
                    {
                    case RoleType.ClassD:
                        amount = __instance.GetManaFromLabel("Door Interaction", __instance.expEarnWays);
                        break;

                    case RoleType.Spectator:
                        amount = __instance.GetManaFromLabel("Tesla Gate Activation", __instance.expEarnWays);
                        break;

                    case RoleType.Scientist:
                        amount = __instance.GetManaFromLabel("Lockdown Activation", __instance.expEarnWays);
                        break;

                    case RoleType.Scp079:
                        amount = __instance.GetManaFromLabel("Elevator Use", __instance.expEarnWays);
                        break;
                    }

                    if (amount != 0f)
                    {
                        float num4 = 1f / Mathf.Clamp(__instance.levels[__instance.curLvl].manaPerSecond / 1.5f, 1f, 7f);

                        amount = Mathf.Round(amount * num4 * 10f) / 10f;
                    }

                    break;
                }

                default:
                    return(false);
                }

                Events.InvokeScp079ExpGain(__instance.gameObject, type, ref allow, ref amount);

                if (allow && amount > 0)
                {
                    __instance.AddExperience(amount);
                    return(false);
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp079ExpGainEvent error: {exception}");
                return(true);
            }
        }
コード例 #17
0
ファイル: Patches.cs プロジェクト: BuildBoy12/DisasterMod
        public static void Postfix(Scp079PlayerScript __instance)
        {
            foreach (Scp079PlayerScript.Ability079 ability in __instance.abilities)
            {
                switch (ability.label)
                {
                case "Camera Switch":
                    ability.mana = Configs.scp079_cost_camera;
                    break;

                case "Door Lock":
                    ability.mana = Configs.scp079_cost_lock;
                    break;

                case "Door Lock Start":
                    ability.mana = Configs.scp079_cost_lock_start;
                    break;

                case "Door Lock Minimum":
                    ability.mana = Configs.scp079_cost_lock_minimum;
                    break;

                case "Door Interaction DEFAULT":
                    ability.mana = Configs.scp079_cost_door_default;
                    break;

                case "Door Interaction CONT_LVL_1":
                    ability.mana = Configs.scp079_cost_door_contlv1;
                    break;

                case "Door Interaction CONT_LVL_2":
                    ability.mana = Configs.scp079_cost_door_contlv2;
                    break;

                case "Door Interaction CONT_LVL_3":
                    ability.mana = Configs.scp079_cost_door_contlv3;
                    break;

                case "Door Interaction ARMORY_LVL_1":
                    ability.mana = Configs.scp079_cost_door_armlv1;
                    break;

                case "Door Interaction ARMORY_LVL_2":
                    ability.mana = Configs.scp079_cost_door_armlv2;
                    break;

                case "Door Interaction ARMORY_LVL_3":
                    ability.mana = Configs.scp079_cost_door_armlv3;
                    break;

                case "Door Interaction EXIT_ACC":
                    ability.mana = Configs.scp079_cost_door_exit;
                    break;

                case "Door Interaction INCOM_ACC":
                    ability.mana = Configs.scp079_cost_door_intercom;
                    break;

                case "Door Interaction CHCKPOINT_ACC":
                    ability.mana = Configs.scp079_cost_door_checkpoint;
                    break;

                case "Room Lockdown":
                    ability.mana = Configs.scp079_cost_lockdown;
                    break;

                case "Tesla Gate Burst":
                    ability.mana = Configs.scp079_cost_tesla;
                    break;

                case "Elevator Teleport":
                    ability.mana = Configs.scp079_cost_elevator_teleport;
                    break;

                case "Elevator Use":
                    ability.mana = Configs.scp079_cost_elevator_use;
                    break;

                case "Speaker Start":
                    ability.mana = Configs.scp079_cost_speaker_start;
                    break;

                case "Speaker Update":
                    ability.mana = Configs.scp079_cost_speaker_update;
                    break;
                }
            }
        }
コード例 #18
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);
            }
        }
コード例 #19
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":
                {
                    float manaFromLabel = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                    if (manaFromLabel > __instance.curMana)
                    {
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                        result = false;
                        break;
                    }

                    GameObject gameObject =
                        GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                    if (gameObject != null)
                    {
                        gameObject.GetComponent <TeslaGate>().RpcInstantBurst();
                        __instance.AddInteractionToHistory(gameObject, array[0], true);
                        __instance.Mana -= manaFromLabel;
                    }

                    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 component = target.GetComponent <Door>();
                    if (component == null)
                    {
                        result = false;
                        break;
                    }

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

                    float manaFromLabel = __instance.GetManaFromLabel(
                        "Door Interaction " + (string.IsNullOrEmpty(component.permissionLevel)
                                    ? "DEFAULT"
                                    : component.permissionLevel), __instance.abilities);
                    if (manaFromLabel > __instance.curMana)
                    {
                        Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant);
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                        result = false;
                        break;
                    }

                    if (component != null && component.ChangeState079())
                    {
                        __instance.Mana -= manaFromLabel;
                        __instance.AddInteractionToHistory(target, array[0], true);
                        Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant);
                        result = true;
                        break;
                    }

                    Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant);
                    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);
            }
        }
コード例 #20
0
        private static void SCPMode()
        {
            var ccm = PlayerManager.localPlayer.GetComponent <CharacterClassManager>();
            Scp173PlayerScript   peanut   = ccm.GetComponent <Scp173PlayerScript>();
            Scp049PlayerScript   doctor   = ccm.GetComponent <Scp049PlayerScript>();
            Scp049_2PlayerScript zombie   = ccm.GetComponent <Scp049_2PlayerScript>();
            Scp939PlayerScript   dogo     = ccm.GetComponent <Scp939PlayerScript>();
            Scp096PlayerScript   shyguy   = ccm.GetComponent <Scp096PlayerScript>();
            Scp106PlayerScript   larry    = ccm.GetComponent <Scp106PlayerScript>();
            Scp079PlayerScript   computer = ccm.GetComponent <Scp079PlayerScript>();


            if (peanut.iAm173)
            {
                foreach (GameObject player in PlayerManager.singleton.players)
                {
                    if (Vector3.Distance(PlayerManager.localPlayer.transform.position, player.transform.position) < 4f + peanut.boost_teleportDistance.Evaluate(PlayerManager.localPlayer.GetComponent <PlayerStats>().GetHealthPercent()))
                    {
                        peanut.GetType().GetMethod("HurtPlayer", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(peanut, new object[]
                        {
                            player,
                            "123"
                        });
                    }
                }
            }
            if (doctor.iAm049)
            {
                foreach (GameObject player in PlayerManager.singleton.players)
                {
                    if ((player != PlayerManager.localPlayer) && (Vector3.Distance(PlayerManager.localPlayer.transform.position, player.transform.position) < 3.5f))
                    {
                        doctor.GetType().GetMethod("InfectPlayer", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(doctor, new object[]
                        {
                            player,
                            "123"
                        });
                    }
                }
            }
            if (zombie.iAm049_2)
            {
                foreach (GameObject player in PlayerManager.singleton.players)
                {
                    if ((player != PlayerManager.localPlayer) && (Vector3.Distance(PlayerManager.localPlayer.transform.position, player.transform.position) < 4f))
                    {
                        zombie.CallCmdHurtPlayer(player, "123");
                    }
                }
            }
            if (dogo.iAm939)
            {
                foreach (GameObject player in PlayerManager.singleton.players)
                {
                    // ccm.klasy[player.GetComponent<CharacterClassManager>().curClass].team != Team.SCP
                    if ((player != PlayerManager.localPlayer) && (Vector3.Distance(Camera.main.transform.position, player.transform.position) < 1.3 * dogo.attackDistance))
                    {
                        dogo.CallCmdShoot(player);
                    }
                }
            }
            if (shyguy.iAm096)
            {
                foreach (GameObject player in PlayerManager.singleton.players)
                {
                    if ((Vector3.Distance(Camera.main.transform.position, player.transform.position) < 3.5f))
                    {
                        shyguy.GetType().GetMethod("CallCmdHurtPlayer", BindingFlags.Instance | BindingFlags.Public).Invoke(shyguy, new object[]
                        {
                            player
                        });
                    }
                }
            }
            if (larry.iAm106)
            {
                foreach (GameObject player in PlayerManager.singleton.players)
                {
                    if (Vector3.Distance(Camera.main.transform.position, player.transform.position) < 3.5f)
                    {
                        larry.CallCmdMovePlayer(player, ServerTime.time);
                    }
                }
            }
            if (computer.iAm079)
            {
            }
        }