private static void Postfix(MainMenu __instance, KButton ___buttonPrefab, GameObject ___buttonParent)
        {
            KButton kButton = Util.KInstantiateUI <KButton>(___buttonPrefab.gameObject, ___buttonParent, force_active: true);

            kButton.onClick += () => {
                ConfirmDialogScreen confirmDialogScreen = (ConfirmDialogScreen)KScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject, Global.Instance.globalCanvas);
                var text = new StringBuilder();
                text.AppendLine("Duplicants rescued:");
                var state = EndpointState.Load();
                foreach (var item in from x in state.times_rescued orderby - x.Value, x.Key select x)
                {
                    if (item.Value == 1)
                    {
                        text.AppendLine(item.Key);
                    }
                    else
                    {
                        text.AppendLine(item.Key + " x" + item.Value);
                    }
                }
                confirmDialogScreen.PopupConfirmDialog(text.ToString(), null, null, null, null, "Endpoint Population");
            };
            LocText loctext = kButton.GetComponentInChildren <LocText>();

            loctext.text     = "ENDPOINT";
            loctext.fontSize = 14.0f;
        }
        private static void Postfix(MinionStartingStats __instance)
        {
            var name  = __instance.NameStringKey;
            var state = EndpointState.Load();

            if (state.times_rescued.ContainsKey(name))
            {
                int count = state.times_rescued[name];
                var trait = new Klei.AI.Trait("Rescued", "Rescued", "A previous iteration of this duplicant visited the great printing pod in the sky (x" + count + ").", 0, true, null, true, true);
                foreach (var attribute in TUNING.DUPLICANTSTATS.DISTRIBUTED_ATTRIBUTES)
                {
                    trait.Add(new Klei.AI.AttributeModifier(attribute, state.times_rescued[name], "Rescued x" + count));
                }
                __instance.Traits.Add(trait);
            }
        }
Example #3
0
 public void SetReachedDestination(bool reached_destination, SpaceDestination destination)
 {
     if (reached_destination != has_reached_destination)
     {
         has_reached_destination = reached_destination;
         if (reached_destination && destination.type == "Endpoint" && stay_at_destination)
         {
             var storage = GetComponent <MinionStorage>();
             var ids     = storage.GetStoredMinionInfo().Select((x) => x.id).ToList();
             var state   = EndpointState.Load();
             foreach (var id in ids)
             {
                 var minion   = storage.DeserializeMinion(id, transform.position);
                 var identity = minion.GetComponent <MinionIdentity>();
                 var name     = identity.nameStringKey;
                 Debug.Log("Transported " + name + " to " + destination.type);
                 // Delete duplicant.
                 minion.GetComponent <Schedulable>().GetSchedule().Unassign(minion.GetComponent <Schedulable>());
                 identity.GetSoleOwner().UnassignAll();
                 Components.MinionAssignablesProxy.Remove(identity.assignableProxy.Get());
                 Components.MinionResumes.Remove(minion.GetComponent <MinionResume>());
                 minion.gameObject.SetActive(false);
                 // Show message.
                 Messenger.Instance.QueueMessage(new EndpointMessage(minion.name));
                 // Hacks to avoid crash in SkillsScreen.
                 Components.LiveMinionIdentities.Add(identity);
                 Components.LiveMinionIdentities.Remove(identity);
                 Game.Instance.userMenu.Refresh(gameObject);
                 // Record duplicant as rescued in the state file.
                 if (!state.times_rescued.ContainsKey(name))
                 {
                     state.times_rescued[name] = 0;
                 }
                 state.times_rescued[name] += 1;
             }
             state.Save();
         }
     }
 }