当前位置: 首页>>代码示例>>C#>>正文


C# MyInventory类代码示例

本文整理汇总了C#中MyInventory的典型用法代码示例。如果您正苦于以下问题:C# MyInventory类的具体用法?C# MyInventory怎么用?C# MyInventory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MyInventory类属于命名空间,在下文中一共展示了MyInventory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EntityInventoryItemAmountChanged

 void EntityInventoryItemAmountChanged(MyEntity entity, MyInventory inventory, MyInventoryItem item, float number)
 {
     if (MyScriptWrapper.IsPlayerShip(entity))
     {
         CheckOre();
     }
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:7,代码来源:MyHarvestOreSubmission.cs

示例2: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {             
            base.Init(objectBuilder, cubeGrid);

            MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_Reactor));
            m_reactorDefinition = BlockDefinition as MyReactorDefinition;
            MyDebug.AssertDebug(m_reactorDefinition != null);

            CurrentPowerOutput = 0;
            m_inventory = new MyInventory(m_reactorDefinition.InventoryMaxVolume, m_reactorDefinition.InventorySize, MyInventoryFlags.CanReceive, this);

            var obGenerator = (MyObjectBuilder_Reactor)objectBuilder;
            m_inventory.Init(obGenerator.Inventory);
            m_inventory.ContentsChanged += inventory_ContentsChanged;
            m_inventory.Constraint = m_reactorDefinition.InventoryConstraint;
            RefreshRemainingCapacity();

            UpdateText();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
            //if (MyFakes.SHOW_DAMAGE_EFFECTS && IsWorking)
            //    NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;

            m_baseIdleSound = BlockDefinition.PrimarySound;

            m_useConveyorSystem = obGenerator.UseConveyorSystem;

            if (IsWorking)
                OnStartWorking();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:32,代码来源:MyReactor.cs

示例3: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);
            var def = BlockDefinition as MyPoweredCargoContainerDefinition;
            var ob = objectBuilder as MyObjectBuilder_Collector;
            m_inventory = new MyInventory(def.InventorySize.Volume, def.InventorySize, MyInventoryFlags.CanSend, this);
            m_inventory.Init(ob.Inventory);
            m_inventory.ContentsChanged += Inventory_ContentChangedCallback;
            if (Sync.IsServer && CubeGrid.CreatePhysics)
                LoadDummies();

			var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                MyStringHash.GetOrCompute(def.ResourceSinkGroup),
                MyEnergyConstants.MAX_REQUIRED_POWER_COLLECTOR,
                () => base.CheckIsWorking() ? ResourceSink.MaxRequiredInput : 0f);
	        ResourceSink = sinkComp;
			ResourceSink.Update();
			ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink,this));

            SlimBlock.ComponentStack.IsFunctionalChanged += UpdateReceiver;
            base.EnabledChanged += UpdateReceiver;

            m_useConveyorSystem = ob.UseConveyorSystem;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:26,代码来源:MyCollector.cs

示例4: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_cargoDefinition = (MyCargoContainerDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            var cargoBuilder = (MyObjectBuilder_CargoContainer)objectBuilder;
            m_containerType = cargoBuilder.ContainerType;

            if (MyFakes.ENABLE_INVENTORY_FIX)
            {
                FixSingleInventory();
            }

            // Backward compatibility - inventory component not defined in definition files and in entity container
            if (this.GetInventory() == null)
            {
                MyInventory inventory = new MyInventory(m_cargoDefinition.InventorySize.Volume, m_cargoDefinition.InventorySize, MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive);
                Components.Add<MyInventoryBase>(inventory);
                
                if (m_containerType != null && MyFakes.RANDOM_CARGO_PLACEMENT && (cargoBuilder.Inventory == null || cargoBuilder.Inventory.Items.Count == 0))
                    SpawnRandomCargo();
            }

            //Backward compatibility
            if (cargoBuilder.Inventory != null && cargoBuilder.Inventory.Items.Count > 0)
                this.GetInventory().Init(cargoBuilder.Inventory);

            Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!");
            this.GetInventory().SetFlags(MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive);
            m_conveyorEndpoint = new MyMultilineConveyorEndpoint(this);
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
            UpdateIsWorking();
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCargoContainer.cs

示例5: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_cargoDefinition = (MyCargoContainerDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            var cargoBuilder = (MyObjectBuilder_CargoContainer)objectBuilder;
            m_containerType = cargoBuilder.ContainerType;

            if (!Components.Has<MyInventoryBase>())
            {
                m_inventory = new MyInventory(m_cargoDefinition.InventorySize.Volume, m_cargoDefinition.InventorySize, MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive, this);
				if(MyFakes.ENABLE_MEDIEVAL_INVENTORY)
					Components.Add<MyInventoryBase>(m_inventory);

                if (m_containerType != null && MyFakes.RANDOM_CARGO_PLACEMENT && (cargoBuilder.Inventory == null || cargoBuilder.Inventory.Items.Count == 0))
                    SpawnRandomCargo();
                else
                    m_inventory.Init(cargoBuilder.Inventory);
            }
            else
            {
                m_inventory = Components.Get<MyInventoryBase>() as MyInventory;
				Debug.Assert(m_inventory != null);
                //m_inventory.Owner = this;
            }

            if(MyPerGameSettings.InventoryMass)
                m_inventory.ContentsChanged += Inventory_ContentsChanged;

            m_conveyorEndpoint = new MyMultilineConveyorEndpoint(this);
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
            UpdateIsWorking();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCargoContainer.cs

示例6: MyShip

 /// <summary>
 /// Initializes a new instance of the <see cref="MyEntity"/> class.
 /// </summary>
 protected MyShip()
 {
     this.Faction = MyMwcObjectBuilder_FactionEnum.Euroamerican;
     Inventory = new MyInventory();
     Inventory.OnInventoryContentChange += OnInventoryContentChange;
     Inventory.OnInventoryItemAmountChange += OnInventoryItemAmountChange;
     Inventory.OnInventoryContentChange += new AppCode.Game.Inventory.OnInventoryContentChange(Inventory_OnInventoryContentChange);
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:11,代码来源:MyShip.cs

示例7: MyEntityInventoryStateGroup

 public MyEntityInventoryStateGroup(MyInventory entity, bool attach)
 {
     m_inventoryChangedDelegate = InventoryChanged;
     Inventory = entity;
     if (attach)
     {
         Inventory.ContentsChanged += m_inventoryChangedDelegate;
     }
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyEntityInventoryStateGroup.cs

示例8: MyInventorySynchronizer

        public MyInventorySynchronizer(MyInventory inventory, MyMustBeInventorySynchronizedDelegate mustBeInventorySynchronizedDelegate) 
        {
            m_inventoryItemsHelper = new List<MyInventoryItem>();
            m_inventoryItemsToAdd = new List<MyInventoryItem>();
            m_inventoryItemsAmountChanges = new List<MyInventoryItemAmountDefinition>();
            m_mustBeInventorySynchronizedDelegate = mustBeInventorySynchronizedDelegate;
            m_inventory = inventory;

            //MyMinerGame.OnGameUpdate += MyMinerGame_OnGameUpdate;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MyInventorySynchronizer.cs

示例9: SendTransferInventoryMsg

 public static void SendTransferInventoryMsg(long sourceEntityID, long destinationEntityID, MyInventory inventory, bool clearSourceInventories = false)
 {
     var msg = new TransferInventoryMsg();
     msg.SourceEntityID = sourceEntityID;
     msg.DestinationEntityID = destinationEntityID;
     msg.InventoryId = MyStringHash.GetOrCompute(inventory.InventoryId.ToString());
     msg.RemoveEntityOnEmpty = inventory.RemoveEntityOnEmpty;
     msg.ClearSourceInventories = clearSourceInventories;
     Sync.Layer.SendMessageToAllAndSelf(ref msg);
 }       
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:10,代码来源:MySyncInventory.cs

示例10: OnCharacterDead

        public override void OnCharacterDead()
        {
            System.Diagnostics.Debug.Assert(!Character.Definition.EnableSpawnInventoryAsContainer ||  (Character.Definition.EnableSpawnInventoryAsContainer && Character.Definition.InventorySpawnContainerId.HasValue), "Container id is not defined, but is enabled to spawn the inventory into container");
            
            if (Character.IsDead && Character.Definition.EnableSpawnInventoryAsContainer && Character.Definition.InventorySpawnContainerId.HasValue)
            {
                if (Character.Components.Has<MyInventoryBase>())
                {
                    var inventory = Character.Components.Get<MyInventoryBase>();
                    if (inventory is MyInventoryAggregate)
                    {
                        var inventoryAggregate = inventory as MyInventoryAggregate;
                        var components = new List<MyComponentBase>();
                        inventoryAggregate.GetComponentsFlattened(components);
                        foreach (var inventoryComponent in components)
                        {
                            //TODO: This spawn all MyInventory components, which are currently used with Characters
                            var myInventory = inventoryComponent as MyInventory;
                            if (myInventory != null && myInventory.GetItemsCount() > 0)
                            {
                                MyContainerDefinition containerDefinition;
                                if (MyDefinitionManager.Static.TryGetContainerDefinition(Character.Definition.InventorySpawnContainerId.Value, out containerDefinition))
                                {
                                    inventoryAggregate.RemoveComponent(myInventory);
                                    if (Sync.IsServer)
                                    {
                                        var bagEntityId = SpawnInventoryContainer(Character.Definition.InventorySpawnContainerId.Value, myInventory);
                                    }
                                }
                                else
                                {
                                    System.Diagnostics.Debug.Fail("The provided definiton of the container was not found!");
                                }
                            }
                            else
                            {
                                inventoryAggregate.RemoveComponent(inventoryComponent);
                            }

                        }
                    }
                    else if (inventory is MyInventory && Character.Definition.SpawnInventoryOnBodyRemoval)
                    {
                        m_spawnInventory = inventory as MyInventory;
                        Character.OnClosing += Character_OnClosing;
                    }                    
                    else
                    {
                        System.Diagnostics.Debug.Fail("Reached unpredicted branch on spawning inventory, can't spawn inventory if it is not in aggregate, or if it is not going to be spawned on body removal");
                    }
                }                
                CloseComponent();
            }            
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:54,代码来源:MyInventorySpawnComponent.cs

示例11: RecalculateItemsCount

        private void RecalculateItemsCount(MyInventory inventory)
        {
            for (int index = 0; index < m_itemsToGet.Count; index++)
            {
                var itemToGet = m_itemsToGet[index];
                int itemCount = MyScriptWrapper.GetInventoryItemCount(inventory, itemToGet.ItemType, itemToGet.ItemId);
                if (itemCount >= itemToGet.Count)
                {
                    m_itemsToGet.Remove(itemToGet);
                    index--;

                }
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:14,代码来源:MyObjectiveGetItems.cs

示例12: Init

        void Init()
        {
            m_enableBackgroundFade = true;
            m_size = new Vector2(0.99f, 0.95f);

            // Add screen title
            AddCaption();
            
            m_inventoryItemsRepository = new MyInventoryItemsRepository();
            m_allItemsInventory = new MyInventory();
            m_allItemsInventory.FillInventoryWithAllItems(null, 100, true);

            InitControls();
            AddOkAndCancelButtonControls();
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:15,代码来源:MyGuiScreenEntityWithInventory.cs

示例13: OnInventoryContentChanged

 private void OnInventoryContentChanged(MyInventory sender)
 {
     if (sender.Contains(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.NANO_REPAIR_TOOL))
     {
         if (m_nanoRepairTool == null)
         {
             m_nanoRepairTool = new MyNanoRepairToolEntity(this);                    
         }
     }
     else
     {
         m_nanoRepairTool = null;                
     }
     RecheckNeedsUpdate();
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:15,代码来源:MyPrefabLargeShip.cs

示例14: Inventory_OnInventoryContentChange

        void Inventory_OnInventoryContentChange(MyInventory sender)
        {
            UpdateState();

            if (RespawnTime.HasValue && MyMultiplayerGameplay.IsRunning && !MyGuiScreenGamePlay.Static.IsGameStoryActive())
            {
                if (Inventory.GetInventoryItems().Count < m_inventoryTemplate.InventoryItems.Count)
                {
                    m_shouldRespawn = NeedsUpdate = true;
                }
            }

            if (sender.IsInventoryEmpty() && CloseAfterEmptied)
            {
                MarkForClose();
            }
        }
开发者ID:ripark,项目名称:Miner-Wars-2081,代码行数:17,代码来源:MyCargoBox.cs

示例15: SetInventory

 public void SetInventory(MyInventory inventory, int index)
 {
     switch (index)
     {
         case 0:
             InputInventory.ContentsChanged -= inventory_OnContentsChanged;
             InputInventory = inventory;
             InputInventory.ContentsChanged += inventory_OnContentsChanged;
             break;
         case 1:
             OutputInventory.ContentsChanged -= inventory_OnContentsChanged;
             OutputInventory = inventory;
             OutputInventory.ContentsChanged += inventory_OnContentsChanged;
             break;
         default:
             throw new InvalidBranchException();
     }
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:18,代码来源:MyRefinery.cs


注:本文中的MyInventory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。