本文整理汇总了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();
}
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例7: MyEntityInventoryStateGroup
public MyEntityInventoryStateGroup(MyInventory entity, bool attach)
{
m_inventoryChangedDelegate = InventoryChanged;
Inventory = entity;
if (attach)
{
Inventory.ContentsChanged += m_inventoryChangedDelegate;
}
}
示例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;
}
示例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);
}
示例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();
}
}
示例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--;
}
}
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
}