private void ExposeFactionData()
        {
            if (Scribe.mode == LoadSaveMode.Saving)
            {
                int currentFactionId = Faction.OfPlayer.loadID;
                ScribeUtil.LookValue(currentFactionId, "currentFactionId");

                var data = new Dictionary <int, FactionMapData>(factionMapData);
                data.Remove(currentFactionId);
                ScribeUtil.LookWithValueKey(ref data, "factionMapData", LookMode.Deep, map);
            }
            else
            {
                // The faction whose data is currently set
                Scribe_Values.Look(ref currentFactionId, "currentFactionId");

                ScribeUtil.LookWithValueKey(ref factionMapData, "factionMapData", LookMode.Deep, map);
                if (factionMapData == null)
                {
                    factionMapData = new Dictionary <int, FactionMapData>();
                }
            }

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                factionMapData[currentFactionId] = FactionMapData.FromMap(map, currentFactionId);
            }
        }
Пример #2
0
        public void ExposeData()
        {
            Scribe_Values.Look(ref id, "id");

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                Scribe_References.Look(ref dialog.faction, "faction");
                ScribeUtil.LookValue(dialog.soundAmbient == SoundDefOf.RadioComms_Ambience, "radioMode");
                Scribe_Values.Look(ref dialog.title, "title");

                var nodes = dialog.curNode.TraverseNodes().ToList();

                saveNodes = new List <DiaNodeSave>();
                foreach (var node in nodes)
                {
                    saveNodes.Add(new DiaNodeSave(this, node));
                }

                fieldValues = nodes
                              .SelectMany(n => n.options)
                              .SelectMany(o => DelegateValues(o.action).Concat(DelegateValues(o.linkLateBind)))
                              .Distinct(new FieldSaveEquality())
                              .ToList();

                Scribe_Collections.Look(ref fieldValues, "fieldValues", LookMode.Deep);
                Scribe_Collections.Look(ref saveNodes, "nodes", LookMode.Deep);

                fieldValues = null;
                saveNodes   = null;
            }
            else
            {
                Scribe_References.Look(ref faction, "faction");
                Scribe_Values.Look(ref radioMode, "radioMode");
                Scribe_Values.Look(ref title, "title");

                Scribe_Collections.Look(ref fieldValues, "fieldValues", LookMode.Deep, this);
                Scribe_Collections.Look(ref saveNodes, "nodes", LookMode.Deep, this);
            }

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                dialog = new Dialog_NodeTreeWithFactionInfo(saveNodes[0].node, faction, false, radioMode, title)
                {
                    doCloseX      = true,
                    closeOnCancel = true
                };

                faction     = null;
                saveNodes   = null;
                fieldValues = null;
            }
        }
Пример #3
0
            public void ExposeData()
            {
                if (Scribe.mode == LoadSaveMode.Saving)
                {
                    Scribe_Values.Look(ref opt.text, "text");
                    Scribe_Values.Look(ref opt.resolveTree, "resolveTree");
                    ScribeUtil.LookValue(parent.saveNodes.FindIndex(n => n.node == opt.link), "linkIndex", true);
                    Scribe_Values.Look(ref opt.disabled, "disabled");
                    Scribe_Values.Look(ref opt.disabledReason, "disabledReason");
                    Scribe_Defs.Look(ref opt.clickSound, "clickSound");

                    ScribeUtil.LookValue(parent.fieldValues.FindIndex(f => Equals(f.value, opt.action)), "actionIndex", true);
                    ScribeUtil.LookValue(parent.fieldValues.FindIndex(f => Equals(f.value, opt.linkLateBind)), "linkLateBindIndex", true);
                }

                if (Scribe.mode == LoadSaveMode.LoadingVars)
                {
                    Scribe_Values.Look(ref text, "text");
                    Scribe_Values.Look(ref resolveTree, "resolveTree");
                    Scribe_Values.Look(ref linkIndex, "linkIndex", -1);
                    Scribe_Values.Look(ref disabled, "disabled");
                    Scribe_Values.Look(ref disabledReason, "disabledReason");
                    Scribe_Defs.Look(ref clickSound, "clickSound");

                    Scribe_Values.Look(ref actionIndex, "actionIndex");
                    Scribe_Values.Look(ref linkLateBindIndex, "linkLateBindIndex");

                    opt = new DiaOption()
                    {
                        text           = text,
                        resolveTree    = resolveTree,
                        disabled       = disabled,
                        disabledReason = disabledReason,
                        clickSound     = clickSound
                    };
                }

                if (Scribe.mode == LoadSaveMode.PostLoadInit)
                {
                    opt.link         = parent.saveNodes.ElementAtOrDefault(linkIndex)?.node;
                    opt.action       = (Action)parent.fieldValues.ElementAtOrDefault(actionIndex)?.value;
                    opt.linkLateBind = (Func <DiaNode>)parent.fieldValues.ElementAtOrDefault(linkLateBindIndex)?.value;
                }
            }