public MyInventoryItemAmountDefinition(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId, float originalAmount, float amountChange) { ObjectBuilderType = objectBuilderType; ObjectBuilderId = objectBuilderId; OriginalAmount = originalAmount; AmountChange = amountChange; }
public MyInventoryItemAmountDefinition(MyMwcObjectBuilderTypeEnum objectBuilderType, int? objectBuilderId, float originalAmount, float amountChange) { ObjectBuilderType = objectBuilderType; ObjectBuilderId = objectBuilderId; OriginalAmount = originalAmount; AmountChange = amountChange; }
public PrefabTag(MyMwcObjectBuilderTypeEnum prefabModule, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum factionAppearance, CategoryTypesEnum categoryTypes) { PrefabModule = prefabModule; PrefabId = prefabId; FactionAppearance = factionAppearance; CategoryType = categoryTypes; }
public static bool IsDisabled(MyMwcObjectBuilder_InventoryItem inventoryItem) { int?builderId = inventoryItem.ItemObjectBuilder.GetObjectBuilderId(); MyMwcObjectBuilderTypeEnum builderType = inventoryItem.ItemObjectBuilder.GetObjectBuilderType(); return(IsDisabled(builderType, builderId)); }
public void Init(MyPrefabBase kinematicPartOwner, MyMwcObjectBuilderTypeEnum prefabKinematicPartBuilderType, int? prefabKinematicPartBuilderId, MyModelsEnum modelEnum, MyMaterialType materialType, Matrix kinematicLocalMatrix, float kinematicVelocityMax, MySoundCuesEnum? loopSound, MySoundCuesEnum? loopDamagedSound, MySoundCuesEnum? startSound, MySoundCuesEnum? endSound, float kinematicStart, float kinematicEnd) { m_needsUpdate = true; m_kinematicPartOwner = kinematicPartOwner; m_kinematicLocalMatrix = kinematicLocalMatrix; m_kinematicVelocityMax = kinematicVelocityMax; m_kinematicStart = kinematicStart; m_kinematicEnd = kinematicEnd; m_loopSoundCue = loopSound; m_loopDamagedSoundCue = loopDamagedSound; m_startSoundCue = startSound; m_endSoundCue = endSound; MyMwcObjectBuilder_Base objbuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabKinematicPartBuilderType, prefabKinematicPartBuilderId); m_config = m_kinematicPartOwner.GetConfiguration(); base.Init(null, modelEnum, null, kinematicPartOwner, null, objbuilder); LocalMatrix = Matrix.Identity; MaterialIndex = m_kinematicPartOwner.MaterialIndex; //InitTrianglePhysics(materialType, 1.0f, ModelLod0, null, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART); InitBoxPhysics(materialType, ModelLod0, 100, 0, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART, RigidBodyFlag.RBF_RBO_STATIC); Physics.Enabled = true; m_kinematicPartOwner.OnPositionChanged += OwnerPositionChanged; }
public void Init(MyPrefabBase kinematicPartOwner, MyMwcObjectBuilderTypeEnum prefabKinematicPartBuilderType, int?prefabKinematicPartBuilderId, MyModelsEnum modelEnum, MyMaterialType materialType, Matrix kinematicLocalMatrix, float kinematicVelocityMax, MySoundCuesEnum?loopSound, MySoundCuesEnum?loopDamagedSound, MySoundCuesEnum?startSound, MySoundCuesEnum?endSound, float kinematicStart, float kinematicEnd) { m_needsUpdate = true; m_kinematicPartOwner = kinematicPartOwner; m_kinematicLocalMatrix = kinematicLocalMatrix; m_kinematicVelocityMax = kinematicVelocityMax; m_kinematicStart = kinematicStart; m_kinematicEnd = kinematicEnd; m_loopSoundCue = loopSound; m_loopDamagedSoundCue = loopDamagedSound; m_startSoundCue = startSound; m_endSoundCue = endSound; MyMwcObjectBuilder_Base objbuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabKinematicPartBuilderType, prefabKinematicPartBuilderId); m_config = m_kinematicPartOwner.GetConfiguration(); base.Init(null, modelEnum, null, kinematicPartOwner, null, objbuilder); LocalMatrix = Matrix.Identity; MaterialIndex = m_kinematicPartOwner.MaterialIndex; //InitTrianglePhysics(materialType, 1.0f, ModelLod0, null, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART); InitBoxPhysics(materialType, ModelLod0, 100, 0, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART, RigidBodyFlag.RBF_RBO_STATIC); Physics.Enabled = true; m_kinematicPartOwner.OnPositionChanged += OwnerPositionChanged; }
public static void AddGuiHelper(MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderID, MyGuiHelperBase guiHelper) { if (m_buildTypeHelpers[(int)objectBuilderType] == null) { m_buildTypeHelpers[(int)objectBuilderType] = new MyGuiHelperBase[MyMwcObjectBuilder_Base.GetObjectBuilderIDs(objectBuilderType).Max() + 1]; } m_buildTypeHelpers[(int) objectBuilderType][objectBuilderID] = guiHelper; }
/// <summary> /// Creates new instance of inventory item requirement /// </summary> /// <param name="objectBuilderType"></param> /// <param name="objectBuilderId"></param> /// <param name="amount"></param> /// <param name="removeAfterBuild"></param> public MyBuildingRequirementInventoryItem(MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderId, float amount, bool removeAfterBuild) { ObjectBuilderType = objectBuilderType; ObjectBuilderId = objectBuilderId; Amount = amount; RemoveAfterBuild = removeAfterBuild; m_description = new StringBuilder(); }
/// <summary> /// Find inventory items in inventory /// </summary> /// <param name="inventoryItems">Collection to fill founded inventory items</param> /// <param name="objectBuilderType">Item's object builder type</param> /// <param name="objectBuilderId">Item's object builder Id</param> /// <returns></returns> public void GetInventoryItems(ref List <MyInventoryItem> inventoryItems, MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId) { foreach (MyInventoryItem inventoryItem in m_inventoryItems) { if (inventoryItem.ObjectBuilderType == objectBuilderType && (objectBuilderId == null || inventoryItem.ObjectBuilderId == objectBuilderId)) { inventoryItems.Add(inventoryItem); } } }
/// <summary> /// Returns first inventory item from inventory /// </summary> /// <param name="objectBuilderType">Item's object builder type</param> /// <param name="objectBuilderId">Item's object builder id</param> /// <returns></returns> public MyInventoryItem GetInventoryItem(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId) { m_helperInventoryItems.Clear(); GetInventoryItems(ref m_helperInventoryItems, objectBuilderType, objectBuilderId); if (m_helperInventoryItems.Count > 0) { return(m_helperInventoryItems[0]); } else { return(null); } }
/// <summary> /// Returns total amount of inventory items in inventory /// </summary> /// <param name="objectBuilderType">Item's object builder type</param> /// <param name="objectBuilderId">Item's object builder id</param> /// <returns></returns> public float GetTotalAmountOfInventoryItems(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId) { m_helperInventoryItems.Clear(); GetInventoryItems(ref m_helperInventoryItems, objectBuilderType, objectBuilderId); float inventoryItemsAmount = 0; foreach (MyInventoryItem inventoryItem in m_helperInventoryItems) { inventoryItemsAmount += inventoryItem.Amount; } return(inventoryItemsAmount); }
/// <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> /// Returns inventory items from inventory /// </summary> /// <param name="objectBuilderType">Item's object builder type</param> /// <param name="objectBuilderId">Item's object builder id</param> /// <param name="amount">Amount to remove</param> public bool RemoveInventoryItemAmount(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId, float amount) { bool removed = false; float inventoryItemsAmount = GetTotalAmountOfInventoryItems(objectBuilderType, objectBuilderId); if (inventoryItemsAmount < amount) { return(false); } float amountToRemoveLeft = amount; m_helperInventoryItemsForAddAndRemove.Clear(); GetInventoryItems(ref m_helperInventoryItemsForAddAndRemove, objectBuilderType, objectBuilderId); m_helperInventoryItemsForAddAndRemove.Sort((x, y) => x.Amount.CompareTo(y.Amount)); foreach (MyInventoryItem inventoryItem in m_helperInventoryItemsForAddAndRemove) { float amountToRemove = Math.Min(inventoryItem.Amount, amountToRemoveLeft); MyInventoryItem inventoryItemToRemoveAmount = inventoryItem; if (RemoveInventoryItemAmountPrivate(inventoryItemToRemoveAmount, amountToRemove)) { removed = true; } amountToRemoveLeft -= amountToRemove; if (amountToRemoveLeft <= 0f) { break; } } if (removed) { CallContentChange(); } return(true); }
public static bool IsDisabled(MyMwcObjectBuilderTypeEnum builderType, int?builderId) { if (DisabledItems.ContainsKey((int)builderType)) { List <int> disabledIds = DisabledItems[(int)builderType]; if (disabledIds == null) { return(builderId == null); } else { if (builderId != null) { return(disabledIds.Contains(builderId.Value)); } else { return(false); } } } return(false); }
/// <summary> /// Returns inventory item's count /// </summary> /// <param name="objectBuilderType">Item's object builder type</param> /// <param name="objectBuilderId">Item's object builde id</param> /// <returns></returns> public int GetInventoryItemsCount(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId) { m_helperInventoryItems.Clear(); GetInventoryItems(ref m_helperInventoryItems, objectBuilderType, objectBuilderId); return(m_helperInventoryItems.Count); }
/// <summary> /// Adds new inventory item from object builder /// </summary> /// <param name="objectBuilder">Item object builder</param> /// <param name="amount">Amount of inventory item</param> /// <param name="allAmountAddAsNewInventoryItems">If true, then all amount adds as new inventory items, if false, then try find old inventory items of same type, and add amount to them as first</param> public float AddInventoryItem(MyMwcObjectBuilder_Base objectBuilder, float amount, bool allAmountAddAsNewInventoryItems, bool increaseCapacityIfIsFull = false) { bool added = false; MyMwcObjectBuilderTypeEnum objectBuilderType = objectBuilder.GetObjectBuilderType(); int?objectBuilderId = objectBuilder.GetObjectBuilderId(); m_helperInventoryItemsForAddAndRemove.Clear(); GetInventoryItems(ref m_helperInventoryItemsForAddAndRemove, objectBuilderType, objectBuilderId); float amountToAddLeft = amount; if (!allAmountAddAsNewInventoryItems) { foreach (MyInventoryItem inventoryItem in m_helperInventoryItemsForAddAndRemove) { if (amountToAddLeft <= 0f) { break; } float amountToAdd = Math.Min(inventoryItem.MaxAmount - inventoryItem.Amount, amountToAddLeft); if (InventorySynchronizer != null && InventorySynchronizer.MustBeSynchronized()) { InventorySynchronizer.AddInventoryItemAmountChangeForSynchronization(objectBuilderType, objectBuilderId, inventoryItem.Amount, amountToAdd); } else { inventoryItem.Amount += amountToAdd; } amountToAddLeft -= amountToAdd; } } while (amountToAddLeft > 0f) { if (IsFull) { if (increaseCapacityIfIsFull) { MaxItems++; } else { break; } } MyInventoryItem newInventoryItem = MyInventory.CreateInventoryItemFromObjectBuilder(objectBuilder); float amountToAdd = Math.Min(newInventoryItem.MaxAmount, amountToAddLeft); //AddInventoryItem(newInventoryItem); AddItemToInventoryPrivate(newInventoryItem); newInventoryItem.Amount = amountToAdd; //After AddInventoryItem otherwise Amount event is not called amountToAddLeft -= amountToAdd; added = true; } if (added) { CallContentChange(); } return(amountToAddLeft); }
public MyInventoryTemplateItem(MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderId, float amountRatioMin, float amountRatioMax, int countToRefillMin, int countToRefillMax, float chanceToRefill) { if (!MyMwcObjectBuilder_Base.IsObjectBuilderIdValid(objectBuilderType, objectBuilderId)) { throw new ArgumentException("Invalid objectbuilderId!"); } if (amountRatioMin < 0f) { throw new ArgumentOutOfRangeException("amountRatioMin"); } if (amountRatioMax < 0f) { throw new ArgumentOutOfRangeException("amountRatioMax"); } if (amountRatioMax < amountRatioMin) { throw new ArgumentException("Amount ratio max can't be lesser than amount ratio min!"); } if (countToRefillMin < 0) { throw new ArgumentOutOfRangeException("countToRefillMin"); } if (countToRefillMax < 0) { throw new ArgumentOutOfRangeException("countToRefillMax"); } if (countToRefillMax < countToRefillMin) { throw new ArgumentException("Count to refill max can't be lesser than count to refill min!"); } if (chanceToRefill < 0f || chanceToRefill > 1f) { throw new ArgumentOutOfRangeException("chanceToRefill"); } ObjectBuilderType = objectBuilderType; ObjectBuilderId = objectBuilderId; AmountRatioMin = amountRatioMin; AmountRatioMax = amountRatioMax; CountToRefillMin = countToRefillMin; CountToRefillMax = countToRefillMax; ChanceToRefill = chanceToRefill; }
public static void WriteObjectBuilderTypeEnum(MyMwcObjectBuilderTypeEnum val, BinaryWriter binaryWriter) { binaryWriter.Write((ushort)val); }
/// <summary> /// Adds new inventory item from object builder type and id /// </summary> /// <param name="objectBuilderType">Objectbuilder type</param> /// <param name="objectBuilderId">Objectbuilder id</param> /// <param name="amount">Amount of inventory item</param> /// <param name="allAmmountAddAsNewInventoryItems">If true, then all amount adds as new inventory items, if false, then try find old inventory items of same type, and add amount to them as first</param> public float AddInventoryItem(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId, float amount, bool allAmmountAddAsNewInventoryItems, bool increaseCapacityIfIsFull = false) { MyMwcObjectBuilder_Base objectBuilder = MyMwcObjectBuilder_Base.CreateNewObject(objectBuilderType, objectBuilderId); return(AddInventoryItem(objectBuilder, amount, allAmmountAddAsNewInventoryItems, increaseCapacityIfIsFull)); }
public MyItemToGetDefinition(MyMwcObjectBuilderTypeEnum itemType, int? itemId) : this(itemType, itemId, 1) { }
static void AddPrefabConfiguration(MyMwcObjectBuilderTypeEnum prefabType, ushort prefabId, MyPrefabConfiguration prefabConfiguration) { ushort prefabTypeInt = (ushort)prefabType; if (m_prefabConfigurations[prefabTypeInt] == null) { m_prefabConfigurations[prefabTypeInt] = new MyPrefabConfiguration[MyMwcObjectBuilder_Base.GetObjectBuilderIDs(prefabType).Max() + 1]; } m_prefabConfigurations[prefabTypeInt][prefabId] = prefabConfiguration; }
public static bool IsDisabled(MyMwcObjectBuilderTypeEnum builderType, int? builderId) { if (DisabledItems.ContainsKey((int)builderType)) { List<int> disabledIds = DisabledItems[(int)builderType]; if (disabledIds == null) { return builderId == null; } else { if (builderId != null) { return disabledIds.Contains(builderId.Value); } else { return false; } } } return false; }
private static void AddTemplateItem(MyMwcInventoryTemplateTypeEnum templateType, MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderId, int countToRefillMin, int countToRefillMax, float chanceToRefill) { AddTemplateItem(templateType, objectBuilderType, objectBuilderId, countToRefillMin, countToRefillMax, 1f, 1f, chanceToRefill); }
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; }
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; }
private static void AssertObjectBuilder(MyMwcObjectBuilderTypeEnum objectBuilderType) { // check if there are valid ObjectBuilderIds for concrete ObjectBuilderType var buildingSpecificationsForType = m_buildingSpecifications[(int)objectBuilderType]; MyCommonDebugUtils.AssertDebug(buildingSpecificationsForType != null); for (int objectBuilderId = 0; objectBuilderId < buildingSpecificationsForType.Length; objectBuilderId++) { var buildingSpecification = buildingSpecificationsForType[objectBuilderId]; if (buildingSpecification != null) { MyCommonDebugUtils.AssertDebug(MyMwcObjectBuilder_Base.IsObjectBuilderIdValid(objectBuilderType, objectBuilderId)); } } // check if there are all objectbuilder's types and ids int[] objectBuilderIDs = MyMwcObjectBuilder_Base.GetObjectBuilderIDs(objectBuilderType); foreach (int objectBuilderId in objectBuilderIDs) { MyCommonDebugUtils.AssertDebug(buildingSpecificationsForType[objectBuilderId] != null); } }
public static MyGameplayProperties GetGameplayProperties(MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderId, MyMwcObjectBuilder_FactionEnum faction) { //if (m_itemProperties[(int)objectBuilderType] == null) //{ // return null; //} //return m_itemProperties[(int)objectBuilderType][objectBuilderId]; if (m_itemPropertiesPerFaction[(int)faction] == null) { return null; } return m_itemPropertiesPerFaction[(int)faction][(int)objectBuilderType][objectBuilderId]; }
public static MyPrefabConfiguration GetPrefabConfiguration(MyMwcObjectBuilderTypeEnum prefabType, int prefabId) { MyPrefabConfiguration prefabConfiguration = null; try { prefabConfiguration = m_prefabConfigurations[(ushort)prefabType][prefabId]; } catch { } return prefabConfiguration; }
/// <summary> /// Returns true if inventory contains item /// </summary> /// <param name="objectBuilderType">Item's object builder type</param> /// <param name="objectBuilderId">Item's object builder id</param> /// <returns></returns> public bool Contains(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId) { m_helperInventoryItems.Clear(); GetInventoryItems(ref m_helperInventoryItems, objectBuilderType, objectBuilderId); return(m_helperInventoryItems.Count > 0); }
public MyItemToGetDefinition(MyMwcObjectBuilderTypeEnum itemType, int?itemId) : this(itemType, itemId, 1) { }
public MyItemToGetDefinition(MyMwcObjectBuilderTypeEnum itemType, int? itemId, int count) { ItemType = itemType; ItemId = itemId; Count = count; }
public void AddInventoryItemAmountChangeForSynchronization(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId, float originalAmount, float amountChange) { m_inventoryItemsAmountChanges.Add(new MyInventoryItemAmountDefinition(objectBuilderType, objectBuilderId, originalAmount, amountChange)); }
/// <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; }
public void AddInventoryItemAmountChangeForSynchronization(MyMwcObjectBuilderTypeEnum objectBuilderType, int? objectBuilderId, float originalAmount, float amountChange) { m_inventoryItemsAmountChanges.Add(new MyInventoryItemAmountDefinition(objectBuilderType, objectBuilderId, originalAmount, amountChange)); }
public MyItemToGetDefinition(MyMwcObjectBuilderTypeEnum itemType, int?itemId, int count) { ItemType = itemType; ItemId = itemId; Count = count; }
/// <summary> /// Removes inventory items from inventory /// </summary> /// <param name="objectBuilderType">Inventory item's object builder type</param> /// <param name="objectBuilderId">Inventory item's object builder id</param> /// <param name="closeInventoryItems">If true, then close inventory item's instance in pool</param> public void RemoveInventoryItems(MyMwcObjectBuilderTypeEnum objectBuilderType, int?objectBuilderId, bool closeInventoryItems = false) { m_helperInventoryItems.Clear(); GetInventoryItems(ref m_helperInventoryItems, objectBuilderType, objectBuilderId); RemoveInventoryItems(m_helperInventoryItems, closeInventoryItems); }
public static MyGuiHelperBase GetGuiHelper(MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderID) { return m_buildTypeHelpers[(int) objectBuilderType][objectBuilderID]; }
private static void AddTemplateItem(MyMwcInventoryTemplateTypeEnum templateType, MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderId, int countToRefillMin, int countToRefillMax, float amountRatioMin, float amountRatioMax, float chanceToRefill) { AddTemplateItem(templateType, new MyInventoryTemplateItem(objectBuilderType, objectBuilderId, amountRatioMin, amountRatioMax, countToRefillMin, countToRefillMax, chanceToRefill)); }
public static MyBuildingSpecification GetBuildingSpecification(MyMwcObjectBuilderTypeEnum objectBuilderType, int objectBuilderId) { try { return m_buildingSpecifications[(int)objectBuilderType][objectBuilderId]; } catch { return null; } }
/// <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; }