コード例 #1
0
        private static void AddStrings()
        {
            Strings.Add(SideButtonKey + ".TITLE", SideButtonTitle);
            Strings.Add(SideButtonKey + ".TEXT", SideButtonText);
            Strings.Add(SideButtonKey + ".TOOLTIP", SideButtonTooltip);
            Strings.Add(SideButtonKey + ".STATUS", SideButtonStatus);

            Strings.Add(UserMenuButtonKey + ".TITLE", UserMenuButtonTitle);
            Strings.Add(UserMenuButtonKey + ".TOOLTIP", UserMenuButtonTooltip);

            Strings.Add(CheckboxKey + ".TITLE", CheckboxTitle);
            Strings.Add(CheckboxKey + ".LABEL", CheckboxLabel);
            Strings.Add(CheckboxKey + ".TOOLTIP", CheckboxTooltip);

            Strings.Add(SliderKey + ".TITLE", SliderTitle);
            Strings.Add(SliderKey + ".TOOLTIP", SliderTooltip);
            Strings.Add(SliderKey + ".UNITS", SliderUnits);

            Strings.Add(StatusKey + ".NAME", StatusName);
            Strings.Add(StatusKey + ".TOOLTIP", StatusTooltip);

            Strings.Add(ReservoirStatusKey + ".NAME", ReservoirStatusName);
            Strings.Add(ReservoirStatusKey + ".TOOLTIP", ReservoirStatusTooltip);


            TrashcansStrings.TrashcanStatus = (StatusItem)Traverse.Create(Db.Get().BuildingStatusItems).Method("CreateStatusItem", new object[] {
                "Trashcan",
                "BUILDING",
                string.Empty,
                StatusItem.IconType.Info,
                NotificationType.Neutral,
                false,
                OverlayModes.None.ID,
                true,
                129022
            }).GetValue();

            TrashcansStrings.TrashcanStatus.resolveStringCallback = (Func <string, object, string>)((str, data) =>
            {
                Trashcan trashcan = (Trashcan)data;
                if ((UnityEngine.Object)trashcan == (UnityEngine.Object)null)
                {
                    return(str);
                }

                if (str.Contains("{Total}"))
                {
                    if (!trashcan.AutoTrash)
                    {
                        str = str.Replace("{Remaining}", "<b>not Empty</b>");
                        str = str.Replace("{Total}", "");
                    }
                    else
                    {
                        str = str.Replace("{Remaining}", "empty in <b>" + (trashcan.WaitTime - trashcan.CurrentTime).ToString() + "s</b> ");
                        str = str.Replace("{Total}", "from an increment of <b>" + trashcan.WaitTime + "s</b>");
                    }
                }
                else if (!trashcan.AutoTrash)
                {
                    str = str.Replace("{Remaining}", "Disabled");
                }
                else
                {
                    str = str.Replace("{Remaining}", (trashcan.WaitTime - trashcan.CurrentTime).ToString() + "s");
                }

                return(str);
            });

            TrashcansStrings.ReservoirCapacityStatus = (StatusItem)Traverse.Create(Db.Get().BuildingStatusItems).Method("CreateStatusItem", new object[] {
                "ReservoirCapacity",
                "BUILDING",
                string.Empty,
                StatusItem.IconType.Info,
                NotificationType.Neutral,
                false,
                OverlayModes.None.ID,
                true,
                129022
            }).GetValue();

            TrashcansStrings.ReservoirCapacityStatus.resolveStringCallback = (Func <string, object, string>)((str, data) =>
            {
                Storage storage    = (Storage)data;
                float amountStored = storage.MassStored();
                float capacity     = storage.capacityKg;
                string stored      = Util.FormatWholeNumber((double)amountStored <= (double)capacity - (double)storage.storageFullMargin || (double)amountStored >= (double)capacity ? Mathf.Floor(amountStored) : capacity);
                str = str.Replace("{Stored}", stored);
                str = str.Replace("{Capacity}", Util.FormatWholeNumber(capacity));
                str = str.Replace("{Units}", " Kg");
                return(str);
            });
        }
コード例 #2
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     this.trashcan = this.FindComponent <Trashcan>();
 }