예제 #1
0
        protected override void ReadMemory()
        {
            long pGameContext  = ProcessMemory.ReadInt64(Offsets.GameContext.GetInstance());
            long pGameRenderer = ProcessMemory.ReadInt64(Offsets.GameRenderer.GetInstance());

            //read local player
            if (ProcessMemory.IsValid(pGameRenderer))
            {
                long pRenderView = ProcessMemory.ReadInt64(pGameRenderer + Offsets.GameRenderer.PRenderView);

                if (ProcessMemory.IsValid(pRenderView))
                {
                    _localPlayer.ViewProj = ProcessMemory.ReadMatrix(pRenderView + Offsets.RenderView.PViewProj);
                }
            }

            if (ProcessMemory.IsValid(pGameContext))
            {
                long pPlayerManager = ProcessMemory.ReadInt64(pGameContext + Offsets.GameContext.PPlayerManager);

                if (ProcessMemory.IsValid(pPlayerManager))
                {
                    long pLocalPlayer = ProcessMemory.ReadInt64(pPlayerManager + Offsets.ClientPlayerManager.PLocalPlayer);

                    if (ProcessMemory.IsValid(pLocalPlayer))
                    {
                        _localPlayer.Name   = ProcessMemory.ReadAsciiString(pLocalPlayer + Offsets.ClientPlayer.Name, 10);
                        _localPlayer.TeamId = ProcessMemory.ReadInt32(pLocalPlayer + Offsets.ClientPlayer.TeamId);

                        long pSoldierEntity = ProcessMemory.ReadInt64(pLocalPlayer + Offsets.ClientPlayer.PControlledControllable);

                        if (ProcessMemory.IsValid(pSoldierEntity))
                        {
                            _localPlayer.Yaw = ProcessMemory.ReadFloat(pSoldierEntity + Offsets.ClientSoldierEntity.Yaw);

                            long pPredictedController = ProcessMemory.ReadInt64(pSoldierEntity + Offsets.ClientSoldierEntity.PPredictedController);

                            if (ProcessMemory.IsValid(pPredictedController))
                            {
                                _localPlayer.Position = ProcessMemory.ReadVector3(pPredictedController + Offsets.ClientSoldierPrediction.PPosition);
                            }
                        }
                    }
                }
            }

            //read players
            _players.Clear();

            if (ProcessMemory.IsValid(pGameContext))
            {
                long pPlayerManager = ProcessMemory.ReadInt64(pGameContext + Offsets.GameContext.PPlayerManager);

                if (ProcessMemory.IsValid(pPlayerManager))
                {
                    long ppPlayer = ProcessMemory.ReadInt64(pPlayerManager + Offsets.ClientPlayerManager.PClientPlayer);

                    if (ProcessMemory.IsValid(ppPlayer))
                    {
                        for (int i = 0; i < 64; i++)
                        {
                            long pPlayer = ProcessMemory.ReadInt64(ppPlayer + i * 0x8);

                            if (ProcessMemory.IsValid(pPlayer))
                            {
                                Player player = new Player();

                                player.Name        = ProcessMemory.ReadAsciiString(pPlayer + Offsets.ClientPlayer.Name, 10);
                                player.TeamId      = ProcessMemory.ReadInt32(pPlayer + Offsets.ClientPlayer.TeamId);
                                player.IsSpectator = ProcessMemory.ReadBool(pPlayer + Offsets.ClientPlayer.IsSpectator);

                                long pSoldierEntity = ProcessMemory.ReadInt64(pPlayer + Offsets.ClientPlayer.PControlledControllable);

                                if (ProcessMemory.IsValid(pSoldierEntity))
                                {
                                    player.Yaw       = ProcessMemory.ReadFloat(pSoldierEntity + Offsets.ClientSoldierEntity.Yaw);
                                    player.IsVisible = ProcessMemory.ReadBool(pSoldierEntity + Offsets.ClientSoldierEntity.IsOccluded);
                                    player.PoseType  = (Player.Pose)ProcessMemory.ReadInt32(pSoldierEntity + Offsets.ClientSoldierEntity.PoseType);

                                    long pHealthComponent = ProcessMemory.ReadInt64(pSoldierEntity + Offsets.ClientSoldierEntity.PHealthComponent);

                                    if (ProcessMemory.IsValid(pHealthComponent))
                                    {
                                        player.Health    = ProcessMemory.ReadFloat(pHealthComponent + Offsets.HealthComponent.Health);
                                        player.MaxHealth = ProcessMemory.ReadFloat(pHealthComponent + Offsets.HealthComponent.MaxHealth);
                                    }

                                    long pPredictedController = ProcessMemory.ReadInt64(pSoldierEntity + Offsets.ClientSoldierEntity.PPredictedController);

                                    if (ProcessMemory.IsValid(pPredictedController))
                                    {
                                        player.Position = ProcessMemory.ReadVector3(pPredictedController + Offsets.ClientPredictedController.Position);
                                    }
                                }

                                _players.Add(player);
                            }
                        }
                    }
                }
            }
        }