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(); }
protected override void OnInventoryContentChange(MyInventory sender) { Inventory.OnInventoryContentChange -= OnInventoryContentChange; base.OnInventoryContentChange(sender); // we must play new sound for new engine type, so we must stop old sound cues if (m_engineChanged) { StopEngineSounds(SharpDX.XACT3.StopFlags.Release); if (MySession.PlayerShip == this) { SetEngineSound(Config.Engine.On); } m_engineChanged = false; } //UpdateWeight(); UpdateMaxFuel(); UpdateMaxOxygen(); UpdateRadarCapabilities(); if (Fuel > MaxFuel) { Fuel = MaxFuel; } if (Oxygen > MaxOxygen) { Oxygen = MaxOxygen; } m_hasRadarJammer = Inventory.Contains(MyMwcObjectBuilderTypeEnum.SmallShip_Tool, (int?)MyMwcObjectBuilder_SmallShip_Tool_TypesEnum.RADAR_JAMMER); if (Inventory.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; } if (MySession.PlayerShip == this) { // False ID's FalseFactions = MyMwcObjectBuilder_FactionEnum.None; m_helperInventoryItems.Clear(); Inventory.GetInventoryItems(ref m_helperInventoryItems, MyMwcObjectBuilderTypeEnum.FalseId, null); foreach (MyInventoryItem falsefactionsInventoryItem in m_helperInventoryItems) { FalseFactions |= ((MyMwcObjectBuilder_FalseId)falsefactionsInventoryItem.GetInventoryItemObjectBuilder(false)).Faction; } // if any blueprints was added to player ship's inventory, then we move them to checkpoint's inventory // if any hackingtool was added to player ship's inventory, then we move them to checkpoint's inventory m_helperInventoryItems.Clear(); Inventory.GetInventoryItems(ref m_helperInventoryItems, MyMwcObjectBuilderTypeEnum.Blueprint, null); Inventory.GetInventoryItems(ref m_helperInventoryItems, MyMwcObjectBuilderTypeEnum.SmallShip_HackingTool, null); foreach (MyInventoryItem itemToCheckpointInventory in m_helperInventoryItems) { if (!MySession.Static.Inventory.Contains(itemToCheckpointInventory.GetInventoryItemObjectBuilder(false))) { MySession.Static.Inventory.AddInventoryItem(itemToCheckpointInventory); } } Inventory.RemoveInventoryItems(m_helperInventoryItems); } Inventory.OnInventoryContentChange += OnInventoryContentChange; }