public static MyInventoryBase GetInventory(this MyEntity entity, MyStringHash inventoryId) { MyInventoryBase inventory = null; inventory = entity.Components.Get<MyInventoryBase>(); if (inventory != null) { if (inventoryId.Equals(MyStringHash.GetOrCompute(inventory.InventoryId.ToString()))) { return inventory; } } if (inventory is MyInventoryAggregate) { var aggregate = inventory as MyInventoryAggregate; m_tmpList.Clear(); aggregate.GetComponentsFlattened(m_tmpList); foreach (var component in m_tmpList) { var componentInventory = component as MyInventoryBase; if (inventoryId.Equals(MyStringHash.GetOrCompute(componentInventory.InventoryId.ToString()))) { return componentInventory; } } } return null; }
public static MyInventoryBase GetInventory(this MyEntity entity, MyStringHash inventoryId) { MyInventoryBase inventory = null; inventory = entity.Components.Get <MyInventoryBase>(); if (inventory != null) { if (inventoryId.Equals(MyStringHash.GetOrCompute(inventory.InventoryId.ToString()))) { return(inventory); } } if (inventory is MyInventoryAggregate) { var aggregate = inventory as MyInventoryAggregate; m_tmpList.Clear(); aggregate.GetComponentsFlattened(m_tmpList); foreach (var component in m_tmpList) { var componentInventory = component as MyInventoryBase; if (inventoryId.Equals(MyStringHash.GetOrCompute(componentInventory.InventoryId.ToString()))) { return(componentInventory); } } } return(null); }
public static MyInventoryBase GetInventory(this MyEntity entity, MyStringHash inventoryId) { MyInventoryBase base2 = null; MyStringHash hash; base2 = entity.Components.Get <MyInventoryBase>(); if (base2 != null) { hash = base2.InventoryId; if (inventoryId.Equals(MyStringHash.GetOrCompute(hash.ToString()))) { return(base2); } } if (base2 is MyInventoryAggregate) { m_tmpList.Clear(); (base2 as MyInventoryAggregate).GetComponentsFlattened(m_tmpList); using (List <MyComponentBase> .Enumerator enumerator = m_tmpList.GetEnumerator()) { while (true) { if (!enumerator.MoveNext()) { break; } MyInventoryBase current = enumerator.Current as MyInventoryBase; hash = current.InventoryId; if (inventoryId.Equals(MyStringHash.GetOrCompute(hash.ToString()))) { return(current); } } } } return(null); }
//Do our actual removal. void Entities_OnEntityAdd(IMyEntity entity) { MyFloatingObject floaty = entity as MyFloatingObject; //Make sure its not null if (floaty?.Item != null) { //Also make sure its not null if (floaty.Item.Content?.SubtypeId != null) { MyStringHash subtype = floaty.Item.Content.SubtypeId; //Do a 2fast4u comparison if (m_scraphash.Equals(subtype)) { //Delete the entity entity.Close(); } } } }
public bool Equals(DefinitionKey other) { return(State.Equals(other.State) && Id.Equals(other.Id)); }
public bool Equals(TagKey other) { return(State.Equals(other.State) && Tag.Equals(other.Tag)); }
public bool Equals(BlockModifierKey other) { return(Block.Equals(other.Block) && AttachmentPoint.Equals(other.AttachmentPoint)); }