コード例 #1
0
ファイル: LevelManager.cs プロジェクト: dymara/Bomberman
    private void BeginGame()
    {
        positionConverter = new PositionConverter(cellSize);
        mazeInstance      = Instantiate(mazePrefab);
        float mazeWidth  = indestructibleCubesXNumber * cellSize * 2 + cellSize;
        float mazeLength = indestructibleCubesZNumber * cellSize * 2 + cellSize;
        float startX     = startPositionX.Equals(StartPosition.MIN) ? 1 : mazeWidth - 1;
        float startZ     = startPositionZ.Equals(StartPosition.MIN) ? 1 : mazeLength - 1;

        Debug.Log(DateTime.Now + " Generating maze with size " + indestructibleCubesXNumber + "x" + indestructibleCubesZNumber + "...");
        board = mazeInstance.Generate(mazeWidth, mazeLength, cellSize, cubeHeight, wallHeight, startX, startZ, positionConverter, levelConfig);

        positionManager = new PlayerPositionManager(board, positionConverter);

        player.gameObject.transform.localPosition = new Vector3(startX, 0.5f, startZ);
        SetInitialCameraRotation();

        board.AddPlayer(player);

        InitAI();

        positionManager.AddPlayer(player);

        explosionManager = GameObject.Find(Constants.EXPLOSION_MANAGER_NAME).GetComponent <ExplosionManager>();
        uiController     = GameObject.Find(Constants.UI_CONTROLLER_NAME).GetComponent <UIController>();
        uiController.InitializeHUD(mazeWidth, mazeLength);

        StartCoroutine(StartLevelCountdown());
        Debug.Log(DateTime.Now + " Level " + GameManager.instance.GetCurrentLevelNumber() + " loaded successfully!");
    }
コード例 #2
0
 void Awake()
 {
     if (instance == null) {
         DontDestroyOnLoad (gameObject);
         instance = this;
     } else if (instance != this) {
         Destroy (gameObject);
     }
 }
コード例 #3
0
        internal static void HandleHook(PlayerPositionManager __instance)
        {
            List <PlayerPositionData> normalData = new List <PlayerPositionData>();
            List <GameObject>         players    = ((IEnumerable <GameObject>)PlayerManager.singleton.players).ToList <GameObject>();

            foreach (GameObject _player in players)
            {
                normalData.Add(new PlayerPositionData(_player));
            }
            __instance.ReceiveData(normalData.ToArray());
            foreach (GameObject gameObject in players)
            {
                CharacterClassManager component1 = gameObject.GetComponent <CharacterClassManager>();
                if (component1.curClass >= 0 && (component1.curClass == (int)Role.SCP_939_53 || component1.curClass == (int)Role.SCP_939_89))
                {
                    List <PlayerPositionData> modifiedData2 = new List <PlayerPositionData>((IEnumerable <PlayerPositionData>)normalData);
                    for (int index = 0; index < modifiedData2.Count; ++index)
                    {
                        CharacterClassManager component2 = players[index].GetComponent <CharacterClassManager>();
                        if ((double)modifiedData2[index].position.y < 800.0 && component2.curClass >= 0 && component2.klasy[component2.curClass].team != Team.SCP && (component2.klasy[component2.curClass].team != Team.RIP && !players[index].GetComponent <Scp939_VisionController>().CanSee(component1.GetComponent <Scp939PlayerScript>())))
                        {
                            modifiedData2[index] = new PlayerPositionData()
                            {
                                position = Vector3.up * 6000f,
                                rotation = 0.0f,
                                playerID = modifiedData2[index].playerID
                            };
                        }
                    }
                    __instance.CallTargetTransmit(gameObject.GetComponent <NetworkIdentity>().connectionToClient, modifiedData2.ToArray());
                }
                else
                {
                    __instance.CallTargetTransmit(gameObject.GetComponent <NetworkIdentity>().connectionToClient, normalData.ToArray());
                }

                KeyValuePair <int, List <int> > entry = pHideDict.FirstOrDefault(x => x.Key == gameObject.GetComponent <QueryProcessor>().PlayerId);
                if (PlayerManager.singleton.players.FirstOrDefault(x => x.GetComponent <QueryProcessor>().PlayerId == entry.Key && entry.Key != 0) != null)
                {
                    List <PlayerPositionData> modifiedData = new List <PlayerPositionData>((IEnumerable <PlayerPositionData>)normalData);

                    for (int index = 0; index < modifiedData.Count; ++index)
                    {
                        if (component1.curClass >= 0 && players[index] != gameObject && entry.Value.Contains(players[index].GetComponent <QueryProcessor>().PlayerId))
                        {
                            modifiedData[index] = new PlayerPositionData()
                            {
                                position = Vector3.up * 6000f,
                                rotation = 0.0f,
                                playerID = modifiedData[index].playerID
                            };
                        }
                    }
                    __instance.CallTargetTransmit(gameObject.GetComponent <NetworkIdentity>().connectionToClient, modifiedData.ToArray());
                }
            }
        }
コード例 #4
0
ファイル: JumpEnd.cs プロジェクト: zouuh/FallOfTelladena
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        frame    = 0;
        jumpTime = 0;

        if (controller == null)
        {
            controller = FindObjectOfType <CharacterController>();
        }
        if (bimbopJumpZone == null)
        {
            bimbopJumpZone = FindObjectOfType <BimbopJumpZone>();
        }
        if (playerPositionManager == null)
        {
            playerPositionManager = FindObjectOfType <PlayerPositionManager>().GetComponent <PlayerPositionManager>();
        }
        playerPositionManager.SaveLastPosition();
    }
コード例 #5
0
ファイル: GhostMode.cs プロジェクト: iRebbok/EXILED
        private static bool Prefix(PlayerPositionManager __instance)
        {
            try
            {
                ++__instance._frame;
                if (__instance._frame != __instance._syncFrequency)
                {
                    return(false);
                }
                __instance._frame = 0;
                List <GameObject> players = PlayerManager.players;
                __instance._usedData = players.Count;
                if (__instance._receivedData == null || __instance._receivedData.Length < __instance._usedData)
                {
                    __instance._receivedData = new PlayerPositionData[__instance._usedData * 2];
                }
                for (int index = 0; index < __instance._usedData; ++index)
                {
                    __instance._receivedData[index] = new PlayerPositionData(ReferenceHub.GetHub(players[index]));
                }
                if (__instance._transmitBuffer == null || __instance._transmitBuffer.Length < __instance._usedData)
                {
                    __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2];
                }

                foreach (GameObject gameObject in players)
                {
                    Player player = Player.Get(gameObject);

                    if (player == null)
                    {
                        continue;
                    }

                    Array.Copy(__instance._receivedData, __instance._transmitBuffer, __instance._usedData);
                    if (player.Role.Is939())
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            if (__instance._transmitBuffer[index].position.y < 800.0)
                            {
                                ReferenceHub hub2 = ReferenceHub.GetHub(players[index]);
                                if (player.IsInvisible || (hub2.characterClassManager.CurRole.team != Team.SCP && hub2.characterClassManager.CurRole.team != Team.RIP && !players[index].GetComponent <Scp939_VisionController>().CanSee(player.ReferenceHub.characterClassManager.Scp939)))
                                {
                                    __instance._transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance._transmitBuffer[index].playerID);
                                }
                            }
                        }
                    }
                    else if (player.Role != RoleType.Scp079 && player.Role != RoleType.Spectator)
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            if (Math.Abs(__instance._transmitBuffer[index].position.y - player.Position.y) > 35)
                            {
                                __instance._transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0f, __instance._transmitBuffer[index].playerID);
                            }
                            else
                            {
                                if (ReferenceHub.TryGetHub(__instance._transmitBuffer[index].playerID, out ReferenceHub hub2))
                                {
                                    if (player.IsInvisible || (player.ReferenceHub.scpsController.CurrentScp is Scp096 currentScp && currentScp.Enraged && (!currentScp.HasTarget(hub2) && hub2.characterClassManager.CurRole.team != Team.SCP)))
                                    {
                                        __instance._transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance._transmitBuffer[index].playerID);
                                    }

                                    if (hub2.playerEffectsController.GetEffect <Scp268>().Enabled)
                                    {
                                        bool flag = false;
                                        if (player.ReferenceHub.scpsController.CurrentScp is Scp096 curScp &&
                                            curScp != null)
                                        {
                                            flag = curScp.HasTarget(hub2);
                                        }
                                        if (player.Role != RoleType.Scp079 && player.Role != RoleType.Spectator &&
                                            !flag)
                                        {
                                            __instance._transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance._transmitBuffer[index].playerID);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    for (int i = 0; i < __instance._usedData; i++)
                    {
                        if (player.TargetGhosts.Contains(__instance._transmitBuffer[i].playerID))
                        {
                            __instance._transmitBuffer[i] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance._transmitBuffer[i].playerID);
                        }
                    }

                    NetworkConnection networkConnection = player.ReferenceHub.characterClassManager.netIdentity.isLocalPlayer ? NetworkServer.localConnection : player.ReferenceHub.characterClassManager.netIdentity.connectionToClient;
                    if (__instance._usedData <= 20)
                    {
                        networkConnection.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, (byte)__instance._usedData, 0), 1);
                    }
                    else
                    {
                        byte part;
                        for (part = 0; part < __instance._usedData / 20; ++part)
                        {
                            networkConnection.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, 20, part), 1);
                        }
                        byte count = (byte)(__instance._usedData % (part * 20));
                        if (count > 0)
                        {
                            networkConnection.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, count, part), 1);
                        }
                    }
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"GhostMode error: {exception}");
                return(true);
            }
        }
コード例 #6
0
        private static bool Prefix(PlayerPositionManager __instance)
        {
            try
            {
                if (!NetworkServer.active)
                {
                    return(false);
                }

                __instance._frame++;

                if (__instance._frame != __instance._syncFrequency)
                {
                    return(false);
                }

                __instance._frame = 0;

                var players = Server.Get.Players;
                __instance._usedData = players.Count;

                if (__instance._receivedData == null || __instance._receivedData.Length < __instance._usedData)
                {
                    __instance._receivedData = new PlayerPositionData[__instance._usedData * 2];
                }

                for (var i = 0; i < __instance._usedData; i++)
                {
                    __instance._receivedData[i] = new PlayerPositionData(players[i].Hub);
                }

                if (__instance._transmitBuffer == null || __instance._transmitBuffer.Length < __instance._usedData)
                {
                    __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2];
                }

                foreach (var player in players)
                {
                    Array.Copy(__instance._receivedData, __instance._transmitBuffer, __instance._usedData);
                    if (player.RoleID == (int)RoleType.Scp93953 || player.RoleID == (int)RoleType.Scp93989)
                    {
                        for (var j = 0; j < __instance._usedData; j++)
                        {
                            if (__instance._transmitBuffer[j].position.y < 800f)
                            {
                                var newplayer = players[j];
                                if (newplayer.RealTeam != Team.SCP && newplayer.RealTeam != Team.RIP && !newplayer.GetComponent <Scp939_VisionController>().CanSee(player.ClassManager.Scp939))
                                {
                                    __instance._transmitBuffer[j] = new PlayerPositionData(Vector3.up * 6000f, 0f, __instance._transmitBuffer[j].playerID);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int k = 0; k < __instance._usedData; k++)
                        {
                            var showinvoid = false;
                            var newplayer  = players[k];
                            var vector     = __instance._transmitBuffer[k].position - player.Position;

                            if (player.RoleType == RoleType.Scp173 && player.Scp173Controller.IgnoredPlayers.Contains(newplayer))
                            {
                                showinvoid = true;
                                goto AA_001;
                            }

                            if (newplayer.Invisible && !player.HasPermission("synapse.see.invisible"))
                            {
                                showinvoid = true;
                                goto AA_001;
                            }

                            if (player.RoleType == RoleType.Spectator)
                            {
                                continue;
                            }

                            if (Math.Abs(vector.y) > 35f)
                            {
                                showinvoid = true;
                                goto AA_001;
                            }
                            else
                            {
                                var sqrMagnitude = vector.sqrMagnitude;
                                if (player.Position.y < 800f)
                                {
                                    if (sqrMagnitude >= 1764f)
                                    {
                                        showinvoid = true;
                                        goto AA_001;
                                    }
                                }
                                else if (sqrMagnitude >= 7225f)
                                {
                                    showinvoid = true;
                                    goto AA_001;
                                }

                                if (newplayer != null)
                                {
                                    var scp = player.Hub.scpsController.CurrentScp as Scp096;

                                    if (scp != null && scp.Enraged && !scp.HasTarget(newplayer.Hub) && newplayer.RealTeam != Team.SCP)
                                    {
                                        showinvoid = true;
                                        goto AA_001;
                                    }
                                    if (newplayer.Hub.playerEffectsController.GetEffect <Scp268>().Enabled)
                                    {
                                        var flag = false;
                                        if (scp != null)
                                        {
                                            flag = scp.HasTarget(newplayer.Hub);
                                        }

                                        if (player.RoleType == RoleType.Scp079 || flag)
                                        {
                                            if (Server.Get.Configs.SynapseConfiguration.Better268)
                                            {
                                                showinvoid = true;
                                            }
                                        }
                                        else
                                        {
                                            showinvoid = true;
                                        }
                                    }
                                }
                            }


AA_001:
                            if (showinvoid)
                            {
                                __instance._transmitBuffer[k] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, newplayer.PlayerId);
                            }
                        }
                    }


                    var conn = player.Connection;
                    if (__instance._usedData <= 20)
                    {
                        conn.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, (byte)__instance._usedData, 0), 1);
                    }
                    else
                    {
                        byte b = 0;
                        while ((int)b < __instance._usedData / 20)
                        {
                            conn.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, 20, b), 1);
                            b += 1;
                        }

                        byte b2 = (byte)(__instance._usedData % (int)(b * 20));

                        if (b2 > 0)
                        {
                            conn.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, b2, b), 1);
                        }
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Api.Logger.Get.Error($"Synapse-InvisibleMode: TransmitData failed failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }
コード例 #7
0
ファイル: InvisiblePatch.cs プロジェクト: SynapseSL/Synapse
        private static bool TransmitData(PlayerPositionManager __instance)
        {
            try
            {
                __instance._frame++;

                if (__instance._frame != __instance._syncFrequency)
                {
                    return(false);
                }

                __instance._frame = 0;

                var players = Server.Get.Players;
                players.AddRange(Synapse.Api.Map.Get.Dummies.Select(x => x.Player));
                __instance._usedData = players.Count;

                if (__instance.ReceivedData == null || __instance.ReceivedData.Length < __instance._usedData)
                {
                    __instance.ReceivedData = new PlayerPositionData[__instance._usedData * 2];
                }

                for (var i = 0; i < __instance._usedData; i++)
                {
                    __instance.ReceivedData[i] = new PlayerPositionData(players[i].Hub);
                }

                if (__instance._transmitBuffer == null || __instance._transmitBuffer.Length < __instance._usedData)
                {
                    __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2];
                }

                foreach (var player in players)
                {
                    if (player.Connection == null)
                    {
                        continue;
                    }

                    Array.Copy(__instance.ReceivedData, __instance._transmitBuffer, __instance._usedData);
                    for (int k = 0; k < __instance._usedData; k++)
                    {
                        var showinvoid   = false;
                        var playerToShow = players[k];
                        if (playerToShow == player)
                        {
                            continue;
                        }

                        var vector = __instance._transmitBuffer[k].position - player.Position;

                        if (player.RoleType == RoleType.Spectator)
                        {
                            continue;
                        }

                        if (player.RoleType == RoleType.Scp173)
                        {
                            if (player.Scp173Controller.IgnoredPlayers.Contains(playerToShow))
                            {
                                showinvoid = true;
                                goto AA_001;
                            }
                            else if ((playerToShow.RealTeam == Team.SCP && player.CustomRole != null && !Server.Get.Configs.synapseConfiguration.ScpTrigger173) || Server.Get.Configs.synapseConfiguration.CantLookAt173.Contains(playerToShow.RoleID) || player.Scp173Controller.TurnedPlayers.Contains(playerToShow) || playerToShow.Invisible)
                            {
                                var posinfo = __instance._transmitBuffer[k];
                                var rot     = Quaternion.LookRotation(playerToShow.Position - player.Position).eulerAngles.y;
                                __instance._transmitBuffer[k] = new PlayerPositionData(posinfo.position, rot, posinfo.playerID);
                            }
                        }
                        else if (player.RoleID == (int)RoleType.Scp93953 || player.RoleID == (int)RoleType.Scp93989)
                        {
                            if (__instance._transmitBuffer[k].position.y < 800f && SynapseExtensions.CanHarmScp(playerToShow, false) && playerToShow.RealTeam != Team.RIP && !playerToShow.GetComponent <Scp939_VisionController>().CanSee(player.PlayerEffectsController.GetEffect <CustomPlayerEffects.Visuals939>()))
                            {
                                showinvoid = true;
                                goto AA_001;
                            }
                        }

                        if (playerToShow.Invisible && !player.HasPermission("synapse.see.invisible"))
                        {
                            showinvoid = true;
                            goto AA_001;
                        }

                        if (Math.Abs(vector.y) > 35f)
                        {
                            showinvoid = true;
                            goto AA_001;
                        }
                        else
                        {
                            var sqrMagnitude = vector.sqrMagnitude;
                            if (player.Position.y < 800f)
                            {
                                if (sqrMagnitude >= 1764f)
                                {
                                    showinvoid = true;
                                    goto AA_001;
                                }
                            }
                            else if (sqrMagnitude >= 7225f)
                            {
                                showinvoid = true;
                                goto AA_001;
                            }

                            if (playerToShow != null)
                            {
                                var scp = player.Hub.scpsController.CurrentScp as Scp096;

                                if (scp != null && scp.Enraged && !scp.HasTarget(playerToShow.Hub) && SynapseExtensions.CanHarmScp(playerToShow, false))
                                {
                                    showinvoid = true;
                                    goto AA_001;
                                }
                                if (playerToShow.Hub.playerEffectsController.GetEffect <Invisible>().IsEnabled)
                                {
                                    var flag = false;
                                    if (scp != null)
                                    {
                                        flag = scp.HasTarget(playerToShow.Hub);
                                    }

                                    if (player.RoleType == RoleType.Scp079 || flag)
                                    {
                                        if (Server.Get.Configs.synapseConfiguration.Better268)
                                        {
                                            showinvoid = true;
                                        }
                                    }
                                    else
                                    {
                                        showinvoid = true;
                                    }
                                }
                            }
                        }


AA_001:

                        var posData = __instance._transmitBuffer[k];
                        var rotation = posData.rotation;
                        var pos      = posData.position;

                        Server.Get.Events.Server.InvokeTransmitPlayerDataEvent(player, playerToShow, ref pos, ref rotation, ref showinvoid);

                        if (showinvoid)
                        {
                            __instance._transmitBuffer[k] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, playerToShow.PlayerId);
                        }
                        else
                        {
                            __instance._transmitBuffer[k] = new PlayerPositionData(pos, rotation, playerToShow.PlayerId);
                        }
                    }


                    var conn = player.Connection;
                    if (__instance._usedData <= 20)
                    {
                        conn.Send(new PositionPPMMessage(__instance._transmitBuffer, (byte)__instance._usedData, 0), 1);
                    }
                    else
                    {
                        byte b = 0;
                        while ((int)b < __instance._usedData / 20)
                        {
                            conn.Send(new PositionPPMMessage(__instance._transmitBuffer, 20, b), 1);
                            b += 1;
                        }

                        byte b2 = (byte)(__instance._usedData % (int)(b * 20));

                        if (b2 > 0)
                        {
                            conn.Send(new PositionPPMMessage(__instance._transmitBuffer, b2, b), 1);
                        }
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Api.Logger.Get.Error($"Synapse-InvisibleMode: TransmitData failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }
コード例 #8
0
ファイル: GhostMode.cs プロジェクト: babyboucher/EXILED
        // Keep in mind, changes affecting this code
        // have a high breakage rate, so be careful when
        // updating or adding new things
        private static bool Prefix(PlayerPositionManager __instance)
        {
            try
            {
                if (++__instance._frame != __instance._syncFrequency)
                {
                    return(false);
                }

                __instance._frame = 0;

                List <GameObject> players = PlayerManager.players;
                __instance._usedData = players.Count;

                if (__instance.ReceivedData == null ||
                    __instance.ReceivedData.Length < __instance._usedData)
                {
                    __instance.ReceivedData = new PlayerPositionData[__instance._usedData * 2];
                }

                for (int index = 0; index < __instance._usedData; ++index)
                {
                    __instance.ReceivedData[index] = new PlayerPositionData(ReferenceHub.GetHub(players[index]));
                }

                if (__instance._transmitBuffer == null ||
                    __instance._transmitBuffer.Length < __instance._usedData)
                {
                    __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2];
                }

                foreach (GameObject gameObject in players)
                {
                    Player player = GetPlayerOrServer(gameObject);
                    if (player == null || player.ReferenceHub.queryProcessor._ipAddress == "127.0.0.WAN")
                    {
                        continue;
                    }

                    Array.Copy(__instance.ReceivedData, __instance._transmitBuffer, __instance._usedData);

                    if (player.Role.Is939())
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            if (__instance._transmitBuffer[index].position.y < 800f)
                            {
                                ReferenceHub hub2 = ReferenceHub.GetHub(__instance._transmitBuffer[index].playerID);

                                if (hub2.characterClassManager.CurRole.team != Team.SCP &&
                                    hub2.characterClassManager.CurRole.team != Team.RIP &&
                                    !hub2
                                    .GetComponent <Scp939_VisionController>()
                                    .CanSee(player.ReferenceHub.playerEffectsController.GetEffect <Visuals939>()))
                                {
                                    MakeGhost(index, __instance._transmitBuffer);
                                }
                            }
                        }
                    }
                    else if (player.Role != RoleType.Spectator && player.Role != RoleType.Scp079)
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            PlayerPositionData ppd = __instance._transmitBuffer[index];
                            if (!ReferenceHub.TryGetHub(ppd.playerID, out ReferenceHub targetHub))
                            {
                                continue;
                            }

                            Player currentTarget = GetPlayerOrServer(targetHub.gameObject);
                            if (currentTarget == null)
                            {
                                continue;
                            }

                            Scp096 scp096 = player.ReferenceHub.scpsController.CurrentScp as Scp096;

                            Vector3 vector3 = ppd.position - player.ReferenceHub.playerMovementSync.RealModelPosition;
                            if (Math.Abs(vector3.y) > 35f)
                            {
                                MakeGhost(index, __instance._transmitBuffer);
                            }
                            else
                            {
                                float sqrMagnitude = vector3.sqrMagnitude;
                                if (player.ReferenceHub.playerMovementSync.RealModelPosition.y < 800f)
                                {
                                    if (sqrMagnitude >= 1764f)
                                    {
                                        if (!(sqrMagnitude < 4225f))
                                        {
                                            MakeGhost(index, __instance._transmitBuffer);
                                            continue;
                                        }
                                        if (!(currentTarget.ReferenceHub.scpsController.CurrentScp is Scp096 scp) || !scp.EnragedOrEnraging)
                                        {
                                            MakeGhost(index, __instance._transmitBuffer);
                                            continue;
                                        }
                                    }
                                }
                                else if (sqrMagnitude >= 7225f)
                                {
                                    MakeGhost(index, __instance._transmitBuffer);
                                    continue; // As the target is already ghosted
                                }

                                // The code below doesn't have to follow a ELSE statement!
                                // Otherwise Scp268 won't be processed

                                if (scp096 != null &&
                                    scp096.EnragedOrEnraging &&
                                    !scp096.HasTarget(currentTarget.ReferenceHub) &&
                                    currentTarget.Team != Team.SCP)
                                {
#if DEBUG
                                    Log.Debug($"[Scp096@GhostModePatch] {player.UserId} can't see {currentTarget.UserId}");
#endif
                                    MakeGhost(index, __instance._transmitBuffer);
                                }
                                else if (currentTarget.ReferenceHub.playerEffectsController.GetEffect <Invisible>().IsEnabled)
                                {
                                    bool flag2 = false;
                                    if (scp096 != null)
                                    {
                                        flag2 = scp096.HasTarget(currentTarget.ReferenceHub);
                                    }

                                    if (currentTarget != player && player.Role != RoleType.Scp079 &&
                                        player.Role != RoleType.Spectator &&
                                        !flag2)
                                    {
                                        MakeGhost(index, __instance._transmitBuffer);
                                    }
                                }
                            }
                        }
                    }

                    // We do another FOR for the ghost things
                    // because it's hard to do it without
                    // whole code changes in the game code
                    for (int z = 0; z < __instance._usedData; z++)
                    {
                        PlayerPositionData ppd = __instance._transmitBuffer[z];

                        // Do you remember the bug
                        // when you can't pick up any item?
                        // - Me too;
                        // It was because for a reason
                        // we made the source player
                        // invisible to themself
                        if (player.Id == ppd.playerID)
                        {
                            continue;
                        }

                        // If it's already has the ghost position
                        if (ppd.position == GhostPos)
                        {
                            continue;
                        }

                        if (!ReferenceHub.TryGetHub(ppd.playerID, out ReferenceHub targetHub))
                        {
                            continue;
                        }

                        Player target = GetPlayerOrServer(targetHub.gameObject);
                        if (target == null || target.ReferenceHub.queryProcessor._ipAddress == "127.0.0.WAN")
                        {
                            continue;
                        }

                        // If for some reason the player/their ref hub is null
                        if (target?.ReferenceHub == null)
                        {
                            continue;
                        }

                        if (target.IsInvisible || PlayerCannotSee(player, target.Id))
                        {
                            MakeGhost(z, __instance._transmitBuffer);
                        }
                        // Rotate the player because
                        // those movement checks are
                        // in client-side
                        else if (player.Role == RoleType.Scp173 &&
                                 ((!Exiled.Events.Events.Instance.Config.CanTutorialBlockScp173 &&
                                   target.Role == RoleType.Tutorial) ||
                                  Scp173.TurnedPlayers.Contains(target)))
                        {
                            RotatePlayer(z, __instance._transmitBuffer, FindLookRotation(player.Position, target.Position));
                        }
                    }

                    if (player.ReferenceHub.characterClassManager.netIdentity != null)
                    {
                        NetworkConnection networkConnection =
                            player.ReferenceHub.characterClassManager.netIdentity.isLocalPlayer
                                ? NetworkServer.localConnection
                                : player.ReferenceHub.characterClassManager.netIdentity.connectionToClient;

                        if (__instance._usedData <= 20)
                        {
                            networkConnection.Send <PositionPPMMessage>(
                                new PositionPPMMessage(__instance._transmitBuffer, (byte)__instance._usedData, 0), 1);
                        }
                        else
                        {
                            byte part;
                            for (part = 0; part < __instance._usedData / 20; ++part)
                            {
                                networkConnection.Send <PositionPPMMessage>(new PositionPPMMessage(__instance._transmitBuffer, 20, part), 1);
                            }
                            byte count = (byte)(__instance._usedData % (part * 20));
                            if (count > 0)
                            {
                                networkConnection.Send <PositionPPMMessage>(new PositionPPMMessage(__instance._transmitBuffer, count, part), 1);
                            }
                        }
                    }
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"GhostMode error: {exception}");
                return(true);
            }
        }
コード例 #9
0
        static bool Prefix(PlayerPositionManager __instance)
        {
            List <PlayerPositionData> posData = new List <PlayerPositionData>();
            List <GameObject>         players = PlayerManager.singleton.players.ToList();
            bool smGhostMode = ConfigFile.GetBool("sm_enable_ghostmode", false);

            foreach (GameObject player in players)
            {
                posData.Add(new PlayerPositionData(player));
            }

            __instance.ReceiveData(posData.ToArray());

            foreach (GameObject gameObject in players)
            {
                CharacterClassManager component = gameObject.GetComponent <CharacterClassManager>();
                int pid1 = gameObject.GetComponent <QueryProcessor>().PlayerId;

                if (smGhostMode && gameObject != __instance.gameObject && component.curClass >= 0)
                {
                    for (int i = 0; i < posData.Count; i++)
                    {
                        if (players[i] == gameObject)
                        {
                            continue;
                        }

                        CharacterClassManager component2 = players[i].GetComponent <CharacterClassManager>();
                        int pid2 = players[i].GetComponent <QueryProcessor>().PlayerId;
                        if (component2.smGhostMode && component2.curClass >= 0 && component2.curClass != 2 && (component.curClass != 2 || (!component2.smVisibleToSpec && component.curClass == 2)) && (!component2.smVisibleWhenTalking || (component2.smVisibleWhenTalking && !component2.GetComponent <Radio>().NetworkisTransmitting)))
                        {
                            posData[i] = new PlayerPositionData
                            {
                                position = Vector3.up * 6000f,
                                rotation = 0f,
                                playerID = posData[i].playerID
                            }
                        }
                        ;

                        if (Methods.CheckHidden(pid1, pid2))
                        {
                            ServerConsole.AddLog("Returned true for " + pid1 + " " + pid2);
                            posData[i] = new PlayerPositionData
                            {
                                position = Vector3.up * 6000f, rotation = 0f, playerID = posData[i].playerID
                            };
                        }
                    }
                }

                switch (component.curClass)
                {
                case 16:
                case 17:
                {
                    List <PlayerPositionData> posData939 = new List <PlayerPositionData>(posData);

                    for (int i = 0; i < posData939.Count; i++)
                    {
                        CharacterClassManager component2 = players[i].GetComponent <CharacterClassManager>();
                        if (posData939[i].position.y < 800f && component2.klasy[component2.curClass].team != Team.SCP && component2.klasy[component2.curClass].team != Team.RIP && !players[i].GetComponent <Scp939_VisionController>().CanSee(component.GetComponent <Scp939PlayerScript>()))
                        {
                            posData939[i] = new PlayerPositionData
                            {
                                position = Vector3.up * 6000f,
                                rotation = 0f,
                                playerID = posData939[i].playerID
                            }
                        }
                        ;
                    }
                    __instance.CallTargetTransmit(gameObject.GetComponent <NetworkIdentity>().connectionToClient, posData939.ToArray());
                    break;
                }

                default:
                    __instance.CallTargetTransmit(gameObject.GetComponent <NetworkIdentity>().connectionToClient, posData.ToArray());
                    break;
                }
            }

            return(false);
        }
コード例 #10
0
        public static bool Prefix(PlayerPositionManager __instance)
        {
            try
            {
                List <GameObject> players = PlayerManager.players;
                __instance.usedData = players.Count;
                if (__instance.receivedData == null || __instance.receivedData.Length < __instance.usedData)
                {
                    __instance.receivedData = new PlayerPositionData[__instance.usedData * 2];
                }
                for (int index = 0; index < __instance.usedData; ++index)
                {
                    __instance.receivedData[index] = new PlayerPositionData(players[index]);
                }
                if (__instance.transmitBuffer == null || __instance.transmitBuffer.Length < __instance.usedData)
                {
                    __instance.transmitBuffer = new PlayerPositionData[__instance.usedData * 2];
                }
                foreach (GameObject gameObject in players)
                {
                    CharacterClassManager component1 = gameObject.GetComponent <CharacterClassManager>();
                    Array.Copy(__instance.receivedData, __instance.transmitBuffer, __instance.usedData);

                    if (component1.CurClass == RoleType.Scp096 || component1.CurClass == RoleType.Scp173)
                    {
                        for (int i = 0; i < __instance.usedData; i++)
                        {
                            ReferenceHub hub = Plugin.GetPlayer(__instance.transmitBuffer[i].playerID.ToString());
                            if (hub.characterClassManager.CurClass != RoleType.Tutorial)
                            {
                                continue;
                            }
                            Scp049PlayerScript script   = hub.GetComponent <Scp049PlayerScript>();
                            Vector3            fwd      = script.plyCam.transform.forward;
                            Vector3            pos      = script.gameObject.transform.position;
                            Vector3            position = component1.gameObject.transform.position;
                            float angle = Vector3.Angle(fwd,
                                                        (pos - position).normalized);
                            Vector3    dir = (pos - position).normalized;
                            Quaternion rot = Quaternion.LookRotation(dir);
                            if (angle <= 80f)
                            {
                                __instance.transmitBuffer[i] = new PlayerPositionData(__instance.transmitBuffer[i].position, Quaternion.Inverse(rot).y, __instance.transmitBuffer[i].playerID, __instance.transmitBuffer[i].uses268);
                            }
                        }
                    }

                    if (component1.CurClass.Is939())
                    {
                        for (int index = 0; index < __instance.usedData; ++index)
                        {
                            if (__instance.transmitBuffer[index].position.y < 800.0)
                            {
                                CharacterClassManager component2 = players[index].GetComponent <CharacterClassManager>();
                                if (component2.Classes.SafeGet(component2.CurClass).team != Team.SCP &&
                                    component2.Classes.SafeGet(component2.CurClass).team != Team.RIP && !players[index]
                                    .GetComponent <Scp939_VisionController>()
                                    .CanSee(component1.GetComponent <Scp939PlayerScript>()))
                                {
                                    __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f,
                                                                                              __instance.transmitBuffer[index].playerID);
                                }
                            }
                        }
                    }
                    else if (component1.CurClass == RoleType.Scp096)
                    {
                        Scp096PlayerScript script = component1.GetComponent <Scp096PlayerScript>();
                        if (script.Networkenraged == Scp096PlayerScript.RageState.Enraged || script.Networkenraged == Scp096PlayerScript.RageState.Panic)
                        {
                            for (int i = 0; i < __instance.usedData; i++)
                            {
                                if (!Plugin.Scp096Targets.Contains(__instance.transmitBuffer[i].playerID))
                                {
                                    __instance.transmitBuffer[i] = new PlayerPositionData(Vector3.up * 6000f, 0f, __instance.transmitBuffer[i].playerID);
                                }
                            }
                        }
                    }
                    else if (component1.CurClass != RoleType.Scp079 && component1.CurClass != RoleType.Spectator)
                    {
                        for (int index = 0; index < __instance.usedData; ++index)
                        {
                            if (__instance.transmitBuffer[index].uses268 || EXILED.EventPlugin.GhostedIds.Contains(__instance.transmitBuffer[index].playerID))
                            {
                                __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f,
                                                                                          __instance.transmitBuffer[index].playerID);
                            }
                        }
                    }

                    NetworkConnection networkConnection = component1.netIdentity.isLocalPlayer
                                                ? NetworkServer.localConnection
                                                : component1.netIdentity.connectionToClient;
                    if (__instance.usedData <= 20)
                    {
                        networkConnection.Send(
                            new PlayerPositionManager.PositionMessage(__instance.transmitBuffer,
                                                                      (byte)__instance.usedData, 0), 1);
                    }
                    else
                    {
                        byte part;
                        for (part = (byte)0; (int)part < __instance.usedData / 20; ++part)
                        {
                            networkConnection.Send(
                                new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, 20, part),
                                1);
                        }
                        byte count = (byte)(__instance.usedData % (part * 20));
                        if (count > 0)
                        {
                            networkConnection.Send(
                                new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, count, part), 1);
                        }
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Plugin.Info($"TransmitData Error. {e}");
                return(true);
            }
        }
コード例 #11
0
 private static bool Prefix(PlayerPositionManager __instance)
 {
     Ghostmode.HandleHook(__instance);
     return(false);
 }
コード例 #12
0
ファイル: GhostmodePatch.cs プロジェクト: Lufou/EXILED
        public static bool Prefix(PlayerPositionManager __instance)
        {
            if (EventPlugin.GhostmodePatchDisable)
            {
                return(true);
            }

            try
            {
                List <GameObject> players = PlayerManager.players;
                __instance.usedData = players.Count;
                if (__instance.receivedData == null || __instance.receivedData.Length < __instance.usedData)
                {
                    __instance.receivedData = new PlayerPositionData[__instance.usedData * 2];
                }
                for (int index = 0; index < __instance.usedData; ++index)
                {
                    __instance.receivedData[index] = new PlayerPositionData(players[index]);
                }
                if (__instance.transmitBuffer == null || __instance.transmitBuffer.Length < __instance.usedData)
                {
                    __instance.transmitBuffer = new PlayerPositionData[__instance.usedData * 2];
                }

                foreach (GameObject gameObject in players)
                {
                    CharacterClassManager component1 = gameObject.GetComponent <CharacterClassManager>();
                    Array.Copy(__instance.receivedData, __instance.transmitBuffer, __instance.usedData);

                    if (component1.CurClass == RoleType.Scp096 || component1.CurClass == RoleType.Scp173)
                    {
                        for (int i = 0; i < __instance.usedData; i++)
                        {
                            ReferenceHub hub = Player.GetPlayer(__instance.transmitBuffer[i].playerID);
                            if (hub.characterClassManager.CurClass != RoleType.Tutorial)
                            {
                                continue;
                            }
                            Scp049PlayerScript script   = hub.GetComponent <Scp049PlayerScript>();
                            Vector3            fwd      = script.plyCam.transform.forward;
                            Vector3            pos      = script.gameObject.transform.position;
                            Vector3            position = component1.gameObject.transform.position;
                            float      angle            = Vector3.Angle(fwd, (pos - position).normalized);
                            Vector3    dir = (pos - position).normalized;
                            Quaternion rot = Quaternion.LookRotation(dir);

                            if (angle >= 100f)
                            {
                                float newAngle = Vector3.Angle(new Vector3(fwd.x, fwd.y + 180f, fwd.z),
                                                               (pos - position).normalized);
                                if (component1.CurClass == RoleType.Scp096 && EventPlugin.Scp096Fix || component1.CurClass == RoleType.Scp173 && EventPlugin.Scp173Fix)
                                {
                                    __instance.transmitBuffer[i] = new PlayerPositionData(__instance.transmitBuffer[i].position, newAngle, __instance.transmitBuffer[i].playerID);
                                }
                            }
                        }
                    }

                    if (component1.CurClass.Is939())
                    {
                        for (int index = 0; index < __instance.usedData; ++index)
                        {
                            if (__instance.transmitBuffer[index].position.y < 800.0)
                            {
                                CharacterClassManager component2 = players[index].GetComponent <CharacterClassManager>();
                                if (component2.Classes.SafeGet(component2.CurClass).team != Team.SCP &&
                                    component2.Classes.SafeGet(component2.CurClass).team != Team.RIP && !players[index]
                                    .GetComponent <Scp939_VisionController>()
                                    .CanSee(component1.GetComponent <Scp939PlayerScript>()))
                                {
                                    __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f,
                                                                                              __instance.transmitBuffer[index].playerID);
                                }
                            }
                        }
                    }
                    else if (component1.CurClass != RoleType.Scp079 && component1.CurClass != RoleType.Spectator)
                    {
                        for (int index = 0; index < __instance.usedData; ++index)
                        {
                            if (__instance.transmitBuffer[index].uses268 || EventPlugin.GhostedIds.Contains(__instance.transmitBuffer[index].playerID))
                            {
                                __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f,
                                                                                          __instance.transmitBuffer[index].playerID);
                            }
                        }
                    }

                    if (EventPlugin.TargetGhost.ContainsKey(gameObject.GetPlayer()))
                    {
                        for (int i = 0; i < __instance.usedData; i++)
                        {
                            if (EventPlugin.TargetGhost[gameObject.GetPlayer()]
                                .Contains(__instance.transmitBuffer[i].playerID))
                            {
                                __instance.transmitBuffer[i] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance.transmitBuffer[i].playerID);
                            }
                        }
                    }

                    NetworkConnection networkConnection = component1.netIdentity.isLocalPlayer
                                                ? NetworkServer.localConnection
                                                : component1.netIdentity.connectionToClient;
                    if (__instance.usedData <= 20)
                    {
                        networkConnection.Send(
                            new PlayerPositionManager.PositionMessage(__instance.transmitBuffer,
                                                                      (byte)__instance.usedData, 0), 1);
                    }
                    else
                    {
                        byte part;
                        for (part = 0; part < __instance.usedData / 20; ++part)
                        {
                            networkConnection.Send(
                                new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, 20, part),
                                1);
                        }
                        byte count = (byte)(__instance.usedData % (part * 20));
                        if (count > 0)
                        {
                            networkConnection.Send(
                                new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, count, part), 1);
                        }
                    }
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"GhostmodePatch error: {exception}");
                return(true);
            }
        }
コード例 #13
0
ファイル: GhostMode.cs プロジェクト: gamehunt/EXILED
        private static bool Prefix(PlayerPositionManager __instance)
        {
            try
            {
                ++__instance._frame;
                if (__instance._frame != __instance._syncFrequency)
                {
                    return(false);
                }
                __instance._frame = 0;
                List <GameObject> players = PlayerManager.players;
                __instance._usedData = players.Count;
                if (__instance._receivedData == null || __instance._receivedData.Length < __instance._usedData)
                {
                    __instance._receivedData = new PlayerPositionData[__instance._usedData * 2];
                }
                for (int index = 0; index < __instance._usedData; ++index)
                {
                    __instance._receivedData[index] = new PlayerPositionData(ReferenceHub.GetHub(players[index]));
                }
                if (__instance._transmitBuffer == null || __instance._transmitBuffer.Length < __instance._usedData)
                {
                    __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2];
                }

                foreach (GameObject gameObject in players)
                {
                    Player player = Player.Get(gameObject);
                    Array.Copy(__instance._receivedData, __instance._transmitBuffer, __instance._usedData);

                    if (player.Role.Is939())
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            if (__instance._transmitBuffer[index].position.y < 800.0)
                            {
                                ReferenceHub hub2 = ReferenceHub.GetHub(players[index]);
                                if (hub2.characterClassManager.CurRole.team != Team.SCP &&
                                    hub2.characterClassManager.CurRole.team != Team.RIP && !players[index]
                                    .GetComponent <Scp939_VisionController>()
                                    .CanSee(player.ReferenceHub.characterClassManager.Scp939))
                                {
                                    __instance._transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance._transmitBuffer[index].playerID);
                                }
                            }
                        }
                    }
                    else if (player.Role != RoleType.Spectator && player.Role != RoleType.Scp079)
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            PlayerPositionData ppd           = __instance._transmitBuffer[index];
                            Player             currentTarget = Player.Get(players[index]);
                            Scp096             scp096        = player.ReferenceHub.scpsController.CurrentScp as Scp096;
                            bool canSee       = true;
                            bool shouldRotate = false;

                            if (currentTarget?.ReferenceHub == null)
                            {
                                continue;
                            }

                            if (currentTarget.IsInvisible || player.TargetGhosts.Contains(ppd.playerID))
                            {
                                canSee = false;
                            }

                            Vector3 vector3 = __instance._transmitBuffer[index].position - player.ReferenceHub.playerMovementSync.RealModelPosition;
                            if (Math.Abs(vector3.y) > 35.0)
                            {
                                canSee = false;
                            }
                            else
                            {
                                float sqrMagnitude = vector3.sqrMagnitude;
                                if (player.ReferenceHub.playerMovementSync.RealModelPosition.y < 800.0)
                                {
                                    if (sqrMagnitude >= 1764.0)
                                    {
                                        canSee = false;
                                        continue;
                                    }
                                }
                                else if (sqrMagnitude >= 7225.0)
                                {
                                    canSee = false;
                                    continue;
                                }

                                if (ReferenceHub.TryGetHub(__instance._transmitBuffer[index].playerID, out ReferenceHub hub2))
                                {
                                    if (player.ReferenceHub.scpsController.CurrentScp is Scp096 currentScp && currentScp.Enraged && (!currentScp.HasTarget(hub2) && hub2.characterClassManager.CurRole.team != Team.SCP))
                                    {
                                        canSee = false;
                                    }
                                    else if (hub2.playerEffectsController.GetEffect <Scp268>().Enabled)
                                    {
                                        bool flag = false;
                                        if (scp096 != null)
                                        {
                                            flag = scp096._targets.Contains(hub2);
                                        }

                                        canSee = flag;
                                    }
                                }

                                switch (player.Role)
                                {
                                case RoleType.Scp173 when !Exiled.Events.Events.Instance.Config.CanTutorialBlockScp173 && currentTarget.Role == RoleType.Tutorial:
                                    shouldRotate = true;
                                    break;

                                case RoleType.Scp096 when !Exiled.Events.Events.Instance.Config.CanTutorialTriggerScp096 && currentTarget.Role == RoleType.Tutorial:
                                    shouldRotate = true;
                                    break;
                                }

                                if (!canSee)
                                {
                                    ppd = new PlayerPositionData(Vector3.up * 6000f, 0.0f, ppd.playerID);
                                }
                                else if (shouldRotate)
                                {
                                    ppd = new PlayerPositionData(ppd.position, Quaternion.LookRotation(FindLookRotation(player.Position, currentTarget.Position)).eulerAngles.y, ppd.playerID);
                                }

                                __instance._transmitBuffer[index] = ppd;
                            }
                        }
                    }

                    NetworkConnection networkConnection = player.ReferenceHub.characterClassManager.netIdentity.isLocalPlayer
                        ? NetworkServer.localConnection
                        : player.ReferenceHub.characterClassManager.netIdentity.connectionToClient;
                    if (__instance._usedData <= 20)
                    {
                        networkConnection.Send(
                            new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, (byte)__instance._usedData, 0), 1);
                    }
                    else
                    {
                        byte part;
                        for (part = 0; part < __instance._usedData / 20; ++part)
                        {
                            networkConnection.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, 20, part), 1);
                        }
                        byte count = (byte)(__instance._usedData % (part * 20));
                        if (count > 0)
                        {
                            networkConnection.Send(new PlayerPositionManager.PositionMessage(__instance._transmitBuffer, count, part), 1);
                        }
                    }
                }

                return(false);
            }
コード例 #14
0
        // Keep in mind, changes affecting this code
        // have a high breakage rate, so be careful when
        // updating or adding new things
        private static bool Prefix(PlayerPositionManager __instance)
        {
            try
            {
                if (!Round.IsStarted)
                {
                    return(true);
                }

                if (++__instance._frame != __instance._syncFrequency)
                {
                    return(false);
                }

                __instance._frame = 0;

                List <GameObject> players = PlayerManager.players;
                __instance._usedData = players.Count;

                if (__instance.ReceivedData is null ||
                    __instance.ReceivedData.Length < __instance._usedData)
                {
                    __instance.ReceivedData = new PlayerPositionData[__instance._usedData * 2];
                }

                for (int index = 0; index < __instance._usedData; ++index)
                {
                    __instance.ReceivedData[index] = new PlayerPositionData(ReferenceHub.GetHub(players[index]));
                }

                if (__instance._transmitBuffer is null ||
                    __instance._transmitBuffer.Length < __instance._usedData)
                {
                    __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2];
                }

                foreach (GameObject gameObject in players)
                {
                    Player player = GetPlayerOrServer(gameObject);
                    if (player is null || player.ReferenceHub.queryProcessor._ipAddress == "127.0.0.WAN")
                    {
                        continue;
                    }

                    Array.Copy(__instance.ReceivedData, __instance._transmitBuffer, __instance._usedData);

                    if (player.Role.Type.Is939())
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            if (__instance._transmitBuffer[index].position.y < 800f)
                            {
                                ReferenceHub hub2 = ReferenceHub.GetHub(__instance._transmitBuffer[index].playerID);

                                if (hub2.characterClassManager.CurRole.team != Team.SCP &&
                                    hub2.characterClassManager.CurRole.team != Team.RIP &&
                                    !hub2
                                    .GetComponent <Scp939_VisionController>()
                                    .CanSee(player.ReferenceHub.playerEffectsController.GetEffect <Visuals939>()))
                                {
                                    MakeGhost(index, __instance._transmitBuffer);
                                }
                            }
                        }
                    }
                    else if (player.Role.Type != RoleType.Spectator && player.Role.Type != RoleType.Scp079)
                    {
                        for (int index = 0; index < __instance._usedData; ++index)
                        {
                            PlayerPositionData ppd = __instance._transmitBuffer[index];
                            if (!ReferenceHub.TryGetHub(ppd.playerID, out ReferenceHub targetHub))
                            {
                                continue;
                            }

                            Player currentTarget = GetPlayerOrServer(targetHub.gameObject);
                            if (currentTarget is null)
                            {
                                continue;
                            }

                            Scp096 scp096 = player.ReferenceHub.scpsController.CurrentScp as Scp096;

                            Vector3 vector3 = ppd.position - player.ReferenceHub.playerMovementSync.RealModelPosition;
                            if (Math.Abs(vector3.y) > 35f)
                            {
                                MakeGhost(index, __instance._transmitBuffer);
                            }
                            else
                            {
                                float sqrMagnitude = vector3.sqrMagnitude;
                                if (player.ReferenceHub.playerMovementSync.RealModelPosition.y < 800f)
                                {
                                    if (sqrMagnitude >= 1764f)
                                    {
                                        if (!(sqrMagnitude < 4225f))
                                        {
                                            MakeGhost(index, __instance._transmitBuffer);
                                            continue;
                                        }
                                        if (!(currentTarget.ReferenceHub.scpsController.CurrentScp is Scp096 scp) || !scp.EnragedOrEnraging)
                                        {
                                            MakeGhost(index, __instance._transmitBuffer);
                                            continue;
                                        }
                                    }
                                }
                                else if (sqrMagnitude >= 7225f)
                                {
                                    MakeGhost(index, __instance._transmitBuffer);
                                    continue; // As the target is already ghosted
                                }

                                // The code below doesn't have to follow a ELSE statement!
                                // Otherwise Scp268 won't be processed

                                if (scp096 is not null &&
                                    scp096.EnragedOrEnraging &&
                                    !scp096.HasTarget(currentTarget.ReferenceHub) &&
                                    currentTarget.Role.Team != Team.SCP)
                                {
#if DEBUG
                                    Log.Debug($"[Scp096@GhostModePatch] {player.UserId} can't see {currentTarget.UserId}");
#endif
                                    MakeGhost(index, __instance._transmitBuffer);
                                }
                                else if (currentTarget.ReferenceHub.playerEffectsController.GetEffect <Invisible>().IsEnabled)
                                {
                                    bool flag2 = false;
                                    if (scp096 is not null)
                                    {
                                        flag2 = scp096.HasTarget(currentTarget.ReferenceHub);
                                    }

                                    if (currentTarget != player && player.Role.Type != RoleType.Scp079 &&
                                        player.Role.Type != RoleType.Spectator &&
                                        !flag2)
                                    {
                                        MakeGhost(index, __instance._transmitBuffer);
                                    }
                                }
                            }
                        }
                    }
コード例 #15
0
 public void SetPostitionManager(PlayerPositionManager positionManager)
 {
     this.positionManager = positionManager;
 }