internal void ExposeInventoryData() { if (InventoryItem != null) { TechType = InventoryItem.item.GetTechType(); PrefabId = InventoryItem.item.gameObject.GetComponent <PrefabIdentifier>()?.Id; var battery = InventoryItem.item.gameObject.GetComponent <Battery>(); var food = InventoryItem.item.gameObject.GetComponent <Eatable>(); var fuel = InventoryItem.item.gameObject.GetComponent <FireExtinguisher>(); if (fuel != null) { FuelData = new FuelData { Fuel = fuel.fuel }; QuickLogger.Debug($"Saved {TechType} fire extinguisher"); Type = ItemType.Fuel; return; } if (battery != null) { BatteryData = new BatteryData { Capacity = battery._capacity, Charge = battery._charge }; QuickLogger.Debug($"Saved {TechType} battery"); Type = ItemType.Battery; return; } if (InventoryItem.item.gameObject.GetComponent <Eatable>() != null) { FoodData = new FoodData { FoodValue = food.GetFoodValue(), WaterValue = food.GetWaterValue() }; QuickLogger.Debug($"Saved {TechType} Food"); Type = ItemType.Food; } } else { QuickLogger.Error($"InventoryItem was null when trying to set in the {nameof(ItemData)}"); } }
internal void ExposeInventoryData() { if (InventoryItem != null) { TechType = InventoryItem.item.GetTechType(); PrefabId = InventoryItem.item.gameObject.GetComponent <PrefabIdentifier>()?.Id; var energyMixin = InventoryItem.item.GetComponentInChildren <EnergyMixin>(); var battery = InventoryItem.item.gameObject.GetComponent <Battery>(); var food = InventoryItem.item.gameObject.GetComponent <Eatable>(); var fuel = InventoryItem.item.gameObject.GetComponent <FireExtinguisher>(); if (TechType == Mod.GetDSSServerTechType()) { QuickLogger.Debug("Is DDS Server", true); Type = ItemType.FCSFilteredStorage; var data = InventoryItem.item.gameObject.GetComponent <FCSFilteredStorage>(); FcsFilteredStorage = new HashSet <ObjectData>(data.Items.ToList().ConvertAll(obj => new ObjectData(obj))); FcsFilters = data.Filters.ConvertAll(filter => new Filter(filter)); } if (energyMixin != null) { PlayerToolData = GetPlayerToolData(InventoryItem); QuickLogger.Debug($"Saved {TechType} player tool"); Type = ItemType.PlayerTool; } if (fuel != null) { FuelData = new FuelData { Fuel = fuel.fuel }; QuickLogger.Debug($"Saved {TechType} fire extinguisher"); Type = ItemType.Fuel; return; } if (battery != null) { BatteryData = new BatteryData { Capacity = battery._capacity, Charge = battery._charge }; QuickLogger.Debug($"Saved {TechType} battery"); Type = ItemType.Battery; return; } if (InventoryItem.item.gameObject.GetComponent <Eatable>() != null) { FoodData = new FoodData { FoodValue = food.GetFoodValue(), WaterValue = food.GetWaterValue() }; QuickLogger.Debug($"Saved {TechType} Food"); Type = ItemType.Food; } } else { QuickLogger.Error($"InventoryItem was null when trying to set in the {nameof(ItemData)}"); } }