public MyMwcObjectBuilder_PrefabBankNode(MyMwcObjectBuilder_PrefabBankNode_TypesEnum bankNodeType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, float cash) : base((int)bankNodeType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { Cash = cash; }
protected override void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType) { MyMwcLog.WriteLine("GAME AddPrefabItems - START"); Vector2 itemSize = MyGuiConstants.CHECKBOX_SIZE * 3; foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues) { foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue)) { MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId); MyGuiPrefabHelper prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper; if (config == null) { continue; } if (config.FactionSpecific.HasValue && config.FactionSpecific.Value != appearanceTextureEnum) { continue; } if (config.BuildType == buildType && config.CategoryType == categoryType && config.EnabledInEditor) { MyMwcObjectBuilder_PrefabBase prefabObjectBuilder = MyPrefabFactory.GetInstance().CreatePrefabObjectBuilder(enumValue, prefabId, appearanceTextureEnum); MyBuildingSpecification buildingSpecification = MyBuildingSpecifications.GetBuildingSpecification(prefabObjectBuilder); MyTexture2D previewTexture = MyGuiManager.GetPrefabPreviewTexture(enumValue, prefabId, appearanceTextureEnum); AddTreeViewItem(parentItem, prefabModuleHelper.Description, previewTexture, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE, prefabObjectBuilder, buildingSpecification); } } } MyMwcLog.WriteLine("GAME AddPrefabItems - END"); }
public PrefabTag(MyMwcObjectBuilderTypeEnum prefabModule, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum factionAppearance, CategoryTypesEnum categoryTypes) { PrefabModule = prefabModule; PrefabId = prefabId; FactionAppearance = factionAppearance; CategoryType = categoryTypes; }
public MyMwcObjectBuilder_PrefabScanner(MyMwcObjectBuilder_PrefabScanner_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, Vector3 size, Color color, float scanningSpeed/*, bool on*/) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { Size = size; Color = color; ScanningSpeed = scanningSpeed; }
public MyMwcObjectBuilder_PrefabGenerator(MyMwcObjectBuilder_PrefabGenerator_TypesEnum generatorType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, /*bool on,*/ float range) : base((int)generatorType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { //On = on; }
public MyMwcObjectBuilder_PrefabGenerator(MyMwcObjectBuilder_PrefabGenerator_TypesEnum generatorType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, /*bool on,*/ float range) : base((int)generatorType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { //On = on; }
public MyMwcObjectBuilder_PrefabBankNode(MyMwcObjectBuilder_PrefabBankNode_TypesEnum bankNodeType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, float cash) : base((int)bankNodeType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { Cash = cash; }
public MyMwcObjectBuilder_PrefabFoundationFactory(MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum foundationFactoryType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, bool isBuilding, int buildingTimeFromStart, MyMwcObjectBuilder_ObjectToBuild buildingObject, List <MyMwcObjectBuilder_ObjectToBuild> buildingQueue) : base((int)foundationFactoryType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { IsBuilding = isBuilding; BuildingTimeFromStart = buildingTimeFromStart; BuildingObject = buildingObject; BuildingQueue = buildingQueue; }
public MyMwcObjectBuilder_PrefabFoundationFactory(MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum foundationFactoryType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, bool isBuilding, int buildingTimeFromStart, MyMwcObjectBuilder_ObjectToBuild buildingObject, List<MyMwcObjectBuilder_ObjectToBuild> buildingQueue) : base((int)foundationFactoryType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { IsBuilding = isBuilding; BuildingTimeFromStart = buildingTimeFromStart; BuildingObject = buildingObject; BuildingQueue = buildingQueue; }
public MyPrefabConfigurationLargeWeapon( BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum weaponType, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 5, float explosionDamageMultiplier = 300) : base(buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, factionSpecific: factionSpecific, explosionType: explosionType, explosionRadiusMultiplier: explosionRadiusMultiplier, explosionDamageMultiplier: explosionDamageMultiplier, requiresEnergy: true, displayHud: true) { WeaponType = weaponType; }
protected void AddPrefabType(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, MyTextsWrapperEnum typeText, BuildTypesEnum buildTypesEnum, CategoryTypesEnum[] categories, MyTexture2D icon, Vector2 iconSize, MyTexture2D expand, MyTexture2D collapse, Vector2 expandIconSize) { var prefabTypeItem = parentItem == null? m_addObjectTreeView.AddItem(MyTextsWrapper.Get(typeText), icon, iconSize, expand, collapse, expandIconSize) : parentItem.AddItem(MyTextsWrapper.Get(typeText), icon, iconSize, expand, collapse, expandIconSize); foreach (var categoryTypesEnum in categories) { var categoryItem = prefabTypeItem.AddItem(MyGuiPrefabHelpers.GetMyGuiCategoryTypeHelper(categoryTypesEnum).Description, icon, iconSize, expand, collapse, expandIconSize); AddPrefabItems(categoryItem, appearanceTextureEnum, buildTypesEnum, categoryTypesEnum); } }
public MyPrefabConfigurationLargeShip( MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, MyModelsEnum? collisionModelEnum = null, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.BOMB_EXPLOSION, float particleScale = 1) : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.LargeShip, factionSpecific: factionSpecific, needsUpdate: true, collisionModelEnum: collisionModelEnum, explosionType: explosionType, explosionParticleEffectScale: particleScale) { }
public static StringBuilder GetFactionName(MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum) { switch (appearanceTextureEnum) { case MyMwcObjectBuilder_Prefab_AppearanceEnum.None: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionNeutralShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.FourthReich: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFourthReichShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.Chinese: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChineseShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.Euroamerican: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionEuroamericanShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.Omnicorp: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionOmnicorpShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.Russian: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussianShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.Church: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChurchShort); case MyMwcObjectBuilder_Prefab_AppearanceEnum.Saudi: return MyTextsWrapper.Get(MyTextsWrapperEnum.FactionSaudiShort); } return null; }
protected MyMwcObjectBuilder_PrefabBase(int prefabObjectBuilderId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, bool requiresEnergy = false) : this() { SetObjectBuilderId(prefabObjectBuilderId); //PrefabObjectBuilderId = prefabObjectBuilderId; FactionAppearance = appearance; PositionInContainer = position; AnglesInContainer = anglesInContainer; PrefabMaxHealth = prefabMaxHealth; PrefabHealthRatio = prefabHealthRatio; DisplayName = displayName; ElectricCapacity = electricCapacity; CausesAlarm = causesAlarm; RequiresEnergy = requiresEnergy; AIPriority = aiPriority; }
protected MyMwcObjectBuilder_PrefabBase(int prefabObjectBuilderId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, bool requiresEnergy = false) : this() { SetObjectBuilderId(prefabObjectBuilderId); //PrefabObjectBuilderId = prefabObjectBuilderId; FactionAppearance = appearance; PositionInContainer = position; AnglesInContainer = anglesInContainer; PrefabMaxHealth = prefabMaxHealth; PrefabHealthRatio = prefabHealthRatio; DisplayName = displayName; ElectricCapacity = electricCapacity; CausesAlarm = causesAlarm; RequiresEnergy = requiresEnergy; AIPriority = aiPriority; }
protected override void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType) { MyMwcLog.WriteLine("GOD AddPrefabItems - START"); Vector2 itemSize = MyGuiConstants.CHECKBOX_SIZE * 3; foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues) { foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue)) { MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId); MyGuiPrefabHelper prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper; if (config == null) continue; if (config.FactionSpecific.HasValue && config.FactionSpecific.Value != appearanceTextureEnum) continue; if (config.BuildType == buildType && config.CategoryType == categoryType && config.EnabledInEditor) { MyTexture2D previewTexture = MyGuiManager.GetPrefabPreviewTexture(enumValue, prefabId, appearanceTextureEnum); var item = parentItem.AddItem(new StringBuilder(), previewTexture, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE); item.ToolTip = GetPrefabToolTip(prefabModuleHelper.Description, config); //item.ToolTip = new MyToolTips(prefabModuleHelper.Description); item.Tag = new PrefabTag(enumValue, prefabId, appearanceTextureEnum, categoryType); item.Action = OnAddPrefab; item.DragDrop = m_addObjectTreeViewdragDrop; } } } MyMwcLog.WriteLine("GOD AddPrefabItems - END"); }
/// <summary> /// IMPORTANT: using Lod1Normals here, since this is done in a separate time to normal rendering /// </summary> public Texture RenderPrefabPreview(int prefabId, MyPrefabConfiguration config, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, int width, int height, float lightsIntensity = 2.5f) { m_fullSizeRT = MyRender.GetRenderTarget(MyRenderTargets.SSAO); if (m_fullSizeRT == null || MyGuiScreenGamePlay.Static == null) { return(null); } MyFakes.RENDER_PREVIEWS_WITH_CORRECT_ALPHA = true; Texture renderTarget = new Texture(MyMinerGame.Static.GraphicsDevice, width, height, 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); PrepareRender(width, height); MyRender.Sun.Intensity = lightsIntensity; foreach (var light in m_setup.LightsToUse) { light.Intensity = lightsIntensity; } if (MySession.PlayerShip != null) { MySession.PlayerShip.Visible = false; } bool weapon = false; if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY) { MyModel baseModel = null; MyModel barrelModel = null; Matrix baseMatrix = Matrix.Identity; Matrix barrelMatrix = Matrix.Identity; weapon = MyLargeShipGunBase.GetVisualPreviewData((MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum)prefabId, ref baseModel, ref barrelModel, ref baseMatrix, ref barrelMatrix); if (weapon) { m_setup.ViewMatrix = Matrix.Identity; SetupRenderElements(baseModel, baseMatrix, (int)appearance); SetupRenderElements(barrelModel, barrelMatrix, (int)appearance); SetupLights(baseModel); MyRender.PushRenderSetup(m_setup); MyRender.Draw(); MyRender.PopRenderSetup(); BlitToThumbnail(MyMinerGame.Static.GraphicsDevice, renderTarget); } } if (!weapon) { //load new model from prefab config MyModel model = MyModels.GetModelForDraw(config.ModelLod0Enum); float distanceMultiplier = 2f; Matrix viewMatrix = Matrix.Identity; m_setup.ViewMatrix = viewMatrix; //generate world matrix Matrix worldMatrix = Matrix.Identity; worldMatrix.Translation = -model.BoundingSphere.Center; worldMatrix *= config.PreviewPointOfView.Transform; worldMatrix *= Matrix.CreateRotationY(-.85f * MathHelper.PiOver4); worldMatrix *= Matrix.CreateRotationX(.35f * MathHelper.PiOver4); worldMatrix.Translation += new Vector3(0, 0, -model.BoundingSphere.Radius * distanceMultiplier); SetupRenderElements(model, worldMatrix, (int)appearance); SetupLights(model); //MyGuiManager.TakeScreenshot(); MyRender.PushRenderSetup(m_setup); MyRender.EnableShadows = false; MyRender.Draw(); MyRender.EnableShadows = true; MyRender.PopRenderSetup(); //MyGuiManager.StopTakingScreenshot(); BlitToThumbnail(MyMinerGame.Static.GraphicsDevice, renderTarget); } if (MySession.PlayerShip != null) { MySession.PlayerShip.Visible = true; } MyFakes.RENDER_PREVIEWS_WITH_CORRECT_ALPHA = false; return(renderTarget); }
public MyMwcObjectBuilder_PrefabScanner(MyMwcObjectBuilder_PrefabScanner_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, Vector3 size, Color color, float scanningSpeed /*, bool on*/) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { Size = size; Color = color; ScanningSpeed = scanningSpeed; }
protected void AddPrefabType(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, MyTextsWrapperEnum typeText, BuildTypesEnum buildTypesEnum, CategoryTypesEnum[] categories, MyTexture2D icon, Vector2 iconSize, MyTexture2D expand, MyTexture2D collapse, Vector2 expandIconSize) { var prefabTypeItem = parentItem == null ? m_addObjectTreeView.AddItem(MyTextsWrapper.Get(typeText), icon, iconSize, expand, collapse, expandIconSize) : parentItem.AddItem(MyTextsWrapper.Get(typeText), icon, iconSize, expand, collapse, expandIconSize); foreach (var categoryTypesEnum in categories) { var categoryItem = prefabTypeItem.AddItem(MyGuiPrefabHelpers.GetMyGuiCategoryTypeHelper(categoryTypesEnum).Description, icon, iconSize, expand, collapse, expandIconSize); AddPrefabItems(categoryItem, appearanceTextureEnum, buildTypesEnum, categoryTypesEnum); } }
/// <summary> /// Returns true if this prefab has available textures for specific factions. /// Large ship prefabs, large weapon prefabs and the CUSTOM object don't. /// This is dependent on artists. Would be better if this was read /// </summary> public bool HasAvailableFactionMaterial(MyMwcObjectBuilder_Prefab_AppearanceEnum material) { var factionSpecific = m_config.FactionSpecific; bool hasMaterialForAllFactions = !factionSpecific.HasValue; return hasMaterialForAllFactions || factionSpecific.Value == material; }
/// <summary> /// CreatePrefabObjectBuilder /// </summary> /// <param name="prefabCategory"></param> /// <returns></returns> public MyMwcObjectBuilder_PrefabBase CreatePrefabObjectBuilder(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum textureEnum) { MyGameplayProperties gameplayProperties = MyGameplayConstants.GetGameplayProperties(prefabType, prefabId, MyMwcObjectBuilder_FactionEnum.Euroamerican); MyPrefabConfiguration prefabConfig = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId); MyMwcVector3Short pos = new MyMwcVector3Short(0, 0, 0); MyMwcObjectBuilder_PrefabBase objBuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabType, prefabId) as MyMwcObjectBuilder_PrefabBase; objBuilder.PositionInContainer = pos; objBuilder.AnglesInContainer = Vector3.Zero; objBuilder.PrefabHealthRatio = MyGameplayConstants.HEALTH_RATIO_MAX; objBuilder.PrefabMaxHealth = null; objBuilder.FactionAppearance = textureEnum; objBuilder.IsDestructible = gameplayProperties.IsDestructible; if (prefabConfig.DisplayHud) { objBuilder.PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud; } return(objBuilder); }
private bool Read_01085000(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion) { // PrefabType int?prefabObjectBuilderId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint); if (prefabObjectBuilderId == null) { return(NetworkError()); } PrefabObjectBuilderId = prefabObjectBuilderId.Value; MyMwcLog.IfNetVerbose_AddToLog("PrefabObjectBuilderId: " + PrefabObjectBuilderId); // PositionInContainer MyMwcVector3Short?positionInContainer = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint); if (positionInContainer == null) { return(NetworkError()); } PositionInContainer = positionInContainer.Value; MyMwcLog.IfNetVerbose_AddToLog("PositionInContainer: " + PositionInContainer); // AnglesInContainer Vector3?anglesInContainer = MyMwcMessageIn.ReadVector3FloatEx(binaryReader, senderEndPoint); if (anglesInContainer == null) { return(NetworkError()); } AnglesInContainer = anglesInContainer.Value; MyMwcLog.IfNetVerbose_AddToLog("AnglesInContainer: " + AnglesInContainer.ToString()); bool?hasMaxHealth = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasMaxHealth.HasValue) { return(NetworkError()); } if (hasMaxHealth.Value) { // PrefabMaxHealth float?prefabMaxHealth = MyMwcMessageIn.ReadFloat(binaryReader); if (prefabMaxHealth == null) { return(NetworkError()); } PrefabMaxHealth = prefabMaxHealth.Value; MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth: " + PrefabMaxHealth.Value.ToString()); if (float.IsNaN(PrefabMaxHealth.Value) || float.IsInfinity(PrefabMaxHealth.Value)) { System.Diagnostics.Debug.Fail("PrefabMaxHealth is: " + PrefabMaxHealth.Value); PrefabMaxHealth = null; // MyGameplayConstants.MAX_HEALTH_MAX; } } else { MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth is: null"); PrefabMaxHealth = null; } // PrefabHealthRatio float?prefabHealthRatio = MyMwcMessageIn.ReadFloat(binaryReader); if (prefabHealthRatio == null) { return(NetworkError()); } PrefabHealthRatio = prefabHealthRatio.Value; MyMwcLog.IfNetVerbose_AddToLog("PrefabHealth: " + PrefabHealthRatio.ToString()); bool?hasDisplayName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasDisplayName.HasValue) { return(NetworkError()); } if (hasDisplayName.Value) { string displayName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint); if (displayName == null) { return(NetworkError()); } MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + displayName); DisplayName = displayName; } else { MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + "null"); DisplayName = null; } // faction appearance (texture set) short?factionAppearance = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint); if (!factionAppearance.HasValue) { return(NetworkError()); } FactionAppearance = (MyMwcObjectBuilder_Prefab_AppearanceEnum)factionAppearance.Value; MyMwcLog.IfNetVerbose_AddToLog("FactionAppearance: " + FactionAppearance); // Use Properties bool?hasUseProperties = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (hasUseProperties == null) { return(NetworkError()); } if (hasUseProperties.Value) { UseProperties = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_EntityUseProperties; if (UseProperties == null) { return(NetworkError()); } if (UseProperties.Read(binaryReader, senderEndPoint, gameVersion) == false) { return(NetworkError()); } } else { UseProperties = null; } // Causes Alarm bool?hasCausesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasCausesAlarm.HasValue) { return(NetworkError()); } if (hasCausesAlarm.Value) { bool?causesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!causesAlarm.HasValue) { return(NetworkError()); } MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + CausesAlarm); CausesAlarm = causesAlarm.Value; } else { MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + "null"); CausesAlarm = null; } // Requires Energy bool?hasRequiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasRequiresEnergy.HasValue) { return(NetworkError()); } if (hasRequiresEnergy.Value) { bool?requiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!requiresEnergy.HasValue) { return(NetworkError()); } MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + RequiresEnergy); RequiresEnergy = requiresEnergy.Value; } else { MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + "null"); RequiresEnergy = null; } // Display HUD bool?hasDisplayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasDisplayHud.HasValue) { return(NetworkError()); } if (hasDisplayHud.Value) { bool?displayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!displayHud.HasValue) { return(NetworkError()); } if (displayHud.Value) { PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud; } else { PersistentFlags &= ~MyPersistentEntityFlags.DisplayOnHud; } MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + displayHud.Value); } else { MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + "null"); } // AI Priority int?aiPriority = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint); if (aiPriority == null) { return(NetworkError()); } AIPriority = aiPriority.Value; MyMwcLog.IfNetVerbose_AddToLog("AIPriority: " + AIPriority); return(true); }
public MyMwcObjectBuilder_PrefabSecurityControlHUB(MyMwcObjectBuilder_PrefabHangar_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, List<uint> connectedEntities, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority, true) { ConnectedEntities = connectedEntities; }
public MyMwcObjectBuilder_PrefabSecurityControlHUB(MyMwcObjectBuilder_PrefabHangar_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, List <uint> connectedEntities, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority, true) { ConnectedEntities = connectedEntities; }
public MyMwcObjectBuilder_PrefabKinematicPart(MyMwcObjectBuilder_PrefabKinematicPart_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { }
public MyMwcObjectBuilder_PrefabKinematicPart(MyMwcObjectBuilder_PrefabKinematicPart_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { }
/// <summary> /// IMPORTANT: using Lod1Normals here, since this is done in a separate time to normal rendering /// </summary> public Texture RenderPrefabPreview(int prefabId, MyPrefabConfiguration config, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, int width, int height, float lightsIntensity = 2.5f) { m_fullSizeRT = MyRender.GetRenderTarget(MyRenderTargets.SSAO); if (m_fullSizeRT == null || MyGuiScreenGamePlay.Static == null) { return null; } MyFakes.RENDER_PREVIEWS_WITH_CORRECT_ALPHA = true; Texture renderTarget = new Texture(MyMinerGame.Static.GraphicsDevice, width, height, 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); PrepareRender(width, height); MyRender.Sun.Intensity = lightsIntensity; foreach (var light in m_setup.LightsToUse) { light.Intensity = lightsIntensity; } if (MySession.PlayerShip != null) { MySession.PlayerShip.Visible = false; } bool weapon = false; if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY) { MyModel baseModel = null; MyModel barrelModel = null; Matrix baseMatrix = Matrix.Identity; Matrix barrelMatrix = Matrix.Identity; weapon = MyLargeShipGunBase.GetVisualPreviewData((MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum)prefabId, ref baseModel, ref barrelModel, ref baseMatrix, ref barrelMatrix); if (weapon) { m_setup.ViewMatrix = Matrix.Identity; SetupRenderElements(baseModel, baseMatrix, (int) appearance); SetupRenderElements(barrelModel, barrelMatrix, (int)appearance); SetupLights(baseModel); MyRender.PushRenderSetup(m_setup); MyRender.Draw(); MyRender.PopRenderSetup(); BlitToThumbnail(MyMinerGame.Static.GraphicsDevice, renderTarget); } } if (!weapon) { //load new model from prefab config MyModel model = MyModels.GetModelForDraw(config.ModelLod0Enum); float distanceMultiplier = 2f; Matrix viewMatrix = Matrix.Identity; m_setup.ViewMatrix = viewMatrix; //generate world matrix Matrix worldMatrix = Matrix.Identity; worldMatrix.Translation = -model.BoundingSphere.Center; worldMatrix *= config.PreviewPointOfView.Transform; worldMatrix *= Matrix.CreateRotationY(-.85f * MathHelper.PiOver4); worldMatrix *= Matrix.CreateRotationX(.35f * MathHelper.PiOver4); worldMatrix.Translation += new Vector3(0, 0, -model.BoundingSphere.Radius * distanceMultiplier); SetupRenderElements(model, worldMatrix, (int)appearance); SetupLights(model); //MyGuiManager.TakeScreenshot(); MyRender.PushRenderSetup(m_setup); MyRender.EnableShadows = false; MyRender.Draw(); MyRender.EnableShadows = true; MyRender.PopRenderSetup(); //MyGuiManager.StopTakingScreenshot(); BlitToThumbnail(MyMinerGame.Static.GraphicsDevice, renderTarget); } if (MySession.PlayerShip != null) { MySession.PlayerShip.Visible = true; } MyFakes.RENDER_PREVIEWS_WITH_CORRECT_ALPHA = false; return renderTarget; }
protected abstract void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType);
public static void AddPrefabPreview(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyTexture2D texture) { if (m_prefabPreviews[(int)prefabType] == null) { m_prefabPreviews[(int)prefabType] = new MyTexture2D[MyMwcObjectBuilder_Base.GetObjectBuilderIDs(prefabType).Max() + 1][]; } if (m_prefabPreviews[(int)prefabType][prefabId] == null) { m_prefabPreviews[(int)prefabType][prefabId] = new MyTexture2D[MyGuiPrefabHelpers.MyMwcFactionTextureEnumValues.Length]; } m_prefabPreviews[(int)prefabType][prefabId][(ushort)appearance] = texture; }
protected abstract void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType);
/// <summary> /// Creates new instance of prefab configuration /// </summary> /// <param name="modelLod0Enum">Model LOD0</param> /// <param name="modelLod1Enum">Model LOD2</param> /// <param name="buildType">Build type</param> /// <param name="categoryType">Category type</param> /// <param name="subCategoryType">Subcategory type</param> /// <param name="materialType">Material type</param> /// <param name="prefabTypeFlag">Prefab type flags</param> protected MyPrefabConfiguration( MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, MyModelsEnum? collisionModelEnum = null, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, bool needsUpdate = false, bool initPhysics = true, bool enabledInEditor = true, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MySoundCuesEnum? startRotatingCue = null, MySoundCuesEnum? loopRotatingCue = null, MySoundCuesEnum? loopRotatingDamagedCue = null, MySoundCuesEnum? endRotatingCue = null, MyPreviewPointOfViewEnum previewAngle = MyPreviewPointOfViewEnum.Front, float minElectricCapacity = MyGameplayConstants.DEFAULT_MIN_ELECTRIC_CAPACITY, float maxElectricCapacity = MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 1, float explosionDamage = 1, float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS, bool causesAlarm = false, bool requiresEnergy = false, float explosionParticleEffectScale = 1, bool displayHud = false) : this(buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, factionSpecific, needsUpdate, initPhysics, enabledInEditor, rotatingVelocity, startRotatingCue, loopRotatingCue, loopRotatingDamagedCue, endRotatingCue, previewAngle, minElectricCapacity, maxElectricCapacity, explosionType, explosionRadiusMultiplier, explosionDamage, minSizeForExplosion, causesAlarm, requiresEnergy: requiresEnergy, explosionParticleEffectScale: explosionParticleEffectScale, displayHud: displayHud) { m_modelLod0Enum = modelLod0Enum; m_modelLod1Enum = modelLod1Enum; m_collisionModelEnum = collisionModelEnum; }
private static MyTexture2D GetPrefabPreview(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance) { MyTexture2D texture = null; // TODO: Wouldn't be better to use compound key? (for example long when int would be too small) if (m_prefabPreviews != null && m_prefabPreviews[(int)prefabType] != null && m_prefabPreviews[(int)prefabType][prefabId] != null) { texture = m_prefabPreviews[(int)prefabType][prefabId][(ushort)appearance]; } return texture; }
/// <summary> /// Creates new instance of prefab configuration with default prefab type flags /// </summary> /// <param name="modelLod0Enum">Model LOD0</param> /// <param name="modelLod1Enum">Model LOD2</param> /// <param name="buildType">Build type</param> /// <param name="categoryType">Category type</param> /// <param name="subCategoryType">Subcategory type</param> /// <param name="materialType">Material type</param> /// <param name="factionSpecific">To which faction is this prefab specific. Null if prefab is for all factions. Used for material (texture) set availability. </param> public MyPrefabConfiguration( MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, MyModelsEnum? collisionModelEnum = null, bool needsUpdate = false, bool initPhysics = true, bool enabledInEditor = true, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MySoundCuesEnum? startRotatingCue = null, MySoundCuesEnum? loopRotatingCue = null, MySoundCuesEnum? loopRotatingDamagedCue = null, MySoundCuesEnum? endRotatingCue = null, MyPreviewPointOfViewEnum previewAngle = MyPreviewPointOfViewEnum.Front, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 1, float explosionDamageMultiplier = 1, float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS, bool causesAlarm = false, bool requiresEnergy = false, float explosionParticleEffectScale = 1, bool displayHud = false) : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, collisionModelEnum, factionSpecific, needsUpdate, initPhysics, enabledInEditor, rotatingVelocity, startRotatingCue, loopRotatingCue, loopRotatingDamagedCue, endRotatingCue, previewAngle, explosionType: explosionType, explosionRadiusMultiplier: explosionRadiusMultiplier, explosionDamage: explosionDamageMultiplier, minSizeForExplosion: minSizeForExplosion, causesAlarm: causesAlarm, requiresEnergy: requiresEnergy, explosionParticleEffectScale: explosionParticleEffectScale, displayHud: displayHud) { System.Diagnostics.Debug.Assert(modelLod0Enum != modelLod1Enum, "LOD0 and LOD1 models are the same!"); if (collisionModelEnum != null) { System.Diagnostics.Debug.Assert(modelLod0Enum != collisionModelEnum, "LOD0 and COL models are the same!"); System.Diagnostics.Debug.Assert(modelLod1Enum != collisionModelEnum, "LOD1 and COL models are the same!"); } }
/// <summary> /// CreatePrefabObjectBuilder /// </summary> /// <param name="prefabCategory"></param> /// <returns></returns> public MyMwcObjectBuilder_PrefabBase CreatePrefabObjectBuilder(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum textureEnum) { MyGameplayProperties gameplayProperties = MyGameplayConstants.GetGameplayProperties(prefabType, prefabId, MyMwcObjectBuilder_FactionEnum.Euroamerican); MyPrefabConfiguration prefabConfig = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId); MyMwcVector3Short pos = new MyMwcVector3Short(0, 0, 0); MyMwcObjectBuilder_PrefabBase objBuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabType, prefabId) as MyMwcObjectBuilder_PrefabBase; objBuilder.PositionInContainer = pos; objBuilder.AnglesInContainer = Vector3.Zero; objBuilder.PrefabHealthRatio = MyGameplayConstants.HEALTH_RATIO_MAX; objBuilder.PrefabMaxHealth = null; objBuilder.FactionAppearance = textureEnum; objBuilder.IsDestructible = gameplayProperties.IsDestructible; if (prefabConfig.DisplayHud) { objBuilder.PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud; } return objBuilder; }
/// <summary> /// Creates new instance of prefab configuration without model /// </summary> /// <param name="buildType">Build type</param> /// <param name="categoryType">Category type</param> /// <param name="subCategoryType">Subcategory type</param> /// <param name="materialType">Material type</param> /// <param name="prefabTypeFlag">Prefab type flags</param> /// <param name="factionSpecific">To which faction is this prefab specific. Null if prefab is for all factions. Used for material (texture) set availability. </param> /// <param name="previewPointOfView">Indicates whether the preview image for this prefab should be from a different angle than normal. Use for flat objects that have incorrect default previews (such as signs). </param> protected MyPrefabConfiguration( BuildTypesEnum buildType, CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null, bool needsUpdate = false, bool initPhysics = true, bool enabledInEditor = true, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MySoundCuesEnum? startRotatingCue = null, MySoundCuesEnum? loopRotatingCue = null, MySoundCuesEnum? loopRotatingDamagedCue = null, MySoundCuesEnum? endRotatingCue = null, MyPreviewPointOfViewEnum previewPointOfView = MyPreviewPointOfViewEnum.Front, float minElectricCapacity = MyGameplayConstants.DEFAULT_MIN_ELECTRIC_CAPACITY, float maxElectricCapacity = MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY, MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION, float explosionRadiusMultiplier = 1.5f, float explosionDamageMultiplier = 1, float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS, bool causesAlarm = false, bool requiresEnergy = false, float explosionParticleEffectScale = 1, bool displayHud = false) { //m_modelLod0Enum = null; m_modelLod1Enum = null; BuildType = buildType; CategoryType = categoryType; SubCategoryType = subCategoryType; MaterialType = materialType; PrefabTypeFlag = prefabTypeFlag; FactionSpecific = factionSpecific; EnabledInEditor = enabledInEditor; RotatingVelocity = rotatingVelocity; StartRotatingCue = startRotatingCue; LoopRotatingCue = loopRotatingCue; LoopRotatingDamagedCue = loopRotatingDamagedCue; EndRotatingCue = endRotatingCue; PreviewPointOfView = new MyPreviewPointOfView(previewPointOfView); MinElectricCapacity = minElectricCapacity; MaxElectricCapacity = maxElectricCapacity; NeedsUpdate = needsUpdate; InitPhysics = initPhysics; ExplosionType = explosionType; ExplosionRadiusMultiplier = explosionRadiusMultiplier; ExplosionDamage = explosionDamageMultiplier; ExplosionParticleEffectScale = explosionParticleEffectScale; MinSizeForExplosion = minSizeForExplosion; CausesAlarm = causesAlarm; RequiresEnergy = requiresEnergy; DisplayHud = displayHud; }
public MyMwcObjectBuilder_PrefabLargeWeapon(MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, float aimingDistance, float searchingDistance, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { AimingDistance = aimingDistance; SearchingDistance = searchingDistance; }
private bool Read_01085000(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion) { // PrefabType int? prefabObjectBuilderId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint); if (prefabObjectBuilderId == null) return NetworkError(); PrefabObjectBuilderId = prefabObjectBuilderId.Value; MyMwcLog.IfNetVerbose_AddToLog("PrefabObjectBuilderId: " + PrefabObjectBuilderId); // PositionInContainer MyMwcVector3Short? positionInContainer = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint); if (positionInContainer == null) return NetworkError(); PositionInContainer = positionInContainer.Value; MyMwcLog.IfNetVerbose_AddToLog("PositionInContainer: " + PositionInContainer); // AnglesInContainer Vector3? anglesInContainer = MyMwcMessageIn.ReadVector3FloatEx(binaryReader, senderEndPoint); if (anglesInContainer == null) return NetworkError(); AnglesInContainer = anglesInContainer.Value; MyMwcLog.IfNetVerbose_AddToLog("AnglesInContainer: " + AnglesInContainer.ToString()); bool? hasMaxHealth = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasMaxHealth.HasValue) return NetworkError(); if (hasMaxHealth.Value) { // PrefabMaxHealth float? prefabMaxHealth = MyMwcMessageIn.ReadFloat(binaryReader); if (prefabMaxHealth == null) return NetworkError(); PrefabMaxHealth = prefabMaxHealth.Value; MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth: " + PrefabMaxHealth.Value.ToString()); if (float.IsNaN(PrefabMaxHealth.Value) || float.IsInfinity(PrefabMaxHealth.Value)) { System.Diagnostics.Debug.Fail("PrefabMaxHealth is: " + PrefabMaxHealth.Value); PrefabMaxHealth = null; // MyGameplayConstants.MAX_HEALTH_MAX; } } else { MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth is: null"); PrefabMaxHealth = null; } // PrefabHealthRatio float? prefabHealthRatio = MyMwcMessageIn.ReadFloat(binaryReader); if (prefabHealthRatio == null) return NetworkError(); PrefabHealthRatio = prefabHealthRatio.Value; MyMwcLog.IfNetVerbose_AddToLog("PrefabHealth: " + PrefabHealthRatio.ToString()); bool? hasDisplayName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasDisplayName.HasValue) return NetworkError(); if (hasDisplayName.Value) { string displayName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint); if (displayName == null) return NetworkError(); MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + displayName); DisplayName = displayName; } else { MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + "null"); DisplayName = null; } // faction appearance (texture set) short? factionAppearance = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint); if (!factionAppearance.HasValue) return NetworkError(); FactionAppearance = (MyMwcObjectBuilder_Prefab_AppearanceEnum) factionAppearance.Value; MyMwcLog.IfNetVerbose_AddToLog("FactionAppearance: " + FactionAppearance); // Use Properties bool? hasUseProperties = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (hasUseProperties == null) return NetworkError(); if (hasUseProperties.Value) { UseProperties = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_EntityUseProperties; if (UseProperties == null) return NetworkError(); if (UseProperties.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError(); } else { UseProperties = null; } // Causes Alarm bool? hasCausesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasCausesAlarm.HasValue) return NetworkError(); if (hasCausesAlarm.Value) { bool? causesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!causesAlarm.HasValue) return NetworkError(); MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + CausesAlarm); CausesAlarm = causesAlarm.Value; } else { MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + "null"); CausesAlarm = null; } // Requires Energy bool? hasRequiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasRequiresEnergy.HasValue) return NetworkError(); if (hasRequiresEnergy.Value) { bool? requiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!requiresEnergy.HasValue) return NetworkError(); MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + RequiresEnergy); RequiresEnergy = requiresEnergy.Value; } else { MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + "null"); RequiresEnergy = null; } // Display HUD bool? hasDisplayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!hasDisplayHud.HasValue) return NetworkError(); if (hasDisplayHud.Value) { bool? displayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint); if (!displayHud.HasValue) return NetworkError(); if (displayHud.Value) PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud; else PersistentFlags &= ~MyPersistentEntityFlags.DisplayOnHud; MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + displayHud.Value); } else { MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + "null"); } // AI Priority int? aiPriority = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint); if (aiPriority == null) return NetworkError(); AIPriority = aiPriority.Value; MyMwcLog.IfNetVerbose_AddToLog("AIPriority: " + AIPriority); return true; }
public MyMwcObjectBuilder_PrefabLargeWeapon(MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, float aimingDistance, float searchingDistance, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { AimingDistance = aimingDistance; SearchingDistance = searchingDistance; }
/// <summary> /// c-tor /// </summary> /// <param name="prefabType"></param> /// <param name="position"></param> /// <param name="anglesInContainer"></param> public MyMwcObjectBuilder_PrefabLight(MyMwcObjectBuilder_PrefabLight_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { PointFalloff = SpotFalloff = 1.0f; PointIntensity = SpotIntensity = 1.0f; SpotRange = SpotRange = 100.0f; PointColor = SpotColor = new Vector4(1, 1, 1, 1); PointSpecular = SpotSpecular = new Vector3(0, 0, 0); PointOffset = 0; Effect = MyLightEffectTypeEnum.NORMAL; SpotAgle = 1; ShadowsDistance = 200; }
/// <summary> /// c-tor /// </summary> /// <param name="prefabType"></param> /// <param name="position"></param> /// <param name="anglesInContainer"></param> public MyMwcObjectBuilder_PrefabLight(MyMwcObjectBuilder_PrefabLight_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority) : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority) { PointFalloff = SpotFalloff = 1.0f; PointIntensity = SpotIntensity = 1.0f; SpotRange = SpotRange = 100.0f; PointColor = SpotColor = new Vector4(1, 1, 1, 1); PointSpecular = SpotSpecular = new Vector3(0, 0, 0); PointOffset = 0; Effect = MyLightEffectTypeEnum.NORMAL; SpotAgle = 1; ShadowsDistance = 200; }
/// <summary> /// Gets the prefab preview (thumbnail) texture. /// </summary> /// <param name="enumValue">Specifies the prefab type.</param> public static MyTexture2D GetPrefabPreviewTexture(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance) { MyTexture2D texture = GetPrefabPreview(prefabType, prefabId, appearance); if (texture == null || texture.LoadState == LoadState.Error) { //TODO /* MyMwcLog.WriteLine("Failed to load prefab preview from disk: " + prefabType + " - " + prefabId + ", faction " + appearance + ". Rendering it on-the-fly."); MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId); try { Texture preview = m_previewRenderer.RenderPrefabPreview(prefabId, config, appearance, MyHudConstants.PREFAB_PREVIEW_SIZE, MyHudConstants.PREFAB_PREVIEW_SIZE); if (preview != null) { texture = preview; AddPrefabPreview(prefabType, prefabId, appearance, preview); } } catch (Exception e) { Debug.Assert(false, "Render preview failed " + e.Message); MyMwcLog.WriteLine("Render preview failed"); MyMwcLog.WriteLine(e.ToString()); } */ } return texture; }