public MyMwcObjectBuilder_VoxelHand_Cylinder(MyMwcPositionAndOrientation positionAndOrientation, float radius1, float radius2, float length, MyMwcVoxelHandModeTypeEnum voxelHandModeType) : base(positionAndOrientation, voxelHandModeType) { Radius1 = radius1; Radius2 = radius2; Length = length; }
// Read this object from message-in internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion) { if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError(); MyMwcPositionAndOrientation? objectPositionAndOrientation = MyMwcMessageIn.ReadPositionAndOrientationEx(binaryReader, senderEndPoint); if (objectPositionAndOrientation == null) return NetworkError(); MyMwcLog.IfNetVerbose_AddToLog("objectPositionAndOrientation: " + objectPositionAndOrientation.ToString()); PositionAndOrientation = objectPositionAndOrientation.Value; MyMwcVoxelHandModeTypeEnum? voxelHandModeType = MyMwcMessageIn.ReadVoxelHandModeTypeEnumEx(binaryReader, senderEndPoint); if (voxelHandModeType == null) return NetworkError(); VoxelHandModeType = voxelHandModeType.Value; MyMwcLog.IfNetVerbose_AddToLog("VoxelHandModeType: " + VoxelHandModeType.ToString()); bool? isVoxelMaterial = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (isVoxelMaterial == null) return NetworkError(); if (isVoxelMaterial.Value) { VoxelHandMaterial = MyMwcMessageIn.ReadVoxelMaterialsEnumEx(binaryReader, senderEndPoint); } else { VoxelHandMaterial = null; } return true; }
public MyMwcObjectBuilder_VoxelHand_Cuboid(MyMwcPositionAndOrientation positionAndOrientation, float width1, float depth1, float width2, float depth2, float length, MyMwcVoxelHandModeTypeEnum voxelHandModeType) : base(positionAndOrientation, voxelHandModeType) { Width1 = width1; Depth1 = depth1; Width2 = width2; Depth2 = depth2; Length = length; }
// Read this object from message-in internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion) { if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError(); MyMwcPositionAndOrientation? objectPositionAndOrientation = MyMwcMessageIn.ReadPositionAndOrientationEx(binaryReader, senderEndPoint); if (objectPositionAndOrientation == null) return NetworkError(); MyMwcLog.IfNetVerbose_AddToLog("objectPositionAndOrientation: " + objectPositionAndOrientation.ToString()); PositionAndOrientation = objectPositionAndOrientation.Value; return true; }
// Read this object from message-in internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion) { if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) { return(NetworkError()); } MyMwcPositionAndOrientation?objectPositionAndOrientation = MyMwcMessageIn.ReadPositionAndOrientationEx(binaryReader, senderEndPoint); if (objectPositionAndOrientation == null) { return(NetworkError()); } MyMwcLog.IfNetVerbose_AddToLog("objectPositionAndOrientation: " + objectPositionAndOrientation.ToString()); PositionAndOrientation = objectPositionAndOrientation.Value; return(true); }
// Read this object from message-in internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion) { if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) { return(NetworkError()); } MyMwcPositionAndOrientation?objectPositionAndOrientation = MyMwcMessageIn.ReadPositionAndOrientationEx(binaryReader, senderEndPoint); if (objectPositionAndOrientation == null) { return(NetworkError()); } MyMwcLog.IfNetVerbose_AddToLog("objectPositionAndOrientation: " + objectPositionAndOrientation.ToString()); PositionAndOrientation = objectPositionAndOrientation.Value; MyMwcVoxelHandModeTypeEnum?voxelHandModeType = MyMwcMessageIn.ReadVoxelHandModeTypeEnumEx(binaryReader, senderEndPoint); if (voxelHandModeType == null) { return(NetworkError()); } VoxelHandModeType = voxelHandModeType.Value; MyMwcLog.IfNetVerbose_AddToLog("VoxelHandModeType: " + VoxelHandModeType.ToString()); bool?isVoxelMaterial = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (isVoxelMaterial == null) { return(NetworkError()); } if (isVoxelMaterial.Value) { VoxelHandMaterial = MyMwcMessageIn.ReadVoxelMaterialsEnumEx(binaryReader, senderEndPoint); } else { VoxelHandMaterial = null; } return(true); }
public override void OnOkClick(MyGuiControlButton sender) { base.OnOkClick(sender); if (m_botBuilder != null) { m_botBuilder.Faction = (MyMwcObjectBuilder_FactionEnum)m_selectShipFactionCombobox.GetSelectedKey(); m_botBuilder.AITemplate = (MyAITemplateEnum)m_selectAITemplateCombobox.GetSelectedKey(); m_botBuilder.Aggressivity = m_aggresivitySlider.GetValue(); m_botBuilder.SeeDistance = m_seeDistanceSlider.GetValue(); var templateBuilder = m_templatesBuilders[m_selectSmallShipCombobox.GetSelectedKey()]; bool isTemplate = templateBuilder.UserData != null; if (isTemplate) { var template = templateBuilder.UserData as MySmallShipTemplate; if (m_botBuilder.ShipTemplateID == null) { if (m_inventoryBuilder == null) { m_botBuilder.Inventory = null; m_botBuilder.Weapons = null; m_botBuilder.Engine = null; m_botBuilder.Armor = null; m_botBuilder.Radar = null; } else { m_botBuilder.Inventory = m_inventoryBuilder.Inventory; m_botBuilder.Weapons = m_inventoryBuilder.Weapons; m_botBuilder.Engine = m_inventoryBuilder.Engine; m_botBuilder.Armor = m_inventoryBuilder.Armor; m_botBuilder.Radar = m_inventoryBuilder.Radar; } } m_botBuilder.ShipTemplateID = template.ID; } else { var builderWithAllItems = MyMwcObjectBuilder_SmallShip_Bot.CreateObjectBuilderWithAllItems(templateBuilder.Builder.ShipType, MyShipTypeConstants.GetShipTypeProperties(templateBuilder.Builder.ShipType).GamePlay.CargoCapacity); if (m_botBuilder.ShipTemplateID != null) { m_botBuilder.Inventory = builderWithAllItems.Inventory; m_botBuilder.Weapons = builderWithAllItems.Weapons; m_botBuilder.Engine = builderWithAllItems.Engine; m_botBuilder.Armor = builderWithAllItems.Armor; m_botBuilder.Radar = builderWithAllItems.Radar; } m_botBuilder.ShipTemplateID = null; } m_botBuilder.ShipType = templateBuilder.Builder.ShipType; CloseAndCallOnOk(); } else if (m_bot != null) // edit SmallShip { Matrix matrix = m_bot.WorldMatrix; MyMwcObjectBuilder_SmallShip_Bot botBuilder = m_bot.GetObjectBuilder(true) as MyMwcObjectBuilder_SmallShip_Bot; System.Diagnostics.Debug.Assert(botBuilder != null); botBuilder.Faction = (MyMwcObjectBuilder_FactionEnum)m_selectShipFactionCombobox.GetSelectedKey(); botBuilder.AITemplate = (MyAITemplateEnum)m_selectAITemplateCombobox.GetSelectedKey(); botBuilder.Aggressivity = m_aggresivitySlider.GetValue(); botBuilder.SeeDistance = m_seeDistanceSlider.GetValue(); botBuilder.ShipType = (MyMwcObjectBuilder_SmallShip_TypesEnum)m_selectSmallShipCombobox.GetSelectedKey(); if (m_inventoryBuilder != null) { botBuilder.Inventory = m_inventoryBuilder.Inventory; botBuilder.Weapons = m_inventoryBuilder.Weapons; botBuilder.Engine = m_inventoryBuilder.Engine; botBuilder.Armor = m_inventoryBuilder.Armor; botBuilder.Radar = m_inventoryBuilder.Radar; } MyEditorGizmo.ClearSelection(); m_newBotBuilderToInit = botBuilder; m_newBotWorldMatrixToInit = matrix; m_bot.MarkForClose(); m_bot.OnClose += OnOldBodClose; } else // create SmallShip { MyMwcObjectBuilder_SmallShip_TypesEnum shipType = (MyMwcObjectBuilder_SmallShip_TypesEnum) Enum.ToObject(typeof(MyMwcObjectBuilder_SmallShip_TypesEnum), m_selectSmallShipCombobox.GetSelectedKey()); MyMwcObjectBuilder_FactionEnum shipFaction = (MyMwcObjectBuilder_FactionEnum) Enum.ToObject(typeof(MyMwcObjectBuilder_FactionEnum), m_selectShipFactionCombobox.GetSelectedKey()); MyMwcPositionAndOrientation positionAndOrientation = new MyMwcPositionAndOrientation(m_newObjectPosition, Vector3.Forward, Vector3.Up); MyMwcObjectBuilder_SmallShip_Bot botBuilder = MyEditor.CreateDefaultBotObjectBuilder(positionAndOrientation.Position, positionAndOrientation.Forward, positionAndOrientation.Up, shipType, shipFaction); botBuilder.AITemplate = (MyAITemplateEnum)m_selectAITemplateCombobox.GetSelectedKey(); botBuilder.Aggressivity = m_aggresivitySlider.GetValue(); botBuilder.SeeDistance = m_seeDistanceSlider.GetValue(); MyEditor.Static.CreateFromObjectBuilder(botBuilder, Matrix.CreateWorld(m_newObjectPosition, Vector3.Forward, Vector3.Up), m_screenPosition); CloseAndCallOnOk(); } }
protected MyMwcObjectBuilder_VoxelHand_Shape(MyMwcPositionAndOrientation positionAndOrientation, MyMwcVoxelHandModeTypeEnum voxelHandModeType) : base() { PositionAndOrientation = positionAndOrientation; VoxelHandModeType = voxelHandModeType; }
public static void SetVoxelProperties(MyVoxelHandShapeType voxelHandShapeType, float distance, MyMwcVoxelHandModeTypeEnum modeType, MyMwcVoxelMaterialsEnum?materialEnum, bool isProjected, bool isProjectedToWaypoints) { IsProjected = isProjected; IsProjectedToWaypoints = isProjectedToWaypoints; // same shape type if (voxelHandShapeType == MyEditorVoxelHand.VoxelHandShape.GetShapeType()) { //if ((size >= MyVoxelConstants.MIN_VOXEL_HAND_SIZE) && (size <= MyVoxelConstants.MAX_VOXEL_HAND_SIZE)) { //MyEditorVoxelHand.VoxelHandShape.SetShapeSize(size); //MyEditorVoxelHand.VoxelHandShape.SetShapeSize2(size2); //MyEditorVoxelHand.VoxelHandShape.SetShapeSize3(size3); MyEditorVoxelHand.VoxelHandShape.ModeType = modeType; MyEditorVoxelHand.VoxelHandShape.Material = materialEnum; } } // another shape type else { // float newShapeSize = size; // if ((newShapeSize < MyVoxelConstants.MIN_VOXEL_HAND_SIZE) && (newShapeSize > MyVoxelConstants.MAX_VOXEL_HAND_SIZE)) float newShapeSize = MyVoxelConstants.DEFAULT_VOXEL_HAND_SIZE; MyMwcPositionAndOrientation positionAndOritentation = new MyMwcPositionAndOrientation(MySpectator.Position, Vector3.Forward, Vector3.Up); switch (voxelHandShapeType) { case MyVoxelHandShapeType.Sphere: MyMwcObjectBuilder_VoxelHand_Sphere sphereObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Sphere(positionAndOritentation, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandSphere(); ((MyVoxelHandSphere)MyEditorVoxelHand.VoxelHandShape).Init(sphereObjectBuilder, null); break; case MyVoxelHandShapeType.Box: MyMwcObjectBuilder_VoxelHand_Box boxObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Box(positionAndOritentation, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandBox(); ((MyVoxelHandBox)MyEditorVoxelHand.VoxelHandShape).Init(boxObjectBuilder, null); break; case MyVoxelHandShapeType.Cuboid: MyMwcObjectBuilder_VoxelHand_Cuboid cuboidObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Cuboid(positionAndOritentation, newShapeSize, newShapeSize, newShapeSize, newShapeSize, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandCuboid(); ((MyVoxelHandCuboid)MyEditorVoxelHand.VoxelHandShape).Init(cuboidObjectBuilder, null); break; case MyVoxelHandShapeType.Cylinder: MyMwcObjectBuilder_VoxelHand_Cylinder cylinderObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Cylinder(positionAndOritentation, newShapeSize, newShapeSize, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandCylinder(); ((MyVoxelHandCylinder)MyEditorVoxelHand.VoxelHandShape).Init(cylinderObjectBuilder, null); break; default: System.Diagnostics.Debug.Assert(false); break; } MyEditorVoxelHand.VoxelHandShape.Material = materialEnum; } if (IsProjected) { if (!MyFakes.MWBUILDER) { if ((distance >= MyVoxelConstants.MIN_PROJECTED_VOXEL_HAND_OFFSET) && (distance <= MyVoxelConstants.MAX_PROJECTED_VOXEL_HAND_OFFSET)) { MyEditorVoxelHand.SetShapeDistance(distance); } } } else if (IsProjectedToWaypoints) { } else { if ((distance >= MyVoxelConstants.MIN_VOXEL_HAND_DISTANCE) && (distance <= MyVoxelConstants.MAX_VOXEL_HAND_DISTANCE)) { MyEditorVoxelHand.SetShapeDistance(distance); } } MyEditorVoxelHand.UpdateShapePosition(); }
/// <summary> /// /// </summary> /// <returns>Return false when all players are dead</returns> public bool GetSafeRespawnPositionNearPlayer(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, out MyMwcPositionAndOrientation positionAndOrientation) { foreach (var player in Peers.Players) { if (player.Ship != null && !player.Ship.IsDead()) { Vector3 position; if (GetSafeRespawnPositionNearEntity(shipType, player.Ship, out position)) { positionAndOrientation = new MyMwcPositionAndOrientation(position, player.Ship.GetForward(), player.Ship.GetUp()); return true; } else { // Inside ship positionAndOrientation = new MyMwcPositionAndOrientation(player.Ship.GetPosition(), player.Ship.GetForward(), player.Ship.GetUp()); return true; } } } positionAndOrientation = default(MyMwcPositionAndOrientation); return false; }
public MyMwcObjectBuilder_VoxelHand_Box(MyMwcPositionAndOrientation positionAndOrientation, float size, MyMwcVoxelHandModeTypeEnum voxelHandModeType) : base(positionAndOrientation, voxelHandModeType) { Size = size; Size3 = Size2 = size; //not fully supported yet }
public MyMwcObjectBuilder_VoxelHand_Sphere(MyMwcPositionAndOrientation positionAndOrientation, float radius, MyMwcVoxelHandModeTypeEnum voxelHandModeType) : base(positionAndOrientation, voxelHandModeType) { Radius = radius; }
protected MyMwcObjectBuilder_Object3dBase(MyMwcPositionAndOrientation positionAndOrientation) { PositionAndOrientation = positionAndOrientation; }
public MyMwcObjectBuilder_MysteriousCube(MyMwcPositionAndOrientation positionAndOrientation) : base(positionAndOrientation) { }
public static void SetVoxelProperties(MyVoxelHandShapeType voxelHandShapeType, float distance, MyMwcVoxelHandModeTypeEnum modeType, MyMwcVoxelMaterialsEnum? materialEnum, bool isProjected, bool isProjectedToWaypoints) { IsProjected = isProjected; IsProjectedToWaypoints = isProjectedToWaypoints; // same shape type if (voxelHandShapeType == MyEditorVoxelHand.VoxelHandShape.GetShapeType()) { //if ((size >= MyVoxelConstants.MIN_VOXEL_HAND_SIZE) && (size <= MyVoxelConstants.MAX_VOXEL_HAND_SIZE)) { //MyEditorVoxelHand.VoxelHandShape.SetShapeSize(size); //MyEditorVoxelHand.VoxelHandShape.SetShapeSize2(size2); //MyEditorVoxelHand.VoxelHandShape.SetShapeSize3(size3); MyEditorVoxelHand.VoxelHandShape.ModeType = modeType; MyEditorVoxelHand.VoxelHandShape.Material = materialEnum; } } // another shape type else { // float newShapeSize = size; // if ((newShapeSize < MyVoxelConstants.MIN_VOXEL_HAND_SIZE) && (newShapeSize > MyVoxelConstants.MAX_VOXEL_HAND_SIZE)) float newShapeSize = MyVoxelConstants.DEFAULT_VOXEL_HAND_SIZE; MyMwcPositionAndOrientation positionAndOritentation = new MyMwcPositionAndOrientation(MySpectator.Position, Vector3.Forward, Vector3.Up); switch (voxelHandShapeType) { case MyVoxelHandShapeType.Sphere: MyMwcObjectBuilder_VoxelHand_Sphere sphereObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Sphere(positionAndOritentation, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandSphere(); ((MyVoxelHandSphere)MyEditorVoxelHand.VoxelHandShape).Init(sphereObjectBuilder, null); break; case MyVoxelHandShapeType.Box: MyMwcObjectBuilder_VoxelHand_Box boxObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Box(positionAndOritentation, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandBox(); ((MyVoxelHandBox)MyEditorVoxelHand.VoxelHandShape).Init(boxObjectBuilder, null); break; case MyVoxelHandShapeType.Cuboid: MyMwcObjectBuilder_VoxelHand_Cuboid cuboidObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Cuboid(positionAndOritentation, newShapeSize, newShapeSize, newShapeSize, newShapeSize, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandCuboid(); ((MyVoxelHandCuboid)MyEditorVoxelHand.VoxelHandShape).Init(cuboidObjectBuilder, null); break; case MyVoxelHandShapeType.Cylinder: MyMwcObjectBuilder_VoxelHand_Cylinder cylinderObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Cylinder(positionAndOritentation, newShapeSize, newShapeSize, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandCylinder(); ((MyVoxelHandCylinder)MyEditorVoxelHand.VoxelHandShape).Init(cylinderObjectBuilder, null); break; default: System.Diagnostics.Debug.Assert(false); break; } MyEditorVoxelHand.VoxelHandShape.Material = materialEnum; } if (IsProjected) { if (!MyFakes.MWBUILDER) { if ((distance >= MyVoxelConstants.MIN_PROJECTED_VOXEL_HAND_OFFSET) && (distance <= MyVoxelConstants.MAX_PROJECTED_VOXEL_HAND_OFFSET)) MyEditorVoxelHand.SetShapeDistance(distance); } } else if (IsProjectedToWaypoints) { } else { if ((distance >= MyVoxelConstants.MIN_VOXEL_HAND_DISTANCE) && (distance <= MyVoxelConstants.MAX_VOXEL_HAND_DISTANCE)) MyEditorVoxelHand.SetShapeDistance(distance); } MyEditorVoxelHand.UpdateShapePosition(); }