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;
        }
 public static void OnLoad()
 {
     Debug.Log("Endpoint state path: " + EndpointState.Filename());
     if (!System.IO.File.Exists(EndpointState.Filename()))
     {
         Debug.Log("endpoint_state.yaml file not found. Creating it.");
         new EndpointState().Save();
     }
     Strings.Add("STRINGS.UI.UISIDESCREENS.ENDPOINTTRANSPORT.TITLE", "Transport Options");
     STRINGS.MISC.NOTIFICATIONS.COLONYLOST.NAME        = "Game over";
     STRINGS.MISC.NOTIFICATIONS.COLONYLOST.TOOLTIP     = "All Duplicants are rescued, incapacitated, or dead";
     STRINGS.UI.COLONYLOSTSCREEN.COLONYLOST            = "GAME OVER";
     STRINGS.UI.COLONYLOSTSCREEN.COLONYLOSTDESCRIPTION = "No duplicants remain on this asteroid.";
 }
        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);
            }
        }
        public static EndpointState Load()
        {
            EndpointState result;

            try
            {
                result = YamlIO.LoadFile <EndpointState>(Filename());
            }
            catch (Exception ex)
            {
                Debug.LogWarning("Failed to load endpoint_state.yml: " + ex.ToString());
                result = new EndpointState();
            }
            if (result.times_rescued == null)
            {
                Debug.Log("Missing times_rescued");
                result.times_rescued = new Dictionary <string, int>();
            }
            Debug.Log("Loaded Endpoint state: " + result.ToString());
            return(result);
        }
Exemple #5
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();
         }
     }
 }