Exemplo n.º 1
0
        public void Start(MyGuiHelperBase guiHelper, MyGameplayProperties itemProperties, MyMwcObjectBuilder_Base objectBuilder, float amount)
        {
            GuiHelper      = guiHelper;
            ItemProperties = itemProperties;
            ObjectBuilder  = objectBuilder;

            Amount         = Math.Min(amount, MaxAmount);
            TemporaryFlags = MyInventoryItemTemporaryFlags.NONE;
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        public static MyInventoryItem CreateInventoryItemFromObjectBuilder(MyMwcObjectBuilder_Base objectBuilder, float amount)
        {
            float maxAmount   = MyGameplayConstants.GetGameplayProperties(objectBuilder, MyMwcObjectBuilder_FactionEnum.Euroamerican).MaxAmount;
            float amountToAdd = Math.Min(maxAmount, amount);

            int objectBuilderId = objectBuilder.GetObjectBuilderId().HasValue ? objectBuilder.GetObjectBuilderId().Value : 0;

            MyGuiHelperBase guiHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(objectBuilder.GetObjectBuilderType(), objectBuilderId);

            MyCommonDebugUtils.AssertDebug(guiHelper != null);

            //warning: use default faction for get gameplay properties for inventory item
            MyGameplayProperties inventoryItemProperties = MyGameplayConstants.GetGameplayProperties(objectBuilder.GetObjectBuilderType(), objectBuilderId, MyMwcObjectBuilder_FactionEnum.Euroamerican);

            MyCommonDebugUtils.AssertDebug(inventoryItemProperties != null);



            MyInventoryItem item = MyInventory.InventoryItemsPool.Allocate();

            item.Start(guiHelper, inventoryItemProperties, objectBuilder, amountToAdd);
            return(item);
        }
Exemplo n.º 4
0
 public void Start(MyGuiHelperBase guiHelper, MyGameplayProperties itemProperties, MyMwcObjectBuilder_Base objectBuilder)
 {
     Start(guiHelper, itemProperties, objectBuilder, 1f);
 }