private void UpdateLocalPlayerMovement(JagexBuffer b) { b.BeginBitAccess(); if (b.ReadBits(1) == 0) { return; } int moveType = b.ReadBits(2); if (moveType == 0) { entityIndices[entityCount++] = 2047; return; } if (moveType == 1) { int direction = b.ReadBits(3); GameContext.Self.QueueMove(direction, false); if (b.ReadBits(1) == 1) { entityIndices[entityCount++] = 2047; } return; } if (moveType == 2) { GameContext.Self.QueueMove(b.ReadBits(3), true); GameContext.Self.QueueMove(b.ReadBits(3), true); if (b.ReadBits(1) == 1) { entityIndices[entityCount++] = 2047; } return; } if (moveType == 3) { GameContext.Plane = b.ReadBits(2); int discardMoveQueue = b.ReadBits(1); if (b.ReadBits(1) == 1) { entityIndices[entityCount++] = 2047; } int y = b.ReadBits(7); int x = b.ReadBits(7); GameContext.Self.TeleportTo(x, y, discardMoveQueue == 1); } }
public void UpdateActorMovement(JagexBuffer b) { b.BeginBitAccess(); int actorCount = b.ReadBits(8); if (actorCount < GameContext.ActorCount) { for (int l = actorCount; l < GameContext.ActorCount; l++) { entityUpdateIndices[entityUpdateCount++] = GameContext.ActorIndices[l]; } } if (actorCount > GameContext.ActorCount) { Debug.Log("Actor count is too high"); return; } GameContext.ActorCount = 0; for (int i = 0; i < actorCount; i++) { int actorIndex = GameContext.ActorIndices[i]; Actor a = GameContext.Actors[actorIndex]; int movement_update = b.ReadBits(1); if (movement_update == 0) { GameContext.ActorIndices[GameContext.ActorCount++] = actorIndex; a.UpdateCycle = (int)GameContext.LoopCycle; } else { int moveType = b.ReadBits(2); switch (moveType) { case 0: { GameContext.ActorIndices[GameContext.ActorCount++] = actorIndex; a.UpdateCycle = (int)GameContext.LoopCycle; entityIndices[entityCount++] = actorIndex; break; } case 1: { GameContext.ActorIndices[GameContext.ActorCount++] = actorIndex; a.UpdateCycle = (int)GameContext.LoopCycle; a.QueueMove(b.ReadBits(3), false); if (b.ReadBits(1) == 1) { entityIndices[entityCount++] = actorIndex; } break; } case 2: { GameContext.ActorIndices[GameContext.ActorCount++] = actorIndex; a.UpdateCycle = (int)GameContext.LoopCycle; a.QueueMove(b.ReadBits(3), true); a.QueueMove(b.ReadBits(3), true); if (b.ReadBits(1) == 1) { entityIndices[entityCount++] = actorIndex; } break; } case 3: { entityUpdateIndices[entityUpdateCount++] = actorIndex; break; } } } } }