public PortalRequestProcessor( int character_id, Point3d portal_position, float portal_angle, int portal_id) { m_character_id = character_id; m_portal_position = new Point3d(portal_position); m_portal_angle = portal_angle; m_portal_id = portal_id; m_world = null; m_room = null; m_opposing_room = null; m_portal = null; m_opposing_portal = null; m_opposing_portal_position = new Point3d(); m_current_room_key = null; m_opposing_room_key = null; m_current_character_position = new Point3d(); m_current_character_angle = 0.0f; m_game_id = -1; m_move_to_target = false; m_result_event_list = null; }
// Setup this portal in the given room to oppose the target portal public static Portal CreateOpposingPortal(Portal targetPortal) { Portal newPortal = new Portal(); newPortal.portal_id = -1; // Id not set until we save the portal into the DB newPortal.target_portal_id = targetPortal.portal_id; newPortal.bounding_box = targetPortal.bounding_box; switch (targetPortal.room_side) { case MathConstants.eSignedDirection.positive_x: { newPortal.room_side = MathConstants.eSignedDirection.negative_x; newPortal.room_x = targetPortal.room_x + 1; newPortal.room_y = targetPortal.room_y; newPortal.room_z = targetPortal.room_z; newPortal.bounding_box.Move( -Vector3d.I * (WorldConstants.ROOM_BOUNDS.XWidth - targetPortal.bounding_box.XWidth)); } break; case MathConstants.eSignedDirection.negative_x: { newPortal.room_side = MathConstants.eSignedDirection.positive_x; newPortal.room_x = targetPortal.room_x - 1; newPortal.room_y = targetPortal.room_y; newPortal.room_z = targetPortal.room_z; newPortal.bounding_box.Move( Vector3d.I * (WorldConstants.ROOM_BOUNDS.XWidth - targetPortal.bounding_box.XWidth)); } break; case MathConstants.eSignedDirection.positive_y: { newPortal.room_side = MathConstants.eSignedDirection.negative_y; newPortal.room_x = targetPortal.room_x; newPortal.room_y = targetPortal.room_y + 1; newPortal.room_z = targetPortal.room_z; newPortal.bounding_box.Move( -Vector3d.J * (WorldConstants.ROOM_BOUNDS.YWidth - targetPortal.bounding_box.YWidth)); } break; case MathConstants.eSignedDirection.negative_y: { newPortal.room_side = MathConstants.eSignedDirection.positive_y; newPortal.room_x = targetPortal.room_x; newPortal.room_y = targetPortal.room_y - 1; newPortal.room_z = targetPortal.room_z; newPortal.bounding_box.Move( Vector3d.J * (WorldConstants.ROOM_BOUNDS.YWidth - targetPortal.bounding_box.YWidth)); } break; case MathConstants.eSignedDirection.positive_z: { newPortal.room_side = MathConstants.eSignedDirection.negative_z; newPortal.room_x = targetPortal.room_x; newPortal.room_y = targetPortal.room_y; newPortal.room_z = targetPortal.room_z + 1; // Keep same bounding box } break; case MathConstants.eSignedDirection.negative_z: { newPortal.room_side = MathConstants.eSignedDirection.positive_z; newPortal.room_x = targetPortal.room_x; newPortal.room_y = targetPortal.room_y; newPortal.room_z = targetPortal.room_z - 1; // Keep same bounding box } break; } return newPortal; }
public static Portal CreatePortal(Portals dbPortal) { Portal portal = new Portal(); portal.portal_id = dbPortal.PortalID; portal.target_portal_id = dbPortal.TargetPortalID; portal.room_x = dbPortal.RoomX; portal.room_y = dbPortal.RoomY; portal.room_z = dbPortal.RoomZ; portal.room_side = (MathConstants.eSignedDirection)dbPortal.RoomSide; portal.bounding_box.SetPointBounds( new Point3d((float)dbPortal.BboxX0, (float)dbPortal.BboxY0, 0F), new Point3d((float)dbPortal.BboxX1, (float)dbPortal.BboxY1, 0F)); return portal; }
public static Portal CreatePortal(Room room, MathConstants.eSignedDirection roomSide) { Portal newPortal = new Portal(); newPortal.portal_id = -1; // portal ID not set until this portal gets saved into the DB newPortal.target_portal_id = -1; newPortal.room_side = roomSide; newPortal.room_x = room.room_key.x; newPortal.room_y = room.room_key.y; newPortal.room_z = room.room_key.z; switch (roomSide) { case MathConstants.eSignedDirection.positive_x: { Point3d p1= WorldConstants.ROOM_BOUNDS.Max; Point3d p0= p1 - Vector3d.I*WorldConstants.PORTAL_WIDTH - Vector3d.J*WorldConstants.ROOM_Y_SIZE; newPortal.bounding_box= new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.negative_x: { Point3d p0 = WorldConstants.ROOM_BOUNDS.Min; Point3d p1 = p0 + Vector3d.I * WorldConstants.PORTAL_WIDTH + Vector3d.J * WorldConstants.ROOM_Y_SIZE; newPortal.bounding_box= new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.positive_y: { Point3d p1 = WorldConstants.ROOM_BOUNDS.Max; Point3d p0 = p1 - Vector3d.I * WorldConstants.ROOM_X_SIZE - Vector3d.J * WorldConstants.PORTAL_WIDTH; newPortal.bounding_box= new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.negative_y: { Point3d p0 = WorldConstants.ROOM_BOUNDS.Min; Point3d p1 = p0 + Vector3d.I * WorldConstants.ROOM_X_SIZE + Vector3d.J * WorldConstants.PORTAL_WIDTH; newPortal.bounding_box= new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.positive_z: case MathConstants.eSignedDirection.negative_z: { int column = RNGUtilities.RandomInt(WorldConstants.ROOM_X_TILES / 3, 2 * WorldConstants.ROOM_X_TILES / 3); int row = RNGUtilities.RandomInt(WorldConstants.ROOM_Y_TILES / 3, 2 * WorldConstants.ROOM_Y_TILES / 3); Point3d p0 = WorldConstants.GetTilePosition(column, row); Point3d p1 = p0 + Vector3d.I * WorldConstants.ROOM_TILE_SIZE + Vector3d.J * WorldConstants.ROOM_TILE_SIZE; newPortal.bounding_box = new AABB3d(p0, p1); } break; } return newPortal; }
private bool LookupPortal(out string result_code) { bool success; // Make sure the portal actually exists in the room the player is in m_portal = m_room.portals.Find(p => p.portal_id == m_portal_id); if (m_portal != null) { result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.INVALID_REQUEST; success = false; } return success; }
private bool LookupOpposingPortal( RequestCache requestCache, out string result_code) { bool success; // If the opposing portal doesn't exist yet, // create a new room adjacent to the current room with an opposing portal if (m_portal.target_portal_id != -1) { //If an opposing portal exists, retrieve it from the DB m_opposing_portal= WorldQueries.GetPortal( requestCache.DatabaseContext, m_portal.target_portal_id); m_opposing_room_key = new RoomKey( m_game_id, m_opposing_portal.room_x, m_opposing_portal.room_y, m_opposing_portal.room_z); // Compute our target position in the new room // Clamp the players position into the bounding box of the portal in the new room m_opposing_portal_position = m_opposing_portal.bounding_box.ClipPoint(m_portal_position); result_code = SuccessMessages.GENERAL_SUCCESS; success = true; } else { result_code = ErrorMessages.CACHE_ERROR; success = false; } return success; }