internal void AdjacentDestroyObject(ADJACENT adj, WorldObject obj) { if (Adjacents[(int)adj] != null) { Adjacents[(int)adj].DestroyObject(obj); } }
internal bool AdjacentCreateObject(ADJACENT adj, WorldObject obj, ServerPacket objCreationPkg) { if (Adjacents[(int)adj] != null) { return(Adjacents[(int)adj].CreateObject(obj, objCreationPkg)); } return(false); }
internal void Move(WorldObject obj) { // dunno if we are gonna do the check allowed to move check here. // maybe make OnMove and LeaveTile return true or false // if the object is allowed to move MapTile newTile = GetTileByLoc(obj.Position); MapTile oldTile = obj.MapTile; if (newTile == oldTile) { oldTile.OnMove(obj); return; } ADJACENT adj = oldTile.IsAdjacent(newTile); if (adj == ADJACENT.NONE) { Leave(obj); Enter(obj); return; } ServerPacket createObjectPkg = MakeCreatePacket(obj); bool sendPkg = false; oldTile.LeaveTile(obj); // nothing should happen with the object in this switch // it's only for creating/destroying objects on the client switch (adj) { case ADJACENT.TOPLEFT: oldTile.AdjacentDestroyObject(ADJACENT.TOPRIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.RIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERRIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWER, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERLEFT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.TOPRIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOP, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOPLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERLEFT, obj, createObjectPkg); break; case ADJACENT.TOP: oldTile.AdjacentDestroyObject(ADJACENT.LOWERLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWER, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERRIGHT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.TOPLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOP, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOPRIGHT, obj, createObjectPkg); break; case ADJACENT.TOPRIGHT: oldTile.AdjacentDestroyObject(ADJACENT.TOPLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWER, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERRIGHT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.TOPLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOP, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOPRIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.RIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERRIGHT, obj, createObjectPkg); break; case ADJACENT.LEFT: oldTile.AdjacentDestroyObject(ADJACENT.TOPRIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.RIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERRIGHT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.TOPLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERLEFT, obj, createObjectPkg); break; case ADJACENT.RIGHT: oldTile.AdjacentDestroyObject(ADJACENT.TOPLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERLEFT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.TOPRIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.RIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERRIGHT, obj, createObjectPkg); break; case ADJACENT.LOWERLEFT: oldTile.AdjacentDestroyObject(ADJACENT.TOPLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOP, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOPRIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.RIGHT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LOWERRIGHT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.LOWERRIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWER, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOPLEFT, obj, createObjectPkg); break; case ADJACENT.LOWER: oldTile.AdjacentDestroyObject(ADJACENT.TOPLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOP, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOPRIGHT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.LOWERLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWER, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERRIGHT, obj, createObjectPkg); break; case ADJACENT.LOWERRIGHT: oldTile.AdjacentDestroyObject(ADJACENT.LOWERLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.LEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOPLEFT, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOP, obj); oldTile.AdjacentDestroyObject(ADJACENT.TOPRIGHT, obj); sendPkg = newTile.AdjacentCreateObject(ADJACENT.LOWERLEFT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWER, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.LOWERRIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.RIGHT, obj, createObjectPkg) || newTile.AdjacentCreateObject(ADJACENT.TOPRIGHT, obj, createObjectPkg); break; } if (sendPkg) { WorldServer.Send(createObjectPkg); } obj.MapTile = newTile; newTile.EnterTile(obj); }