/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on the floor. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnFloor(Vector3 halfDims) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnFloor; placement.HalfDims = halfDims; return placement; }
/// <summary> /// Call this to initialize a Behaviour with data supplied in a file. /// </summary> /// <param name="fileName">The file to load from.</param> public override void LoadContent(String fileName) { base.LoadContent(fileName); ObjectPlacementDefinition def = GameObjectManager.pInstance.pContentManager.Load <ObjectPlacementDefinition>(fileName); mCursor = new GameObject("GameObjects\\Interface\\PlacementCursor\\PlacementCursor"); mCursor.pPosition = mParentGOH.pPosition; GameObjectManager.pInstance.Add(mCursor); mCursorOffset = Vector2.Zero; mItemOffset = new Vector2(-4, -4); mItemSourceRect = new Rectangle(0, 0, 8, 8); mItemColor = new Color(255, 255, 255, 200); mAbsOffsetRange = def.mAbsOffsetRange; mRemoveClassifications = new List <MBHEngineContentDefs.GameObjectDefinition.Classifications>(1); mRemoveClassifications.Add(MBHEngineContentDefs.GameObjectDefinition.Classifications.WALL); mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage(); mGetMapInfoMsg = new Level.GetMapInfoMessage(); mSetTileTypeAtPositionMsg = new Level.SetTileTypeAtPositionMessage(); mGetCurrentObjectMsg = new Inventory.GetCurrentObjectMessage(); mOnPlaceObjectMsg = new OnPlaceObjectMessage(); mAddObjectMsg = new Inventory.AddObjectMessage(); mSelectNextItemMsg = new Inventory.SelectNextItemMessage(); mGetTexture2DMsg = new SpriteRender.GetTexture2DMessage(); mPeekCurrentObjectMsg = new Inventory.PeekCurrentObjectMessage(); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on the floor. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnFloor(Vector3 halfDims) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnFloor; placement.HalfDims = halfDims; return(placement); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be place under a platform edge. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_UnderPlatformEdge(Vector3 halfDims) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_UnderPlatformEdge; placement.HalfDims = halfDims; return(placement); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed floating in space, within the playspace. This query requires that /// other objects do not collide with the placement volume. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_InMidAir(Vector3 halfDims) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition { Type = PlacementType.Place_InMidAir, HalfDims = halfDims }; return(placement); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on top of another object placed object. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="shapeName">Name of the placed object</param> /// <param name="componentIndex">Index of the component within shapeName</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnShape(Vector3 halfDims, string shapeName, int componentIndex) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnShape; placement.HalfDims = halfDims; placement.PlacementParam_Str_0 = SpatialUnderstanding.Instance.UnderstandingDLL.PinString(shapeName); placement.PlacementParam_Int_0 = componentIndex; return(placement); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be have space on the floor and ceiling within the same vertical space. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="halfDimsBottom">Half size of the bottom part of the placement volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnFloorAndCeiling(Vector3 halfDims, Vector3 halfDimsBottom) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnFloorAndCeiling; placement.HalfDims = halfDims; placement.PlacementParam_Float_0 = halfDimsBottom.x; placement.PlacementParam_Float_1 = halfDimsBottom.y; placement.PlacementParam_Float_2 = halfDimsBottom.z; return(placement); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on the edge of a platform. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="halfDimsBottom">Half size of the bottom part of the placement volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnEdge(Vector3 halfDims, Vector3 halfDimsBottom) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition { Type = PlacementType.Place_OnEdge, HalfDims = halfDims, PlacementParam_Float_0 = halfDimsBottom.x, PlacementParam_Float_1 = halfDimsBottom.y, PlacementParam_Float_2 = halfDimsBottom.z }; return(placement); }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on a wall. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="heightMin">Minimum height of the requested volume above the floor</param> /// <param name="heightMax">Maximum height of the requested volume above the floor</param> /// <param name="wallTypes">Bit mask of possible walls to consider, defined by WallTypeFlags</param> /// <param name="marginLeft">Required empty wall space to the left of the volume, as defined by facing the wall</param> /// <param name="marginRight">Required empty wall space to the right of the volume, as defined by facing the wall</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnWall( Vector3 halfDims, float heightMin, float heightMax, WallTypeFlags wallTypes = WallTypeFlags.External | WallTypeFlags.Normal, float marginLeft = 0.0f, float marginRight = 0.0f) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnWall; placement.HalfDims = halfDims; placement.PlacementParam_Float_0 = heightMin; placement.PlacementParam_Float_1 = heightMax; placement.PlacementParam_Float_2 = marginLeft; placement.PlacementParam_Float_3 = marginRight; placement.WallFlags = (int)wallTypes; return(placement); }
private void ParseTextIPL(byte[] data, out int errorCount) { string parserData = Encoding.UTF8.GetString(data); string[] lines = parserData.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); string mode = null; errorCount = 0; foreach (string line in lines) { if (line.StartsWith("#", StringComparison.InvariantCultureIgnoreCase) || line.Trim().Length == 0) { continue; } if (mode == null) { if (line.StartsWith("inst", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("cars", StringComparison.InvariantCultureIgnoreCase) || // unused line.StartsWith("zone", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("cull", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("pick", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("occl", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("mult", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("grge", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("enex", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("jump", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("tcyc", StringComparison.InvariantCultureIgnoreCase) || line.StartsWith("auzo", StringComparison.InvariantCultureIgnoreCase)) { mode = line.Substring(0, 4).ToLowerInvariant(); } continue; } else { if (line.StartsWith("end", StringComparison.InvariantCultureIgnoreCase)) { mode = null; continue; } var parts = line.Split(new char[] { ',', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { parts[i] = parts[i].Trim(' ', '\t', '\r', ','); } try { if (mode == "inst") { var element = new InstanceIPLElement(); if (parts.Length >= 11) { element.Id = int.Parse(parts[0]); element.ModelName = parts[1]; element.Interior = int.Parse(parts[2]); element.X = float.Parse(parts[3]); element.Y = float.Parse(parts[4]); element.Z = float.Parse(parts[5]); element.RX = float.Parse(parts[6]); element.RY = float.Parse(parts[7]); element.RZ = float.Parse(parts[8]); element.RW = float.Parse(parts[9]); element.LODIndex = int.Parse(parts[10]); } var obj = new ObjectPlacementDefinition() { Id = element.Id, Position = new Point3D(element.X, element.Y, element.Z), Rotation = new Quaternion(element.RX, element.RY, element.RZ, element.RW), Interior = element.Interior, LODIndex = element.LODIndex }; MasterDictionary.ObjectPlacementDefinitions.Add(obj); } else if (mode == "cars") { var element = new CarsIPLElement(); if (parts.Length >= 8) { element.X = float.Parse(parts[0]); element.Y = float.Parse(parts[1]); element.Z = float.Parse(parts[2]); element.Angle = float.Parse(parts[3]); element.Id = int.Parse(parts[4]); element.Color1 = int.Parse(parts[5]); element.Color2 = int.Parse(parts[6]); element.ForceSpawn = int.Parse(parts[7]); } if (parts.Length >= 10) { element.Alarm = int.Parse(parts[8]); element.DoorLock = int.Parse(parts[9]); } if (parts.Length >= 12) { element.Unknown1 = int.Parse(parts[10]); element.Unknown2 = int.Parse(parts[11]); } var obj = new VehiclePlacementDefinition() { Id = element.Id, Position = new Point3D(element.X, element.Y, element.Z), ZRotation = element.Angle, Color1 = element.Color1, Color2 = element.Color2 }; MasterDictionary.VehiclePlacementDefinitions.Add(obj); } } catch { errorCount++; } } } }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on a wall. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="heightMin">Minimum height of the requested volume above the floor</param> /// <param name="heightMax">Maximum height of the requested volume above the floor</param> /// <param name="wallTypes">Bit mask of possible walls to consider, defined by WallTypeFlags</param> /// <param name="marginLeft">Required empty wall space to the left of the volume, as defined by facing the wall</param> /// <param name="marginRight">Required empty wall space to the right of the volume, as defined by facing the wall</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnWall( Vector3 halfDims, float heightMin, float heightMax, WallTypeFlags wallTypes = WallTypeFlags.External | WallTypeFlags.Normal, float marginLeft = 0.0f, float marginRight = 0.0f) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnWall; placement.HalfDims = halfDims; placement.PlacementParam_Float_0 = heightMin; placement.PlacementParam_Float_1 = heightMax; placement.PlacementParam_Float_2 = marginLeft; placement.PlacementParam_Float_3 = marginRight; placement.WallFlags = (int)wallTypes; return placement; }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be place under a platform edge. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_UnderPlatformEdge(Vector3 halfDims) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_UnderPlatformEdge; placement.HalfDims = halfDims; return placement; }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be have space on the floor and ceiling within the same vertical space. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="halfDimsBottom">Half size of the bottom part of the placement volume</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnFloorAndCeiling(Vector3 halfDims, Vector3 halfDimsBottom) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnFloorAndCeiling; placement.HalfDims = halfDims; placement.PlacementParam_Float_0 = halfDimsBottom.x; placement.PlacementParam_Float_1 = halfDimsBottom.y; placement.PlacementParam_Float_2 = halfDimsBottom.z; return placement; }
/// <summary> /// Constructs an object placement query definition requiring the object to /// be placed on top of another object placed object. /// </summary> /// <param name="halfDims">Required half size of the requested bounding volume</param> /// <param name="shapeName">Name of the placed object</param> /// <param name="componentIndex">Index of the component within shapeName</param> /// <returns>Constructed object placement definition</returns> public static ObjectPlacementDefinition Create_OnShape(Vector3 halfDims, string shapeName, int componentIndex) { ObjectPlacementDefinition placement = new ObjectPlacementDefinition(); placement.Type = PlacementType.Place_OnShape; placement.HalfDims = halfDims; placement.PlacementParam_Str_0 = SpatialUnderstanding.Instance.UnderstandingDLL.PinString(shapeName); placement.PlacementParam_Int_0 = componentIndex; return placement; }