private static bool Prefix(PlayerMovementSync __instance, Vector3 pos, bool __result)
        {
            try
            {
                int num = 0;
                switch (__instance._hub.characterClassManager.CurClass)
                {
                case RoleType.Scp93953:
                case RoleType.Scp93989:
                    var scp939Offset = PlayerMovementSync._yAxisOffset939 * __instance.transform.localScale.y;
                    num = Physics.OverlapCapsuleNonAlloc(pos - scp939Offset, pos + scp939Offset, 0.15f, PlayerMovementSync._sphereHits, PlayerMovementSync._r3CollidableSurfaces);
                    break;

                case RoleType.ChaosInsurgency:
                    var ciOffset = PlayerMovementSync._yAxisOffsetCi * __instance.transform.localScale.y;
                    num = Physics.OverlapCapsuleNonAlloc(pos - ciOffset, pos + ciOffset, 0.32f, PlayerMovementSync._sphereHits, PlayerMovementSync._r3CollidableSurfaces);
                    break;

                default:
                    var defOffset = PlayerMovementSync._yAxisOffset * __instance.transform.localScale.y;
                    num = Physics.OverlapCapsuleNonAlloc(pos - defOffset, pos + defOffset, 0.38f, PlayerMovementSync._sphereHits, PlayerMovementSync._r3CollidableSurfaces);
                    break;
                }

                for (int i = 0; i < num; i++)
                {
                    PlayableScps.Scp096 scp;
                    if (
                        (__instance._hub.characterClassManager.CurClass == RoleType.Scp106 &&
                         (PlayerMovementSync._sphereHits[i].gameObject.layer == 27 ||
                          PlayerMovementSync._sphereHits[i].gameObject.layer == 14)) ||
                        (PlayerMovementSync._sphereHits[i].gameObject.layer == 27 &&
                         (scp = __instance._hub.scpsController.CurrentScp as PlayableScps.Scp096) != null &&
                         scp.Enraged))
                    {
                        continue;
                    }

                    if (PlayerMovementSync._sphereHits[i].gameObject.layer == 27)
                    {
                        DoorVariant componentInParent2 = PlayerMovementSync._sphereHits[i].GetComponentInParent <DoorVariant>();
                        if (componentInParent2 != null && componentInParent2.AnticheatPassageApproved(__instance._hub))
                        {
                            continue;
                        }
                    }

                    __result = true;
                }

                __result = false;

                return(false);
            }
            catch (Exception ex)
            {
                Log.Error($"{typeof(AntiCheatTriggerByR3WithCustomScale).FullName}.{nameof(Prefix)}:\n{ex}");
                return(true);
            }
        }
Example #2
0
 public void Initialize(Player player, DoorVariant door, PlayerUnstuck plugin)
 {
     this._player = player;
     this._plugin = plugin;
     this._door   = door;
     Coroutine    = Timing.RunCoroutine(_PlayerStuck());
 }
        private static bool Prefix(Scp096 __instance, DoorVariant door)
        {
            if (door.GetExactState() >= 1f)
            {
                return(false);
            }
            IDamageableDoor damageableDoor;
            PryableDoor     gate;

            if ((damageableDoor = (door as IDamageableDoor)) != null)
            {
                if (!damageableDoor.IsDestroyed && door.GetExactState() < 1f && __instance._lastChargedDamageableDoor != damageableDoor && MainClass.singleton.Cfg.Scp.canScp096destroyDoor)
                {
                    damageableDoor.ServerDamage(250f, DoorDamageType.Scp096);
                    __instance._lastChargedDamageableDoor = damageableDoor;
                    return(false);
                }
            }
            else if ((gate = (door as PryableDoor)) != null && door.GetExactState() == 0f && !door.TargetState)
            {
                __instance.Hub.fpc.NetworkmovementOverride = Vector2.zero;
                __instance._chargeCooldown = 0f;
                __instance.PryGate(gate);
            }
            return(false);
        }
Example #4
0
        public void OnWaitingForPlayers()
        {
            ESCPAE_PRIMARY   = DoorNametagExtension.NamedDoors["ESCAPE_PRIMARY"].TargetDoor;
            ESCPAE_SECONDARY = DoorNametagExtension.NamedDoors["ESCAPE_SECONDARY"].TargetDoor;

            ESCPAE_SECONDARY.NetworkTargetState = true;
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TryingNotToCryEventArgs"/> class.
 /// </summary>
 /// <param name="scp096"><inheritdoc cref="Scp096"/></param>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="door"><inheritdoc cref="Door"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public TryingNotToCryEventArgs(Scp096 scp096, Player player, DoorVariant door, bool isAllowed = true)
 {
     Scp096    = scp096;
     Player    = player;
     Door      = door;
     IsAllowed = isAllowed;
 }
Example #6
0
        /// <summary>
        /// Breaks the specified door, if it is not already broken.
        /// </summary>
        /// <param name="door">The <see cref="DoorVariant"/> to break.</param>
        /// <returns>True if the door was broken, false if it was unable to be broken, or was already broken before.</returns>
        public static bool BreakDoor(this DoorVariant door)
        {
            if (door is IDamageableDoor dmg && !dmg.IsDestroyed)
            {
                dmg.ServerDamage(ushort.MaxValue, DoorDamageType.ServerCommand);
                return(true);
            }

            return(false);
        }
Example #7
0
        internal void OnWaitingForPlayers()
        {
            Scp012BottomDoor = Map.GetDoorByName("012_BOTTOM");

            Log.Debug($"Door rotation: {Scp012BottomDoor.transform.eulerAngles}", Config.Debug);

            itemRotation     = Quaternion.Euler(OffsetRotation(Scp012BottomDoor.transform, -90f, 90f, 0f));
            itemSpawnPos     = OffsetPosition(Scp012BottomDoor.transform, 8.5f, 0.5f, 1.75f);
            baitItemSpawnPos = OffsetPosition(Scp012BottomDoor.transform, 6.5f, 1.8f, 1.75f);

            SpawnScp012Item();
        }
Example #8
0
        private IEnumerator <float> StartSystem()
        {
            while (isRoundStarted)
            {
                yield return(Timing.WaitForSeconds(UnityEngine.Random.Range(480, 660)));

                if (UnityEngine.Random.Range(0, 100) < 50)
                {
                    DoorVariant scp106door  = DoorNametagExtension.NamedDoors["106_PRIMARY"].TargetDoor;
                    DoorVariant scp106door2 = DoorNametagExtension.NamedDoors["106_SECONDARY"].TargetDoor;
                    foreach (DoorVariant door in Map.Doors.Where(x => x.transform.position != scp106door.transform.position && x.transform.position != scp106door2.transform.position))
                    {
                        doors.Add(door);
                    }

                    if (!Warhead.IsInProgress && !Warhead.IsDetonated)
                    {
                        isRestarting = true;
                        Timing.CallDelayed(delay, () => isRestarting = false);
                        Cassie.Message("CRITICAL ERROR . . DOOR SYSTEM MALFUNCTION IN PROGRESS . . DOOR SYSTEM SOFTWARE REPAIR COMMENCING IN 3 . 2 . 1 . . . . . . . DOOR SYSTEM REPAIR COMPLETE", true, true);
                        List <DoorVariant> openDoors = new List <DoorVariant>();
                        foreach (DoorVariant door in Map.Doors)
                        {
                            if (door.IsConsideredOpen())
                            {
                                openDoors.Add(door);
                            }
                        }
                        while (isRestarting)
                        {
                            DoorVariant door = doors[UnityEngine.Random.Range(0, doors.Count)];
                            Timing.RunCoroutine(BreakDoor(door));
                            yield return(Timing.WaitForSeconds(0.05f));
                        }
                        foreach (DoorVariant door in Map.Doors)
                        {
                            door.NetworkTargetState = false;
                            door.ServerChangeLock(DoorLockReason.AdminCommand, true);
                        }
                        yield return(Timing.WaitForSeconds(3f));

                        foreach (DoorVariant door in Map.Doors)
                        {
                            door.NetworkTargetState = openDoors.Contains(door);
                            door.ServerChangeLock(DoorLockReason.AdminCommand, false);
                        }
                        brokenDoors.Clear();
                    }
                }
            }
        }
Example #9
0
        private IEnumerator <float> BreakDoor(DoorVariant door)
        {
            doors.Remove(door);
            brokenDoors.Add(door);
            yield return(Timing.WaitForSeconds(0.7f));

            if (isRestarting)
            {
                door.NetworkTargetState = !door.NetworkTargetState;
                door.ServerChangeLock(DoorLockReason.AdminCommand, door.ActiveLocks > 0 ? false : true);
            }
            doors.Add(door);
            brokenDoors.Remove(door);
        }
Example #10
0
        public void Awake()
        {
            _config = Scp953.Singleton.Config;
            _player = Player.Get(gameObject);
            Exiled.Events.Handlers.Player.Died             += OnDied;
            Exiled.Events.Handlers.Player.Escaping         += OnEscaping;
            Exiled.Events.Handlers.Player.Handcuffing      += OnHandcuffing;
            Exiled.Events.Handlers.Player.Hurting          += OnHurting;
            Exiled.Events.Handlers.Player.Left             += OnLeft;
            Exiled.Events.Handlers.Player.Shooting         += OnShooting;
            Exiled.Events.Handlers.Player.Shot             += OnShot;
            Exiled.Events.Handlers.Player.UsingMedicalItem += OnUsingMedicalItem;

            DoorVariant spawnDoor = null;

            foreach (var door in Map.Doors)
            {
                var extension = door.GetComponent <DoorNametagExtension>();
                if (extension != null && string.Equals(extension.GetName, _config.SpawnDoor,
                                                       StringComparison.CurrentCultureIgnoreCase))
                {
                    spawnDoor = door;
                    break;
                }

                if (!string.Equals(door.name, _config.SpawnDoor,
                                   StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                spawnDoor = door;
                break;
            }

            if (spawnDoor == null)
            {
                Log.Error($"Could not find the specified spawn location for Scp953. ({_config.SpawnDoor})");
                return;
            }

            UnDisguise();
            Timing.CallDelayed(3f, () => _player.Health = _player.MaxHealth = _config.Health);
            _player.Position = spawnDoor.transform.position + new Vector3(1, 2, 1);
            _player.EnableEffect <CustomPlayerEffects.Scp207>();
            _player.ResetInventory(_config.Inventory);
            _player.Broadcast(_config.SpawnMessage);
        }
Example #11
0
 private void Player_Spawning(Exiled.Events.EventArgs.SpawningEventArgs ev)
 {
     if (ev.RoleType == RoleType.Scp0492)
     {
         var controller = ev.Player.GameObject.GetComponent <SCP457Controller>();
         if (controller != null)
         {
             DoorVariant door = null;
             foreach (var door2 in Map.Doors)
             {
                 if (door.TryGetComponent <DoorNametagExtension>(out DoorNametagExtension ex))
                 {
                     if (ex.GetName == Config.scp457_settings.spawn_location)
                     {
                         door = door2;
                     }
                 }
             }
             if (door == null)
             {
                 return;
             }
             if (!global::PlayerMovementSync.FindSafePosition(door.transform.position, out Vector3 down, true))
             {
                 return;
             }
             ev.Position = down;
             Timing.CallDelayed(1.5f, () =>
             {
                 ev.Player.Health    = Config.scp457_settings.health;
                 ev.Player.MaxHealth = (int)Config.scp457_settings.health;
                 ev.Player.Scale     = new Vector3(Config.scp457_settings.size, Config.scp457_settings.size, Config.scp457_settings.size);
             });
         }
     }
     else
     {
         var controller = ev.Player.GameObject.GetComponent <SCP457Controller>();
         if (controller != null)
         {
             controller.Destroy();
             UnityEngine.Object.Destroy(controller);
         }
     }
 }
Example #12
0
 public bool IsDoorDestroyed(DoorVariant door)
 {
     if (door is IDamageableDoor damage)
     {
         if (damage.IsDestroyed)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Example #13
0
        public override void Process(Npc npc, Player player, Dictionary <string, string> args)
        {
            DoorVariant d = null;

            if (DoorNametagExtension.NamedDoors.ContainsKey(args["door"]))
            {
                d = DoorNametagExtension.NamedDoors[args["door"]].TargetDoor;
            }
            if (d != null)
            {
                switch (args["type"])
                {
                case "lock":
                    d.ServerChangeLock(DoorLockReason.AdminCommand, true);
                    break;

                case "ulock":
                    d.ServerChangeLock(DoorLockReason.AdminCommand, false);
                    break;

                case "open":
                    d.NetworkTargetState = true;
                    break;

                case "close":
                    d.NetworkTargetState = false;
                    break;

                case "destroy":
                    d.BreakDoor();
                    break;

                default:
                    Log.Error($"Unknown door ctrl action {args["type"]}!");
                    break;
                }
            }
            else
            {
                Log.Error($"Can't find door {args["door"]}!");
            }
        }
Example #14
0
        public static StuckInRoom SetPlayerStuck(Player player, DoorVariant door, PlayerUnstuck plugin)
        {
            for (int i = 0; i < Config.CacheSize; i++)
            {
                var c = CachedClasses[i];

                if (c.Coroutine.IsRunning)
                {
                    continue;
                }

                c.Initialize(player, door, plugin);
                return(c);
            }

            var createNew = new StuckInRoom();

            createNew.Initialize(player, door, plugin);
            return(createNew);
        }
Example #15
0
        private static List <DoorVariant> FindDoors(GameObject gameObject)
        {
            List <DoorVariant> doorList = new List <DoorVariant>();

            foreach (Scp079Interactable scp079Interactable in Interface079.singleton.allInteractables)
            {
                foreach (Scp079Interactable.ZoneAndRoom zoneAndRoom in scp079Interactable.currentZonesAndRooms)
                {
                    if (zoneAndRoom.currentRoom == gameObject.name && zoneAndRoom.currentZone == gameObject.transform.parent.name)
                    {
                        if (scp079Interactable.type == Scp079Interactable.InteractableType.Door)
                        {
                            DoorVariant door = scp079Interactable.GetComponent <DoorVariant>();
                            if (!doorList.Contains(door))
                            {
                                doorList.Add(door);
                            }
                        }
                    }
                }
            }

            return(doorList);
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Door"/> class.
 /// </summary>
 /// <param name="door"><inheritdoc cref="Base"/></param>
 public Door(DoorVariant door)
 {
     DoorVariantToDoor.Add(door, this);
     Base = door;
     Room = door.GetComponentInParent <Room>();
 }
Example #17
0
        private static bool Prefix(DoorVariant __instance, ReferenceHub ply, byte colliderId)
        {
            try
            {
                InteractingDoorEventArgs ev = new(Player.Get(ply), __instance, false);
                bool bypassDenied           = false;
                bool allowInteracting       = false;

                if (__instance.ActiveLocks != 0)
                {
                    DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)__instance.ActiveLocks);
                    if ((!mode.HasFlagFast(DoorLockMode.CanClose) ||
                         !mode.HasFlagFast(DoorLockMode.CanOpen)) &&
                        (!mode.HasFlagFast(DoorLockMode.ScpOverride) ||
                         ply.characterClassManager.CurRole.team != 0) &&
                        (mode == DoorLockMode.FullLock ||
                         (__instance.TargetState &&
                          !mode.HasFlagFast(DoorLockMode.CanClose)) ||
                         (!__instance.TargetState &&
                          !mode.HasFlagFast(DoorLockMode.CanOpen))))
                    {
                        /*
                         * __instance.LockBypassDenied(ply, colliderId);
                         * return false;
                         */
                        //>EXILED
                        ev.IsAllowed = false;
                        bypassDenied = true;
                        //<EXILED
                    }
                }

                if (!bypassDenied && (allowInteracting = __instance.AllowInteracting(ply, colliderId)))
                {
                    if (ply.characterClassManager.CurClass == RoleType.Scp079 || __instance.RequiredPermissions.CheckPermissions(ply.inventory.CurInstance, ply))
                    {
                        /*
                         * __instance.NetworkTargetState = !__instance.TargetState;
                         * __instance._triggerPlayer = ply;
                         */
                        //>EXILED
                        ev.IsAllowed = true;
                        //<EXILED
                    }
                    else
                    {
                        /*
                         * __instance.PermissionsDenied(ply, colliderId);
                         * DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply);
                         */
                        //>EXILED
                        ev.IsAllowed = false;
                        //<EXILED
                    }
                }

                //>EXILED
                Handlers.Player.OnInteractingDoor(ev);

                if (ev.IsAllowed && allowInteracting)
                {
                    __instance.NetworkTargetState = !__instance.TargetState;
                    __instance._triggerPlayer     = ply;
                }
                else if (bypassDenied)
                {
                    __instance.LockBypassDenied(ply, colliderId);
                }
                // Don't call the RPC if the door is still moving
                else if (allowInteracting)
                {
                    // To avoid breaking their API, call the access denied event
                    // when our event prevents the door from opening
                    __instance.PermissionsDenied(ply, colliderId);
                    DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply);
                }
                //<EXILED

                return(false);
            }
            catch (Exception ex)
            {
                Log.Error($"{typeof(InteractingDoor).FullName}.{nameof(Prefix)}:\n{ex}");
                return(true);
            }
        }
        private static bool Prefix(DoorVariant __instance, ReferenceHub ply, byte colliderId)
        {
            try
            {
                if (!NetworkServer.active)
                {
                    Debug.LogWarning("[Server] function 'System.Void Interactables.Interobjects.DoorUtils.DoorVariant::ServerInteract(ReferenceHub,System.Byte)' called on client");
                    return(false);
                }
                if (__instance.ActiveLocks > 0)
                {
                    DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)__instance.ActiveLocks);
                    if ((!mode.HasFlagFast(DoorLockMode.CanClose) || !mode.HasFlagFast(DoorLockMode.CanOpen)) && (!mode.HasFlagFast(DoorLockMode.ScpOverride) || ply.characterClassManager.CurRole.team != Team.SCP) && (mode == DoorLockMode.FullLock || (__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanClose)) || (!__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanOpen))))
                    {
                        __instance.LockBypassDenied(ply, colliderId);
                        return(false);
                    }
                }
                if (__instance.AllowInteracting(ply, colliderId))
                {
                    var player     = ply.GetPlayer();
                    var flag       = __instance.RequiredPermissions.CheckPermissions(player.VanillaInventory.curItem, ply);
                    var cardaccess = false;
                    var item       = player.ItemInHand;

                    if (item != null && item.ItemCategory == ItemCategory.Keycard)
                    {
                        EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref flag);
                    }

                    if (flag)
                    {
                        cardaccess = true;
                    }
                    else if (Server.Get.Configs.SynapseConfiguration.RemoteKeyCard)
                    {
                        foreach (var item2 in player.Inventory.Items.Where(x => x != item && x.ItemCategory == ItemCategory.Keycard))
                        {
                            var allowcard = __instance.RequiredPermissions.CheckPermissions(item2.ItemType, ply);

                            EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item2, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref allowcard);

                            if (allowcard)
                            {
                                cardaccess = true;
                                break;
                            }
                        }
                    }

                    EventHandler.Get.Map.InvokeDoorInteractEvent(player, __instance.GetDoor(), ref cardaccess);

                    if (ply.characterClassManager.CurClass == RoleType.Scp079 || cardaccess)
                    {
                        __instance.NetworkTargetState = !__instance.TargetState;
                        __instance._triggerPlayer     = ply;
                        return(false);
                    }
                    __instance.PermissionsDenied(ply, colliderId);
                    DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply);
                }

                return(false);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: DoorInteract failed!!\n{e}");
                return(true);
            }
        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggeringDoorEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="InteractingDoorEventArgs.Player"/></param>
 /// <param name="door"><inheritdoc cref="InteractingDoorEventArgs.Door"/></param>
 /// <param name="auxiliaryPowerCost"><inheritdoc cref="AuxiliaryPowerCost"/></param>
 /// <param name="isAllowed"><inheritdoc cref="InteractingDoorEventArgs.IsAllowed"/></param>
 public TriggeringDoorEventArgs(Player player, DoorVariant door, float auxiliaryPowerCost, bool isAllowed = true)
     : base(player, door, isAllowed)
 {
     AuxiliaryPowerCost = auxiliaryPowerCost;
 }
Example #20
0
        public static bool Prefix(FragGrenade __instance, ref bool __result)
        {
            Player thrower = Player.Get(__instance.thrower.gameObject);

            Dictionary <Player, float> damages = new Dictionary <Player, float>();

            Vector3 position = ((EffectGrenade)__instance).transform.position;
            int     num      = 0;

            Collider[] colliderArray = Physics.OverlapSphere(position, __instance.chainTriggerRadius, (int)__instance.damageLayerMask);
            int        index         = 0;

            foreach (GameObject obj2 in PlayerManager.players)
            {
                if (!ServerConsole.FriendlyFire && ((obj2 != ((EffectGrenade)__instance).thrower.gameObject) &&
                                                    (!obj2.GetComponent <WeaponManager>().GetShootPermission(((EffectGrenade)__instance).throwerTeam, false))))
                {
                    continue;
                }
                PlayerStats component = obj2.GetComponent <PlayerStats>();
                if ((component != null) && component.ccm.InWorld)
                {
                    float amount = (float)(__instance.damageOverDistance.Evaluate(Vector3.Distance(position, component.transform.position)) * (component.ccm.IsHuman() ? ConfigFile.ServerConfig.GetFloat("human_grenade_multiplier", 0.7f) : ConfigFile.ServerConfig.GetFloat("scp_grenade_multiplier", 1f)));
                    damages.Add(Player.Get(obj2), amount);
                }
            }

            var ev = new ExplodingGrenadeEventArgs(thrower, damages, true, __instance.gameObject);

            Exiled.Events.Handlers.Map.OnExplodingGrenade(ev);

            if (!ev.IsAllowed)
            {
                return(false);
            }

            while (index < colliderArray.Length)
            {
                Collider        collider  = colliderArray[index];
                BreakableWindow component = collider.GetComponent <BreakableWindow>();
                if (component != null)
                {
                    if ((component.transform.position - position).sqrMagnitude <= __instance.sqrChainTriggerRadius)
                    {
                        component.ServerDamageWindow(500f);
                    }
                }
                else
                {
                    DoorVariant componentInParent = collider.GetComponentInParent <DoorVariant>();
                    if (componentInParent != null && componentInParent is IDamageableDoor damageableDoor)
                    {
                        damageableDoor.ServerDamage(__instance.damageOverDistance.Evaluate(Vector3.Distance(position, componentInParent.transform.position)), DoorDamageType.Grenade);
                    }
                    else if (((__instance.chainLengthLimit == -1) || (__instance.chainLengthLimit > ((EffectGrenade)__instance).currentChainLength)) && ((__instance.chainConcurrencyLimit == -1) || (__instance.chainConcurrencyLimit > num)))
                    {
                        Pickup componentInChildren = collider.GetComponentInChildren <Pickup>();
                        if ((componentInChildren != null) && __instance.ChangeIntoGrenade(componentInChildren))
                        {
                            num = (int)(num + 1);
                        }
                    }
                }
                index = (int)(index + 1);
            }

            foreach (var item in damages)
            {
                if (item.Value > __instance.absoluteDamageFalloff)
                {
                    PlayerStats component     = item.Key.GameObject.GetComponent <PlayerStats>();
                    Transform[] grenadePoints = component.grenadePoints;
                    index = 0;
                    while (true)
                    {
                        if (index < grenadePoints.Length)
                        {
                            Transform transform = grenadePoints[index];
                            if (Physics.Linecast(position, transform.position, (int)__instance.hurtLayerMask))
                            {
                                index = (int)(index + 1);
                                continue;
                            }
                            component.HurtPlayer(new PlayerStats.HitInfo(item.Value, (((EffectGrenade)__instance).thrower != null) ? ((EffectGrenade)__instance).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)"), DamageTypes.Grenade, ((EffectGrenade)__instance).thrower.hub.queryProcessor.PlayerId), item.Key.GameObject, false);
                        }
                        if (!component.ccm.IsAnyScp())
                        {
                            ReferenceHub hub      = item.Key.ReferenceHub;
                            float        duration = __instance.statusDurationOverDistance.Evaluate(Vector3.Distance(position, component.transform.position));
                            hub.playerEffectsController.EnableEffect(hub.playerEffectsController.GetEffect <Burned>(), duration, false);
                            hub.playerEffectsController.EnableEffect(hub.playerEffectsController.GetEffect <Concussed>(), duration, false);
                        }
                        break;
                    }
                }
            }

            //if (Tracking.PlayersWithSubclasses.ContainsKey(thrower) && Tracking.PlayersWithSubclasses[thrower].Abilities.Contains(AbilityType.HealGrenadeFrag))
            //{
            //	if (!Tracking.CanUseAbility(thrower, AbilityType.HealGrenadeFrag, Tracking.PlayersWithSubclasses[thrower]))
            //	{
            //		Tracking.DisplayCantUseAbility(thrower, AbilityType.HealGrenadeFrag, Tracking.PlayersWithSubclasses[thrower], "heal frag");
            //	}
            //	else
            //	{
            //		Tracking.UseAbility(thrower, AbilityType.HealGrenadeFrag, Tracking.PlayersWithSubclasses[thrower]);
            //		UnityEngine.Collider[] colliders = UnityEngine.Physics.OverlapSphere(__instance.transform.position, 4);
            //		Subclass.Instance.map.UpdateHealths(colliders, thrower, "HealGrenadeFragHealAmount");
            //		return false;
            //	}
            //}

            string str = (((Grenade)((EffectGrenade)__instance)).thrower != null) ? ((Grenade)((EffectGrenade)__instance)).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)");

            string[] textArray1 = new string[] { "Player ", (string)str, "'s ", (string)((Grenade)((EffectGrenade)__instance)).logName, " grenade exploded." };
            ServerLogs.AddLog(ServerLogs.Modules.Logger, string.Concat((string[])textArray1), ServerLogs.ServerLogType.GameEvent, false);

            if (((EffectGrenade)__instance).serverGrenadeEffect != null)
            {
                Transform transform = ((Grenade)((EffectGrenade)__instance)).transform;
                Object.Instantiate <GameObject>(((EffectGrenade)__instance).serverGrenadeEffect, transform.position, transform.rotation);
            }

            __result = true;
            return(false);
        }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InteractingDoorEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="door"><inheritdoc cref="Door"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public InteractingDoorEventArgs(Player player, DoorVariant door, bool isAllowed = true)
 {
     Player    = player;
     Door      = Door.Get(door);
     IsAllowed = isAllowed;
 }
        public IEnumerator <float> Replay(string path)
        {
            replayEvents.Clear();
            isReplaying = false;
            int cur = 0;

            using (var stream = new MemoryStream(File.ReadAllBytes(path)))
            {
                Stopwatch watcher = new Stopwatch();
                watcher.Start();
                while (true)
                {
                    if (isReplayPaused || (!isReplaying && isReplayReady))
                    {
                        yield return(Timing.WaitForOneFrame);

                        continue;
                    }
                    IEventType data = null;
                    try
                    {
                        data = MessagePack.MessagePackSerializer.Deserialize <IEventType>(stream);
                    }
                    catch (Exception ex)
                    {
                        Log.Info(ex.ToString());
                        isReplayReady = true;
                        ReferenceHub.HostHub.playerStats.Roundrestart();
                        break;
                    }

                    cur++;
                    if (cur == 100)
                    {
                        Log.Info("100 events in " + watcher.ElapsedMilliseconds + "ms");
                        watcher.Restart();
                        cur = 0;
                    }
                    switch (data)
                    {
                    case SeedData seed:
                        LogData($"Received seed {seed.Seed}");
                        RecorderCore.singleton.SeedID = seed.Seed;
                        break;

                    case UpdatePlayerData uplayer:
                        uplayer.Speed.SetVector();
                        uplayer.Rotation.SetVector();
                        uplayer.Position.SetVector();
                        replayEvents.Add(uplayer);
                        break;

                    case UpdatePickupData upickup:
                        upickup.Position.SetVector();
                        upickup.Rotation.SetQuaternion();
                        replayEvents.Add(upickup);
                        break;

                    case CreatePickupData cpickup:
                        cpickup.Position.SetVector();
                        cpickup.Rotation.SetQuaternion();
                        replayEvents.Add(cpickup);
                        break;

                    case DoorData ddata:
                        ddata.Position.SetVector();
                        replayEvents.Add(ddata);
                        break;

                    default:
                        replayEvents.Add(data);
                        break;
                    }
                }
            }
            foreach (var data in replayEvents)
            {
                switch (data)
                {
                case DelayData delay:
                    yield return(Timing.WaitForSeconds(delay.DelayTime));

                    break;

                case PlayerInfoData pinfo:
                    LogData($"Player joined {pinfo.UserName} ({pinfo.UserID}) ({pinfo.PlayerID})");
                    CreateFakePlayer(pinfo.PlayerID, pinfo.UserName, pinfo.UserID, RoleType.Spectator);
                    break;

                case CreatePickupData cpickup:
                    LogData($"Create pickup {(ItemType)cpickup.ItemType}");
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(ReferenceHub.HostHub.inventory.pickupPrefab);
                    NetworkServer.Spawn(gameObject);
                    gameObject.GetComponent <Pickup>().SetupPickup((ItemType)cpickup.ItemType, -1f, ReferenceHub.HostHub.gameObject, new Pickup.WeaponModifiers(false, -1, -1, -1), cpickup.Position.vector, Quaternion.Euler(new Vector3(0, 0, 0)));
                    var rpickup = gameObject.AddComponent <ReplayPickup>();
                    rpickup.uniqueId = cpickup.ItemID;
                    replayPickups.Add(cpickup.ItemID, rpickup);
                    break;

                case UpdatePlayerData uplayer:
                    LogData($"Update player {uplayer.PlayerID}");
                    if (!replayPlayers.ContainsKey(uplayer.PlayerID))
                    {
                        break;
                    }
                    replayPlayers[uplayer.PlayerID].UpdatePlayer(uplayer);
                    break;

                case UpdatePickupData upickup:
                    LogData($"Update pickup {upickup.ItemID}");
                    if (!replayPickups.ContainsKey(upickup.ItemID))
                    {
                        break;
                    }
                    replayPickups[upickup.ItemID].UpdatePickup(upickup);
                    break;

                case LeaveData lplayer:
                    LogData($"Player leave {lplayer.PlayerID}");
                    if (!replayPlayers.ContainsKey(lplayer.PlayerID))
                    {
                        break;
                    }
                    var rplayer = replayPlayers[lplayer.PlayerID];
                    NetworkServer.Destroy(rplayer.gameObject);
                    break;

                case RemovePickupData rppickup:
                    LogData($"Pickup remove {rppickup.ItemID}");
                    if (!replayPickups.ContainsKey(rppickup.ItemID))
                    {
                        break;
                    }
                    var rrpickup = replayPickups[rppickup.ItemID];
                    NetworkServer.Destroy(rrpickup.gameObject);
                    break;

                case DoorData ddata:
                    LogData($"Open door");
                    var doorpos = ddata.Position.vector;

                    DoorVariant bestDoor     = null;
                    float       bestDistance = 999f;
                    foreach (var dor in Map.Doors)
                    {
                        float distance = Vector3.Distance(dor.transform.position, doorpos);
                        if (distance < bestDistance)
                        {
                            bestDoor     = dor;
                            bestDistance = distance;
                        }
                    }
                    if (bestDoor != null)
                    {
                        bestDoor.TargetState = ddata.State;
                    }
                    break;

                case UpdateRoleData urole:
                    LogData($"Update role {(RoleType)urole.RoleID} for player {urole.PlayerID}");
                    if (!replayPlayers.ContainsKey(urole.PlayerID))
                    {
                        break;
                    }
                    replayPlayers[urole.PlayerID].UpdateRole(urole);
                    break;

                case LiftData ulift:
                    LogData($"Use lift");
                    foreach (var lift2 in Map.Lifts)
                    {
                        if (lift2.elevatorName == ulift.Elevatorname)
                        {
                            lift2.UseLift();
                        }
                    }
                    break;

                case ShotWeaponData sweapon:
                    LogData($"Shot weapon {sweapon.PlayerID}");
                    if (!replayPlayers.ContainsKey(sweapon.PlayerID))
                    {
                        break;
                    }
                    replayPlayers[sweapon.PlayerID].ShotWeapon();
                    break;

                case ReloadWeaponData rweapon:
                    LogData($"Reload weapon {rweapon.PlayerID}");
                    if (!replayPlayers.ContainsKey(rweapon.PlayerID))
                    {
                        break;
                    }
                    replayPlayers[rweapon.PlayerID].ReloadWeapon();
                    break;

                case RoundEndData end:
                    LogData($"Round ended");
                    break;
                }
            }
            replayEvents.Clear();
            Log.Info("Replay ended");
            yield break;
        }
Example #23
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);
            }
        }
Example #24
0
 /// <summary>
 /// Gets the <see cref="DoorType"/>.
 /// </summary>
 /// <param name="door">The Door to check.</param>
 /// <returns>The <see cref="DoorType"/>.</returns>
 public static DoorType Type(this DoorVariant door) => OrderedDoorTypes.TryGetValue(door.GetInstanceID(), out var doorType) ? doorType : DoorType.UnknownDoor;
Example #25
0
 /// <summary>
 /// Indicates when the door can be broken.
 /// </summary>
 /// <param name="door">The <see cref="DoorVariant"/>.</param>
 /// <returns>true if the door can be broken; otherwise, false.</returns>
 public static bool IsBreakable(this DoorVariant door) => door is IDamageableDoor dDoor && !dDoor.IsDestroyed;