public void UpdateInstance(List <Actor> list) { if (isUpdatesLocked) { return; } List <BasePacket> basePackets = new List <BasePacket>(); List <SubPacket> RemoveActorSubpackets = new List <SubPacket>(); List <SubPacket> posUpdateSubpackets = new List <SubPacket>(); //Remove missing actors for (int i = 0; i < actorInstanceList.Count; i++) { if (!list.Contains(actorInstanceList[i])) { QueuePacket(RemoveActorPacket.BuildPacket(actorInstanceList[i].actorId)); actorInstanceList.RemoveAt(i); } } //Add new actors or move for (int i = 0; i < list.Count; i++) { Actor actor = list[i]; if (actor.actorId == playerActor.actorId) { continue; } if (actorInstanceList.Contains(actor)) { //Don't send for static characters (npcs) if (actor is Character && ((Character)actor).isStatic) { continue; } QueuePacket(actor.CreatePositionUpdatePacket()); } else { QueuePacket(actor.GetSpawnPackets(playerActor, 1)); QueuePacket(actor.GetInitPackets()); QueuePacket(actor.GetSetEventStatusPackets()); actorInstanceList.Add(actor); if (actor is Npc) { ((Npc)actor).DoOnActorSpawn(playerActor); } } } }
public override void OnDespawn() { zone.BroadcastPacketAroundActor(this, RemoveActorPacket.BuildPacket(this.actorId)); QueuePositionUpdate(spawnX, spawnY, spawnZ); LuaEngine.CallLuaBattleFunction(this, "onDespawn", this); }