public static AddedMassInventory SetupFor(IMyEntity entity) { var inventory = new AddedMassInventory(0, new Vector3(0d, 0d, 0d), MyInventoryFlags.CanSend); entity.Components.Add <MyInventoryBase>(inventory); var block = entity as IMyTerminalBlock; if (block != null) { block.AppendingCustomInfo += AppendingCustomInfo; } return(inventory); }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { // this method is called async! always do stuff in the first update unless you're sure it must be in this one. // NOTE the objectBuilder arg is not the Entity's but the component's, and since the component wasn't loaded from an OB that means it's always null, which it is (AFAIK). block = (IMyGasTank)Entity; if (MyAPIGateway.Multiplayer.IsServer) { NeedsUpdate = MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; // allow UpdateOnceBeforeFrame() to execute, remove if not needed addedMass = AddedMassInventory.SetupFor(block); var tankType = block.DefinitionDisplayNameText; if (tankType.Contains("Hydrogen")) { gasKgPerL = 0.071f; } if (tankType.Contains("Oxygen")) { gasKgPerL = 1.140f; } } }