public UncategorizedFilteredStorage( KMonoBehaviour root, Tag[] required_tags, Tag[] forbidden_tags, IUserControlledCapacity capacity_control, bool use_logic_meter, ChoreType fetch_chore_type) { this.root = root; this.requiredTags = required_tags; this.forbiddenTags = forbidden_tags; this.capacityControl = capacity_control; this.useLogicMeter = use_logic_meter; this.choreType = fetch_chore_type; root.Subscribe(-1697596308, new Action <object>(OnStorageChanged)); root.Subscribe(-543130682, new Action <object>(OnUserSettingsChanged)); this.filterable = root.FindOrAdd <UncategorizedFilterable>(); filterable.OnFilterChanged += new Action <Tag[]>(OnFilterChanged); this.storage = root.GetComponent <Storage>(); storage.Subscribe(644822890, new Action <object>(OnOnlyFetchMarkedItemsSettingChanged)); if (capacityStatusItem == null) { capacityStatusItem = new StatusItem("StorageLocker", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); capacityStatusItem.resolveStringCallback = (str, data) => { UncategorizedFilteredStorage filteredStorage = (UncategorizedFilteredStorage)data; float amountStored = filteredStorage.GetAmountStored(); float b = filteredStorage.storage.capacityKg; string newValue1 = Util.FormatWholeNumber(amountStored <= b - filteredStorage.storage.storageFullMargin || amountStored >= b ? Mathf.Floor(amountStored) : b); IUserControlledCapacity component = filteredStorage.root.GetComponent <IUserControlledCapacity>(); if (component != null) { b = Mathf.Min(component.UserMaxCapacity, b); } string newValue2 = Util.FormatWholeNumber(b); str = str.Replace("{Stored}", newValue1); str = str.Replace("{Capacity}", newValue2); str = component == null?str.Replace("{Units}", (string)GameUtil.GetCurrentMassUnit(false)) : str.Replace("{Units}", (string)component.CapacityUnits); return(str); }; noFilterStatusItem = new StatusItem("NoStorageFilterSet", "BUILDING", "status_item_no_filter_set", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); } root.GetComponent <KSelectable>().SetStatusItem(Db.Get().StatusItemCategories.Main, capacityStatusItem, this); }
public FilteredStorage(KMonoBehaviour root, Tag[] required_tags, Tag[] forbidden_tags, IUserControlledCapacity capacity_control, bool use_logic_meter, ChoreType fetch_chore_type) { this.root = root; requiredTags = required_tags; forbiddenTags = forbidden_tags; capacityControl = capacity_control; useLogicMeter = use_logic_meter; choreType = fetch_chore_type; root.Subscribe(-1697596308, OnStorageChanged); root.Subscribe(-543130682, OnUserSettingsChanged); filterable = root.FindOrAdd <TreeFilterable>(); TreeFilterable treeFilterable = filterable; treeFilterable.OnFilterChanged = (Action <Tag[]>)Delegate.Combine(treeFilterable.OnFilterChanged, new Action <Tag[]>(OnFilterChanged)); storage = root.GetComponent <Storage>(); storage.Subscribe(644822890, OnOnlyFetchMarkedItemsSettingChanged); if (capacityStatusItem == null) { capacityStatusItem = new StatusItem("StorageLocker", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); capacityStatusItem.resolveStringCallback = delegate(string str, object data) { FilteredStorage filteredStorage = (FilteredStorage)data; float amountStored = filteredStorage.GetAmountStored(); float num = filteredStorage.storage.capacityKg; amountStored = ((!(amountStored > num - filteredStorage.storage.storageFullMargin) || !(amountStored < num)) ? Mathf.Floor(amountStored) : num); string newValue = Util.FormatWholeNumber(amountStored); IUserControlledCapacity component = filteredStorage.root.GetComponent <IUserControlledCapacity>(); if (component != null) { num = Mathf.Min(component.UserMaxCapacity, num); } string newValue2 = Util.FormatWholeNumber(num); str = str.Replace("{Stored}", newValue); str = str.Replace("{Capacity}", newValue2); str = ((component == null) ? str.Replace("{Units}", GameUtil.GetCurrentMassUnit(false)) : str.Replace("{Units}", component.CapacityUnits)); return(str); }; noFilterStatusItem = new StatusItem("NoStorageFilterSet", "BUILDING", "status_item_no_filter_set", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); } root.GetComponent <KSelectable>().SetStatusItem(Db.Get().StatusItemCategories.Main, capacityStatusItem, this); }