Exemple #1
0
        public void HandleNewActors(JagexBuffer b)
        {
            while (b.BitPosition() + 21 < b.Capacity() * 8)
            {
                int actorIndex = b.ReadBits(14);
                if (actorIndex == 16383)
                {
                    break;
                }

                if (GameContext.Actors[actorIndex] == null)
                {
                    GameContext.Actors[actorIndex] = new Actor();
                }

                Actor a = GameContext.Actors[actorIndex];
                GameContext.ActorIndices[GameContext.ActorCount++] = actorIndex;
                a.ServerIndex = actorIndex;
                a.UpdateCycle = (int)GameContext.LoopCycle;

                int y = b.ReadBits(5);
                if (y > 15)
                {
                    y -= 32;
                }

                int x = b.ReadBits(5);
                if (x > 15)
                {
                    x -= 32;
                }

                int discardWalkQueue = b.ReadBits(1);

                a.Config = GameContext.Cache.GetActorConfig(b.ReadBits(18));
                if (b.ReadBits(1) == 1)
                {
                    entityIndices[entityCount++] = actorIndex;
                }

                a.TileSize           = a.Config.HasOptions;
                a.RotateSpeed        = a.Config.TurnSpeed;
                a.WalkAnimation      = a.Config.MoveAnim;
                a.Turn180Animation   = a.Config.Turn180Anim;
                a.TurnRightAnimation = a.Config.TurnRightAnim;
                a.TurnLeftAnimation  = a.Config.TurnLeftAnim;
                a.StandAnimation     = a.Config.StandAnim;
                a.TeleportTo(GameContext.Self.PathX[0] + x, GameContext.Self.PathY[0] + y, discardWalkQueue == 1);
            }

            b.EndBitAccess();
        }
Exemple #2
0
        private void UpdateNewPlayers(JagexBuffer b)
        {
            while (b.BitPosition() + 10 < b.Capacity() * 8)
            {
                var playerIndex = b.ReadBits(11);
                if (playerIndex == 2047)
                {
                    break;
                }

                if (GameContext.Players[playerIndex] == null)
                {
                    GameContext.Players[playerIndex] = new Player();
                    JagexBuffer buf = GameContext.PlayerBuffers[playerIndex];
                    if (buf != null)
                    {
                        GameContext.Players[playerIndex].Update(buf);
                    }
                }

                GameContext.PlayerIndices[GameContext.PlayerCount++] = playerIndex;
                var p = GameContext.Players[playerIndex];
                p.ServerIndex = playerIndex;
                p.UpdateCycle = (int)GameContext.LoopCycle;

                if (b.ReadBits(1) == 1)
                {
                    entityIndices[entityCount++] = playerIndex;
                }

                var discardWalkQueue = b.ReadBits(1);
                var x = b.ReadBits(5);
                var y = b.ReadBits(5);

                if (x > 15)
                {
                    x -= 32;
                }

                if (y > 15)
                {
                    y -= 32;
                }

                p.TeleportTo(GameContext.Self.PathX[0] + y, GameContext.Self.PathY[0] + x, discardWalkQueue == 1);
            }
            b.EndBitAccess();
        }