コード例 #1
0
        public void RegisterDeepSaved(object obj, string label)
        {
            if (!Prefs.DevMode)
            {
                return;
            }
            if (Scribe.mode != LoadSaveMode.Saving)
            {
                Log.Error(string.Concat(new object[]
                {
                    "Registered ",
                    obj,
                    ", but current mode is ",
                    Scribe.mode
                }));
                return;
            }
            if (obj == null)
            {
                return;
            }
            ILoadReferenceable loadReferenceable = obj as ILoadReferenceable;

            if (loadReferenceable != null && !this.deepSaved.Add(loadReferenceable.GetUniqueLoadID()))
            {
                Log.Warning(string.Concat(new string[]
                {
                    "DebugLoadIDsSavingErrorsChecker error: tried to register deep-saved object with loadID ",
                    loadReferenceable.GetUniqueLoadID(),
                    ", but it's already here. label=",
                    label,
                    " (not cleared after the previous save? different objects have the same load ID? the same object is deep-saved twice?)"
                }));
            }
        }
コード例 #2
0
 public void RegisterReferenced(ILoadReferenceable obj, string label)
 {
     if (!Prefs.DevMode)
     {
         return;
     }
     if (Scribe.mode != LoadSaveMode.Saving)
     {
         Log.Error(string.Concat(new object[]
         {
             "Registered ",
             obj,
             ", but current mode is ",
             Scribe.mode
         }), false);
         return;
     }
     if (obj == null)
     {
         return;
     }
     try
     {
         this.referenced.Add(new DebugLoadIDsSavingErrorsChecker.ReferencedObject(obj.GetUniqueLoadID(), label));
     }
     catch (Exception arg)
     {
         Log.Error("Error in GetUniqueLoadID(): " + arg, false);
     }
 }
コード例 #3
0
 public void RegisterDeepSaved(object obj, string label)
 {
     if (Prefs.DevMode)
     {
         if (Scribe.mode != LoadSaveMode.Saving)
         {
             Log.Error("Registered " + obj + ", but current mode is " + Scribe.mode);
         }
         else if (obj != null)
         {
             ILoadReferenceable loadReferenceable = obj as ILoadReferenceable;
             if (loadReferenceable != null)
             {
                 try
                 {
                     if (!deepSaved.Add(loadReferenceable.GetUniqueLoadID()))
                     {
                         Log.Warning("DebugLoadIDsSavingErrorsChecker error: tried to register deep-saved object with loadID " + loadReferenceable.GetUniqueLoadID() + ", but it's already here. label=" + label + " (not cleared after the previous save? different objects have the same load ID? the same object is deep-saved twice?)");
                     }
                 }
                 catch (Exception arg)
                 {
                     Log.Error("Error in GetUniqueLoadID(): " + arg);
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: CrossRefs.cs プロジェクト: Wilchenx/Multiplayer
        static bool Prefix(LoadedObjectDirectory __instance, ILoadReferenceable reffable)
        {
            if (!(__instance is SharedCrossRefs))
            {
                return(true);
            }
            if (reffable == null)
            {
                return(false);
            }

            string key = reffable.GetUniqueLoadID();

            if (ScribeUtil.sharedCrossRefs.Dict.ContainsKey(key))
            {
                return(false);
            }

            if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs)
            {
                ScribeUtil.sharedCrossRefs.tempKeys.Add(key);
            }

            ScribeUtil.sharedCrossRefs.Dict.Add(key, reffable);

            return(false);
        }
コード例 #5
0
 public T ObjectWithLoadID <T>(string loadID)
 {
     if (!loadID.NullOrEmpty() && !(loadID == "null"))
     {
         ILoadReferenceable loadReferenceable = default(ILoadReferenceable);
         if (this.allObjectsByLoadID.TryGetValue(loadID, out loadReferenceable))
         {
             if (loadReferenceable == null)
             {
                 return(default(T));
             }
             try
             {
                 return((T)loadReferenceable);
             }
             catch (Exception ex)
             {
                 Log.Error("Exception getting object with load id " + loadID + " of type " + typeof(T) + ". What we loaded was " + loadReferenceable.ToStringSafe() + ". Exception:\n" + ex);
                 return(default(T));
             }
         }
         Log.Warning("Could not resolve reference to object with loadID " + loadID + " of type " + typeof(T) + ". Was it compressed away, destroyed, had no ID number, or not saved/loaded right? curParent=" + Scribe.loader.curParent.ToStringSafe() + " curPathRelToParent=" + Scribe.loader.curPathRelToParent);
         return(default(T));
     }
     return(default(T));
 }
コード例 #6
0
        public new void ExposeData()
        {
            ILoadReferenceable commTarget = (ILoadReferenceable)this.commTarget;

            Scribe_References.Look <ActivityTask>(ref this.activityTask, "activityTask");
            Scribe_References.Look <ILoadReferenceable>(ref commTarget, "commTarget", false);
            this.commTarget = (ICommunicable)commTarget;
            Scribe_References.Look <Verb>(ref this.verbToUse, "verbToUse", false);
            Scribe_References.Look <Bill>(ref this.bill, "bill", false);
            Scribe_References.Look <Lord>(ref this.lord, "lord", false);
            Scribe_Defs.Look <JobDef>(ref this.def, "def");
            Scribe_Values.Look <int>(ref this.loadID, "loadID", 0, false);
            Scribe_TargetInfo.Look(ref this.targetA, "targetA");
            Scribe_TargetInfo.Look(ref this.targetB, "targetB");
            Scribe_TargetInfo.Look(ref this.targetC, "targetC");
            Scribe_Collections.Look <LocalTargetInfo>(ref this.targetQueueA, "targetQueueA", LookMode.Undefined, new object[0]);
            Scribe_Collections.Look <LocalTargetInfo>(ref this.targetQueueB, "targetQueueB", LookMode.Undefined, new object[0]);
            Scribe_Values.Look <int>(ref this.count, "count", -1, false);
            Scribe_Collections.Look <int>(ref this.countQueue, "countQueue", LookMode.Undefined, new object[0]);
            Scribe_Values.Look <int>(ref this.startTick, "startTick", -1, false);
            Scribe_Values.Look <int>(ref this.expiryInterval, "expiryInterval", -1, false);
            Scribe_Values.Look <bool>(ref this.checkOverrideOnExpire, "checkOverrideOnExpire", false, false);
            Scribe_Values.Look <bool>(ref this.playerForced, "playerForced", false, false);
            Scribe_Collections.Look <ThingCountClass>(ref this.placedThings, "placedThings", LookMode.Undefined, new object[0]);
            Scribe_Values.Look <int>(ref this.maxNumMeleeAttacks, "maxNumMeleeAttacks", int.MaxValue, false);
            Scribe_Values.Look <int>(ref this.maxNumStaticAttacks, "maxNumStaticAttacks", int.MaxValue, false);
            Scribe_Values.Look <bool>(ref this.exitMapOnArrival, "exitMapOnArrival", false, false);
            Scribe_Values.Look <bool>(ref this.failIfCantJoinOrCreateCaravan, "failIfCantJoinOrCreateCaravan", false, false);
            Scribe_Values.Look <bool>(ref this.killIncappedTarget, "killIncappedTarget", false, false);
            Scribe_Values.Look <bool>(ref this.haulOpportunisticDuplicates, "haulOpportunisticDuplicates", false, false);
            Scribe_Values.Look <HaulMode>(ref this.haulMode, "haulMode", HaulMode.Undefined, false);
            Scribe_Defs.Look <ThingDef>(ref this.plantDefToSow, "plantDefToSow");
            Scribe_Values.Look <LocomotionUrgency>(ref this.locomotionUrgency, "locomotionUrgency", LocomotionUrgency.Jog, false);
            Scribe_Values.Look <bool>(ref this.ignoreDesignations, "ignoreDesignations", false, false);
            Scribe_Values.Look <bool>(ref this.canBash, "canBash", false, false);
            Scribe_Values.Look <bool>(ref this.haulDroppedApparel, "haulDroppedApparel", false, false);
            Scribe_Values.Look <bool>(ref this.restUntilHealed, "restUntilHealed", false, false);
            Scribe_Values.Look <bool>(ref this.ignoreJoyTimeAssignment, "ignoreJoyTimeAssignment", false, false);
            Scribe_Values.Look <bool>(ref this.overeat, "overeat", false, false);
            Scribe_Values.Look <bool>(ref this.attackDoorIfTargetLost, "attackDoorIfTargetLost", false, false);
            Scribe_Values.Look <int>(ref this.takeExtraIngestibles, "takeExtraIngestibles", 0, false);
            Scribe_Values.Look <bool>(ref this.expireRequiresEnemiesNearby, "expireRequiresEnemiesNearby", false, false);
            Scribe_Values.Look <bool>(ref this.collideWithPawns, "collideWithPawns", false, false);
            Scribe_Values.Look <bool>(ref this.forceSleep, "forceSleep", false, false);
            Scribe_Defs.Look <InteractionDef>(ref this.interaction, "interaction");
            Scribe_Values.Look <bool>(ref this.endIfCantShootTargetFromCurPos, "endIfCantShootTargetFromCurPos", false, false);
            Scribe_Values.Look <bool>(ref this.endIfCantShootInMelee, "endIfCantShootInMelee", false, false);
            Scribe_Values.Look <bool>(ref this.checkEncumbrance, "checkEncumbrance", false, false);
            Scribe_Values.Look <float>(ref this.followRadius, "followRadius", 0.0f, false);
            Scribe_Values.Look <bool>(ref this.endAfterTendedOnce, "endAfterTendedOnce", false, false);
            if (Scribe.mode != LoadSaveMode.PostLoadInit || this.verbToUse == null || !this.verbToUse.BuggedAfterLoading)
            {
                return;
            }
            this.verbToUse = (Verb)null;
            Log.Warning(this.GetType().ToString() + " had a bugged verbToUse after loading.", false);
        }
        public static bool RegisterReferencedPrefix(ILoadReferenceable obj)
        {
            if (Scribe.mode == LoadSaveMode.Saving && obj is AreaExt)
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
ファイル: Job.cs プロジェクト: potsh/RimWorld
        public void ExposeData()
        {
            ILoadReferenceable refee = (ILoadReferenceable)commTarget;

            Scribe_References.Look(ref refee, "commTarget");
            commTarget = (ICommunicable)refee;
            Scribe_References.Look(ref verbToUse, "verbToUse");
            Scribe_References.Look(ref bill, "bill");
            Scribe_References.Look(ref lord, "lord");
            Scribe_Defs.Look(ref def, "def");
            Scribe_Values.Look(ref loadID, "loadID", 0);
            Scribe_TargetInfo.Look(ref targetA, "targetA");
            Scribe_TargetInfo.Look(ref targetB, "targetB");
            Scribe_TargetInfo.Look(ref targetC, "targetC");
            Scribe_Collections.Look(ref targetQueueA, "targetQueueA", LookMode.Undefined);
            Scribe_Collections.Look(ref targetQueueB, "targetQueueB", LookMode.Undefined);
            Scribe_Values.Look(ref count, "count", -1);
            Scribe_Collections.Look(ref countQueue, "countQueue", LookMode.Undefined);
            Scribe_Values.Look(ref startTick, "startTick", -1);
            Scribe_Values.Look(ref expiryInterval, "expiryInterval", -1);
            Scribe_Values.Look(ref checkOverrideOnExpire, "checkOverrideOnExpire", defaultValue: false);
            Scribe_Values.Look(ref playerForced, "playerForced", defaultValue: false);
            Scribe_Collections.Look(ref placedThings, "placedThings", LookMode.Undefined);
            Scribe_Values.Look(ref maxNumMeleeAttacks, "maxNumMeleeAttacks", 2147483647);
            Scribe_Values.Look(ref maxNumStaticAttacks, "maxNumStaticAttacks", 2147483647);
            Scribe_Values.Look(ref exitMapOnArrival, "exitMapOnArrival", defaultValue: false);
            Scribe_Values.Look(ref failIfCantJoinOrCreateCaravan, "failIfCantJoinOrCreateCaravan", defaultValue: false);
            Scribe_Values.Look(ref killIncappedTarget, "killIncappedTarget", defaultValue: false);
            Scribe_Values.Look(ref haulOpportunisticDuplicates, "haulOpportunisticDuplicates", defaultValue: false);
            Scribe_Values.Look(ref haulMode, "haulMode", HaulMode.Undefined);
            Scribe_Defs.Look(ref plantDefToSow, "plantDefToSow");
            Scribe_Values.Look(ref locomotionUrgency, "locomotionUrgency", LocomotionUrgency.Jog);
            Scribe_Values.Look(ref ignoreDesignations, "ignoreDesignations", defaultValue: false);
            Scribe_Values.Look(ref canBash, "canBash", defaultValue: false);
            Scribe_Values.Look(ref haulDroppedApparel, "haulDroppedApparel", defaultValue: false);
            Scribe_Values.Look(ref restUntilHealed, "restUntilHealed", defaultValue: false);
            Scribe_Values.Look(ref ignoreJoyTimeAssignment, "ignoreJoyTimeAssignment", defaultValue: false);
            Scribe_Values.Look(ref overeat, "overeat", defaultValue: false);
            Scribe_Values.Look(ref attackDoorIfTargetLost, "attackDoorIfTargetLost", defaultValue: false);
            Scribe_Values.Look(ref takeExtraIngestibles, "takeExtraIngestibles", 0);
            Scribe_Values.Look(ref expireRequiresEnemiesNearby, "expireRequiresEnemiesNearby", defaultValue: false);
            Scribe_Values.Look(ref collideWithPawns, "collideWithPawns", defaultValue: false);
            Scribe_Values.Look(ref forceSleep, "forceSleep", defaultValue: false);
            Scribe_Defs.Look(ref interaction, "interaction");
            Scribe_Values.Look(ref endIfCantShootTargetFromCurPos, "endIfCantShootTargetFromCurPos", defaultValue: false);
            Scribe_Values.Look(ref endIfCantShootInMelee, "endIfCantShootInMelee", defaultValue: false);
            Scribe_Values.Look(ref checkEncumbrance, "checkEncumbrance", defaultValue: false);
            Scribe_Values.Look(ref followRadius, "followRadius", 0f);
            Scribe_Values.Look(ref endAfterTendedOnce, "endAfterTendedOnce", defaultValue: false);
            if (Scribe.mode == LoadSaveMode.PostLoadInit && verbToUse != null && verbToUse.BuggedAfterLoading)
            {
                verbToUse = null;
                Log.Warning(GetType() + " had a bugged verbToUse after loading.");
            }
        }
        static bool Prefix(LoadedObjectDirectory __instance, ILoadReferenceable reffable)
        {
            if (!PersistentWorldManager.GetInstance().PersistentWorldNotNull())
            {
                return(true);
            }

            var allObjectsByLoadID = (Dictionary <string, ILoadReferenceable>)AllObjectsByLoadIdField.GetValue(__instance);

            return(!allObjectsByLoadID.ContainsKey(reffable.GetUniqueLoadID()));
        }
コード例 #10
0
 public void RegisterLoaded(ILoadReferenceable reffable)
 {
     if (Prefs.DevMode)
     {
         string text = "[excepted]";
         try
         {
             text = reffable.GetUniqueLoadID();
         }
         catch (Exception)
         {
         }
         string text2 = "[excepted]";
         try
         {
             text2 = reffable.ToString();
         }
         catch (Exception)
         {
         }
         if (allObjectsByLoadID.TryGetValue(text, out var value))
         {
             string text3 = "";
             Log.Error(string.Concat("Cannot register ", reffable.GetType(), " ", text2, ", (id=", text, " in loaded object directory. Id already used by ", value.GetType(), " ", value.ToStringSafe(), ".", text3));
             return;
         }
     }
     try
     {
         allObjectsByLoadID.Add(reffable.GetUniqueLoadID(), reffable);
     }
     catch (Exception ex5)
     {
         string text4 = "[excepted]";
         try
         {
             text4 = reffable.GetUniqueLoadID();
         }
         catch (Exception)
         {
         }
         string text5 = "[excepted]";
         try
         {
             text5 = reffable.ToString();
         }
         catch (Exception)
         {
         }
         Log.Error(string.Concat("Exception registering ", reffable.GetType(), " ", text5, " in loaded object directory with unique load ID ", text4, ": ", ex5));
     }
 }
コード例 #11
0
 public void RegisterLoaded(ILoadReferenceable reffable)
 {
     if (Prefs.DevMode)
     {
         string text = "[excepted]";
         try
         {
             text = reffable.GetUniqueLoadID();
         }
         catch (Exception)
         {
         }
         string text2 = "[excepted]";
         try
         {
             text2 = reffable.ToString();
         }
         catch (Exception)
         {
         }
         ILoadReferenceable loadReferenceable = default(ILoadReferenceable);
         if (this.allObjectsByLoadID.TryGetValue(text, out loadReferenceable))
         {
             Log.Error("Cannot register " + reffable.GetType() + " " + text2 + ", (id=" + text + " in loaded object directory. Id already used by " + loadReferenceable.GetType() + " " + loadReferenceable.ToString() + ".");
             return;
         }
     }
     try
     {
         this.allObjectsByLoadID.Add(reffable.GetUniqueLoadID(), reffable);
     }
     catch (Exception ex5)
     {
         string text3 = "[excepted]";
         try
         {
             text3 = reffable.GetUniqueLoadID();
         }
         catch (Exception)
         {
         }
         string text4 = "[excepted]";
         try
         {
             text4 = reffable.ToString();
         }
         catch (Exception)
         {
         }
         Log.Error("Exception registering " + reffable.GetType() + " " + text4 + " in loaded object directory with unique load ID " + text3 + ": " + ex5);
     }
 }
コード例 #12
0
ファイル: SavingPatches.cs プロジェクト: rwmt/Multiplayer
        static bool Prefix(LoadedObjectDirectory __instance, ref ILoadReferenceable reffable)
        {
            string text = "[excepted]";

            try
            {
                text = reffable.GetUniqueLoadID();
            }
            catch
            {
            }

            return(!__instance.allObjectsByLoadID.ContainsKey(text));
        }
コード例 #13
0
 public void RegisterReferenced(ILoadReferenceable obj, string label)
 {
     if (Prefs.DevMode)
     {
         if (Scribe.mode != LoadSaveMode.Saving)
         {
             Log.Error("Registered " + obj + ", but current mode is " + Scribe.mode);
         }
         else if (obj != null)
         {
             this.referenced.Add(new ReferencedObject(obj.GetUniqueLoadID(), label));
         }
     }
 }
コード例 #14
0
ファイル: Trading.cs プロジェクト: rwmt/Multiplayer
        public void ExposeData()
        {
            Scribe_Values.Look(ref sessionId, "sessionId");

            ILoadReferenceable trader = (ILoadReferenceable)this.trader;

            Scribe_References.Look(ref trader, "trader");
            this.trader = (ITrader)trader;

            Scribe_References.Look(ref playerNegotiator, "playerNegotiator");
            Scribe_Values.Look(ref giftMode, "giftMode");
            Scribe_Values.Look(ref giftsOnly, "giftsOnly");

            Scribe_Deep.Look(ref deal, "tradeDeal", this);
        }
コード例 #15
0
        static bool Prefix(ref ILoadReferenceable refee, string label, bool saveDestroyedThings)
        {
            if (!PersistentWorldManager.GetInstance().PersistentWorldNotNull() || !PersistentWorldManager.GetInstance().PersistentWorldNotNullAndLoadStatusIsNot(PersistentWorldLoadSaver.PersistentWorldLoadStatus.Converting))
            {
                return(true);
            }

            var persistentWorld = PersistentWorldManager.GetInstance().PersistentWorld;

            switch (Scribe.mode)
            {
            case LoadSaveMode.Saving:
                if (refee == null)
                {
                    Scribe.saver.WriteElement(label, "null");
                    break;
                }

                if (refee is Thing thing &&
                    Scribe_References.CheckSaveReferenceToDestroyedThing(thing, label, saveDestroyedThings))
                {
                    break;
                }

                Scribe.saver.WriteElement(label, refee.GetUniqueLoadID());
                Scribe.saver.loadIDsErrorsChecker.RegisterReferenced(refee, label);
                break;

            case LoadSaveMode.LoadingVars:
                var xmlNode      = (XmlNode)Scribe.loader.curXmlParent[label];
                var targetLoadID = xmlNode?.InnerText;

                persistentWorld.LoadSaver.ReferenceTable.RequestReference(label, targetLoadID);

                if (refee != null)
                {
                    Scribe.loader.crossRefs.loadIDs.RegisterLoadIDReadFromXml(targetLoadID, refee.GetType(), label);
                }
                break;

            case LoadSaveMode.ResolvingCrossRefs:
                refee = persistentWorld.LoadSaver.ReferenceTable.ResolveReference(label);
                break;
            }

            return(false);
        }
コード例 #16
0
        public void ExposeData()
        {
            ILoadReferenceable loadReferenceable = (ILoadReferenceable)this.commTarget;

            Scribe_References.Look <ILoadReferenceable>(ref loadReferenceable, "commTarget", false);
            this.commTarget = (ICommunicable)loadReferenceable;
            Scribe_References.Look <Verb>(ref this.verbToUse, "verbToUse", false);
            Scribe_References.Look <Bill>(ref this.bill, "bill", false);
            Scribe_References.Look <Lord>(ref this.lord, "lord", false);
            Scribe_Defs.Look <JobDef>(ref this.def, "def");
            Scribe_Values.Look <int>(ref this.loadID, "loadID", 0, false);
            Scribe_TargetInfo.Look(ref this.targetA, "targetA");
            Scribe_TargetInfo.Look(ref this.targetB, "targetB");
            Scribe_TargetInfo.Look(ref this.targetC, "targetC");
            Scribe_Collections.Look <LocalTargetInfo>(ref this.targetQueueA, "targetQueueA", LookMode.Undefined, new object[0]);
            Scribe_Collections.Look <LocalTargetInfo>(ref this.targetQueueB, "targetQueueB", LookMode.Undefined, new object[0]);
            Scribe_Values.Look <int>(ref this.count, "count", -1, false);
            Scribe_Collections.Look <int>(ref this.countQueue, "countQueue", LookMode.Undefined, new object[0]);
            Scribe_Values.Look <int>(ref this.startTick, "startTick", -1, false);
            Scribe_Values.Look <int>(ref this.expiryInterval, "expiryInterval", -1, false);
            Scribe_Values.Look <bool>(ref this.checkOverrideOnExpire, "checkOverrideOnExpire", false, false);
            Scribe_Values.Look <bool>(ref this.playerForced, "playerForced", false, false);
            Scribe_Collections.Look <ThingStackPartClass>(ref this.placedThings, "placedThings", LookMode.Undefined, new object[0]);
            Scribe_Values.Look <int>(ref this.maxNumMeleeAttacks, "maxNumMeleeAttacks", 2147483647, false);
            Scribe_Values.Look <int>(ref this.maxNumStaticAttacks, "maxNumStaticAttacks", 2147483647, false);
            Scribe_Values.Look <bool>(ref this.exitMapOnArrival, "exitMapOnArrival", false, false);
            Scribe_Values.Look <bool>(ref this.failIfCantJoinOrCreateCaravan, "failIfCantJoinOrCreateCaravan", false, false);
            Scribe_Values.Look <bool>(ref this.killIncappedTarget, "killIncappedTarget", false, false);
            Scribe_Values.Look <bool>(ref this.haulOpportunisticDuplicates, "haulOpportunisticDuplicates", false, false);
            Scribe_Values.Look <HaulMode>(ref this.haulMode, "haulMode", HaulMode.Undefined, false);
            Scribe_Defs.Look <ThingDef>(ref this.plantDefToSow, "plantDefToSow");
            Scribe_Values.Look <LocomotionUrgency>(ref this.locomotionUrgency, "locomotionUrgency", LocomotionUrgency.Jog, false);
            Scribe_Values.Look <bool>(ref this.ignoreDesignations, "ignoreDesignations", false, false);
            Scribe_Values.Look <bool>(ref this.canBash, "canBash", false, false);
            Scribe_Values.Look <bool>(ref this.haulDroppedApparel, "haulDroppedApparel", false, false);
            Scribe_Values.Look <bool>(ref this.restUntilHealed, "restUntilHealed", false, false);
            Scribe_Values.Look <bool>(ref this.ignoreJoyTimeAssignment, "ignoreJoyTimeAssignment", false, false);
            Scribe_Values.Look <bool>(ref this.overeat, "overeat", false, false);
            Scribe_Values.Look <bool>(ref this.attackDoorIfTargetLost, "attackDoorIfTargetLost", false, false);
            Scribe_Values.Look <int>(ref this.takeExtraIngestibles, "takeExtraIngestibles", 0, false);
            Scribe_Values.Look <bool>(ref this.expireRequiresEnemiesNearby, "expireRequiresEnemiesNearby", false, false);
            Scribe_Values.Look <bool>(ref this.collideWithPawns, "collideWithPawns", false, false);
            Scribe_Values.Look <bool>(ref this.forceSleep, "forceSleep", false, false);
            Scribe_Defs.Look <InteractionDef>(ref this.interaction, "interaction");
            Scribe_Values.Look <bool>(ref this.endIfCantShootTargetFromCurPos, "endIfCantShootTargetFromCurPos", false, false);
        }
コード例 #17
0
ファイル: Job.cs プロジェクト: MoyTW/MTW_AncestorSpirits
        public static void ExposeData(this Source _this)
        {
            // Hack!
            if (_this.GetType() == typeof(Job_PetitionAncestors))
            {
                ((Job_PetitionAncestors)_this).ExposeAdditionalData();
            }
            // Existing
            ILoadReferenceable loadReferenceable = (ILoadReferenceable)_this.commTarget;

            Scribe_References.LookReference <ILoadReferenceable>(ref loadReferenceable, "commTarget", false);
            _this.commTarget = (ICommunicable)loadReferenceable;
            Scribe_References.LookReference <Verb>(ref _this.verbToUse, "verbToUse", false);
            Scribe_References.LookReference <Bill>(ref _this.bill, "bill", false);
            Scribe_Defs.LookDef <JobDef>(ref _this.def, "def");
            Scribe_TargetInfo.LookTargetInfo(ref _this.targetA, "targetA");
            Scribe_TargetInfo.LookTargetInfo(ref _this.targetB, "targetB");
            Scribe_TargetInfo.LookTargetInfo(ref _this.targetC, "targetC");
            Scribe_Collections.LookList <TargetInfo>(ref _this.targetQueueA, "targetQueueA", LookMode.Undefined, new object[0]);
            Scribe_Collections.LookList <TargetInfo>(ref _this.targetQueueB, "targetQueueB", LookMode.Undefined, new object[0]);
            Scribe_Collections.LookList <int>(ref _this.numToBringList, "numToBring", LookMode.Undefined, new object[0]);
            Scribe_Collections.LookList <ThingStackPart>(ref _this.placedThings, "placedThings", LookMode.Undefined, new object[0]);
            Scribe_Values.LookValue <int>(ref _this.startTick, "startTick", -1, false);
            Scribe_Values.LookValue <int>(ref _this.expiryInterval, "expiryInterval", -1, false);
            Scribe_Values.LookValue <int>(ref _this.maxNumMeleeAttacks, "maxNumMeleeAttacks", 2147483647, false);
            Scribe_Values.LookValue <bool>(ref _this.exitMapOnArrival, "exitMapOnArrival", false, false);
            Scribe_Values.LookValue <bool>(ref _this.killIncappedTarget, "killIncappedTarget", false, false);
            Scribe_Values.LookValue <int>(ref _this.maxNumToCarry, "maxNumToHaul", -1, false);
            Scribe_Values.LookValue <bool>(ref _this.haulOpportunisticDuplicates, "haulOpportunisticDuplicates", false, false);
            Scribe_Values.LookValue <HaulMode>(ref _this.haulMode, "haulMode", HaulMode.Undefined, false);
            Scribe_Defs.LookDef <ThingDef>(ref _this.plantDefToSow, "plantDefToSow");
            Scribe_Values.LookValue <bool>(ref _this.playerForced, "playerForced", false, false);
            Scribe_Values.LookValue <LocomotionUrgency>(ref _this.locomotionUrgency, "locomotionUrgency", LocomotionUrgency.Jog, false);
            Scribe_Values.LookValue <bool>(ref _this.applyAnesthetic, "applyAnesthetic", false, false);
            Scribe_Values.LookValue <bool>(ref _this.ignoreDesignations, "ignoreDesignations", false, false);
            Scribe_Values.LookValue <bool>(ref _this.checkOverrideOnExpire, "checkOverrideOnExpire", false, false);
            Scribe_Values.LookValue <bool>(ref _this.canBash, "canBash", false, false);
            Scribe_Values.LookValue <bool>(ref _this.haulDroppedApparel, "haulDroppedApparel", false, false);
            Scribe_Values.LookValue <bool>(ref _this.restUntilHealed, "restUntilHealed", false, false);
            Scribe_Values.LookValue <bool>(ref _this.ignoreJoyTimeAssignment, "ignoreJoyTimeAssignment", false, false);
            Scribe_Values.LookValue <bool>(ref _this.overeat, "overeat", false, false);
            Scribe_Values.LookValue <bool>(ref _this.attackDoorIfTargetLost, "attackDoorIfTargetLost", false, false);
            Scribe_Values.LookValue <int>(ref _this.takeExtraIngestibles, "takeExtraIngestibles", 0, false);
            Scribe_Values.LookValue <bool>(ref _this.expireRequiresEnemiesNearby, "expireRequiresEnemiesNearby", false, false);
        }
コード例 #18
0
 public void ResolveAllCrossReferences()
 {
     Scribe.mode = LoadSaveMode.ResolvingCrossRefs;
     if (DebugViewSettings.logMapLoad)
     {
         LogSimple.Message("==================Register the saveables all so we can find them later");
     }
     foreach (IExposable crossReferencingExposable in crossReferencingExposables)
     {
         ILoadReferenceable loadReferenceable = crossReferencingExposable as ILoadReferenceable;
         if (loadReferenceable != null)
         {
             if (DebugViewSettings.logMapLoad)
             {
                 LogSimple.Message("RegisterLoaded " + loadReferenceable.GetType());
             }
             loadedObjectDirectory.RegisterLoaded(loadReferenceable);
         }
     }
     if (DebugViewSettings.logMapLoad)
     {
         LogSimple.Message("==================Fill all cross-references to the saveables");
     }
     foreach (IExposable crossReferencingExposable2 in crossReferencingExposables)
     {
         if (DebugViewSettings.logMapLoad)
         {
             LogSimple.Message("ResolvingCrossRefs ExposeData " + crossReferencingExposable2.GetType());
         }
         try
         {
             Scribe.loader.curParent          = crossReferencingExposable2;
             Scribe.loader.curPathRelToParent = null;
             crossReferencingExposable2.ExposeData();
         }
         catch (Exception arg)
         {
             Log.Error("Could not resolve cross refs: " + arg);
         }
     }
     Scribe.loader.curParent          = null;
     Scribe.loader.curPathRelToParent = null;
     Scribe.mode = LoadSaveMode.Inactive;
     Clear(errorIfNotEmpty: true);
 }
コード例 #19
0
        /// <summary>
        /// Loads the reference (first parameter) with any add-on label depending on the path relative to the parent.
        /// </summary>
        /// <param name="referenceable"></param>
        /// <param name="label"></param>
        public void LoadReferenceIntoMemory(ILoadReferenceable referenceable, string label)
        {
            // Current file of the reference to be assigned as Reference.pathOfFileContainingReference.
            var currentFile     = GetCroppedFileName(this.loadSaver.CurrentFile.FullName);
            var pathRelToParent = "";

            switch (Scribe.mode)
            {
            case LoadSaveMode.Saving:
                pathRelToParent = (string)CurPathField.GetValue(Scribe.saver) + "/" + label;

                if (label == "li")
                {
                    pathRelToParent += "[" + ScribeSaver_EnterNode_Patch.GetIndexInList(pathRelToParent, label) +
                                       "]";
                }
                else if (label == "thing")
                {
                    pathRelToParent += "[" + ScribeSaver_EnterNode_Patch.GetThingIndex() + "]";
                }

                FileLog.Log("LoadReferenceIntoMemory SAVING (pathRelToParent=" + pathRelToParent + ")");
                break;

            case LoadSaveMode.LoadingVars:
                pathRelToParent = label;
                FileLog.Log("LoadReferenceIntoMemory LOADING (pathRelToParent=" + pathRelToParent + ")");
                break;

            default:
                throw new InvalidProgramException("Invalid program state.");
            }

            var reference = new Reference(currentFile, referenceable);

            if (references.ContainsKey(referenceable.GetUniqueLoadID()))
            {
                Log.Error("There is already a reference entry with the unique load ID of \"" + referenceable.GetUniqueLoadID() + "\"");
                return;
            }

            references.Add(referenceable.GetUniqueLoadID(), reference);
        }
コード例 #20
0
ファイル: SaveLoad.cs プロジェクト: PhoenixICE/Multiplayer
        static bool Prefix(LoadedObjectDirectory __instance, ref ILoadReferenceable reffable)
        {
            string text = "[excepted]";

            try
            {
                text = reffable.GetUniqueLoadID();
            }
            catch (Exception)
            {
            }

            ILoadReferenceable loadReferenceable;

            if (__instance.allObjectsByLoadID.TryGetValue(text, out loadReferenceable))
            {
                return(false);
            }
            return(true);
        }
コード例 #21
0
 public void RegisterReferenced(ILoadReferenceable obj, string label)
 {
     if (Prefs.DevMode)
     {
         if (Scribe.mode != LoadSaveMode.Saving)
         {
             Log.Error(string.Concat(new object[]
             {
                 "Registered ",
                 obj,
                 ", but current mode is ",
                 Scribe.mode
             }), false);
         }
         else if (obj != null)
         {
             this.referenced.Add(new DebugLoadIDsSavingErrorsChecker.ReferencedObject(obj.GetUniqueLoadID(), label));
         }
     }
 }
コード例 #22
0
 public void RegisterReferenced(ILoadReferenceable obj, string label)
 {
     if (!Prefs.DevMode)
     {
         return;
     }
     if (Scribe.mode != LoadSaveMode.Saving)
     {
         Log.Error(string.Concat("Registered ", obj, ", but current mode is ", Scribe.mode));
     }
     else if (obj != null)
     {
         try
         {
             referenced.Add(new ReferencedObject(obj.GetUniqueLoadID(), label));
         }
         catch (Exception arg)
         {
             Log.Error("Error in GetUniqueLoadID(): " + arg);
         }
     }
 }
コード例 #23
0
 public static void ResolveAllCrossReferences()
 {
     Scribe.mode = LoadSaveMode.ResolvingCrossRefs;
     using (List <IExposable> .Enumerator enumerator = Scribe.loader.crossRefs.crossReferencingExposables.GetEnumerator()) {
         while (enumerator.MoveNext())
         {
             ILoadReferenceable loadReferenceable = enumerator.Current as ILoadReferenceable;
             if (loadReferenceable != null)
             {
                 LoadedObjectDirectory loadedObjectDirectory = ReflectionUtil.GetFieldValue <LoadedObjectDirectory>(Scribe.loader.crossRefs, "loadedObjectDirectory");
                 if (loadedObjectDirectory != null)
                 {
                     loadedObjectDirectory.RegisterLoaded(loadReferenceable);
                 }
                 else
                 {
                     Logger.Warning("Could not access CrossRefHandler.loadedObjectDirectory in our version of ResolveAllCrossReferences()");
                 }
             }
         }
     }
     foreach (IExposable current in Scribe.loader.crossRefs.crossReferencingExposables)
     {
         try {
             Scribe.loader.curParent          = current;
             Scribe.loader.curPathRelToParent = null;
             current.ExposeData();
         }
         catch (Exception arg) {
             Log.Warning("Could not resolve cross refs: " + arg, false);
         }
     }
     Scribe.loader.curParent          = null;
     Scribe.loader.curPathRelToParent = null;
     Scribe.mode = LoadSaveMode.Inactive;
     Scribe.loader.crossRefs.Clear(false);
 }
コード例 #24
0
 public void RegisterLoaded(ILoadReferenceable reffable)
 {
     if (Prefs.DevMode)
     {
         string text = "[excepted]";
         try
         {
             text = reffable.GetUniqueLoadID();
         }
         catch (Exception)
         {
         }
         string text2 = "[excepted]";
         try
         {
             text2 = reffable.ToString();
         }
         catch (Exception)
         {
         }
         ILoadReferenceable loadReferenceable;
         if (this.allObjectsByLoadID.TryGetValue(text, out loadReferenceable))
         {
             Log.Error(string.Concat(new object[]
             {
                 "Cannot register ",
                 reffable.GetType(),
                 " ",
                 text2,
                 ", (id=",
                 text,
                 " in loaded object directory. Id already used by ",
                 loadReferenceable.GetType(),
                 " ",
                 loadReferenceable.ToString(),
                 "."
             }), false);
             return;
         }
     }
     try
     {
         this.allObjectsByLoadID.Add(reffable.GetUniqueLoadID(), reffable);
     }
     catch (Exception ex)
     {
         string text3 = "[excepted]";
         try
         {
             text3 = reffable.GetUniqueLoadID();
         }
         catch (Exception)
         {
         }
         string text4 = "[excepted]";
         try
         {
             text4 = reffable.ToString();
         }
         catch (Exception)
         {
         }
         Log.Error(string.Concat(new object[]
         {
             "Exception registering ",
             reffable.GetType(),
             " ",
             text4,
             " in loaded object directory with unique load ID ",
             text3,
             ": ",
             ex
         }), false);
     }
 }
コード例 #25
0
 /// <summary>
 /// The main constructor for the Reference class.
 /// </summary>
 /// <param name="pathOfFileContainingReference">The path of the file containing this reference.</param>
 /// <param name="reffable">The link to the loaded reference in memory.</param>
 public Reference(string pathOfFileContainingReference, ILoadReferenceable reffable)
 {
     this.pathOfFileContainingReference = pathOfFileContainingReference;
     this.reffable = reffable;
 }
コード例 #26
0
        public static void Look <T>(ref List <T> list, bool saveDestroyedThings, string label, LookMode lookMode = LookMode.Undefined, params object[] ctorArgs)
        {
            if (lookMode == LookMode.Undefined)
            {
                if (ParseHelper.HandlesType(typeof(T)))
                {
                    lookMode = LookMode.Value;
                }
                else if (typeof(T) == typeof(LocalTargetInfo))
                {
                    lookMode = LookMode.LocalTargetInfo;
                }
                else if (typeof(T) == typeof(TargetInfo))
                {
                    lookMode = LookMode.TargetInfo;
                }
                else if (typeof(T) == typeof(GlobalTargetInfo))
                {
                    lookMode = LookMode.GlobalTargetInfo;
                }
                else if (typeof(Def).IsAssignableFrom(typeof(T)))
                {
                    lookMode = LookMode.Def;
                }
                else if (typeof(T) == typeof(BodyPartRecord))
                {
                    lookMode = LookMode.BodyPart;
                }
                else
                {
                    if (!typeof(IExposable).IsAssignableFrom(typeof(T)) || typeof(ILoadReferenceable).IsAssignableFrom(typeof(T)))
                    {
                        Log.Error("LookList call with a list of " + typeof(T) + " must have lookMode set explicitly.");
                        return;
                    }
                    lookMode = LookMode.Deep;
                }
            }
            if (Scribe.EnterNode(label))
            {
                try
                {
                    if (Scribe.mode == LoadSaveMode.Saving)
                    {
                        if (list == null)
                        {
                            Scribe.saver.WriteAttribute("IsNull", "True");
                        }
                        else
                        {
                            foreach (T item8 in list)
                            {
                                switch (lookMode)
                                {
                                case LookMode.Value:
                                {
                                    T value5 = item8;
                                    Scribe_Values.Look(ref value5, "li", default(T), forceSave: true);
                                    break;
                                }

                                case LookMode.LocalTargetInfo:
                                {
                                    LocalTargetInfo value4 = (LocalTargetInfo)(object)item8;
                                    Scribe_TargetInfo.Look(ref value4, saveDestroyedThings, "li");
                                    break;
                                }

                                case LookMode.TargetInfo:
                                {
                                    TargetInfo value3 = (TargetInfo)(object)item8;
                                    Scribe_TargetInfo.Look(ref value3, saveDestroyedThings, "li");
                                    break;
                                }

                                case LookMode.GlobalTargetInfo:
                                {
                                    GlobalTargetInfo value2 = (GlobalTargetInfo)(object)item8;
                                    Scribe_TargetInfo.Look(ref value2, saveDestroyedThings, "li");
                                    break;
                                }

                                case LookMode.Def:
                                {
                                    Def value = (Def)(object)item8;
                                    Scribe_Defs.Look(ref value, "li");
                                    break;
                                }

                                case LookMode.BodyPart:
                                {
                                    BodyPartRecord part = (BodyPartRecord)(object)item8;
                                    Scribe_BodyParts.Look(ref part, "li");
                                    break;
                                }

                                case LookMode.Deep:
                                {
                                    T target = item8;
                                    Scribe_Deep.Look(ref target, saveDestroyedThings, "li", ctorArgs);
                                    break;
                                }

                                case LookMode.Reference:
                                {
                                    ILoadReferenceable refee = (ILoadReferenceable)(object)item8;
                                    Scribe_References.Look(ref refee, "li", saveDestroyedThings);
                                    break;
                                }
                                }
                            }
                        }
                    }
                    else if (Scribe.mode == LoadSaveMode.LoadingVars)
                    {
                        XmlNode      curXmlParent = Scribe.loader.curXmlParent;
                        XmlAttribute xmlAttribute = curXmlParent.Attributes["IsNull"];
                        if (xmlAttribute == null || !(xmlAttribute.Value.ToLower() == "true"))
                        {
                            switch (lookMode)
                            {
                            case LookMode.Value:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                IEnumerator enumerator3 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator3.MoveNext())
                                    {
                                        XmlNode subNode = (XmlNode)enumerator3.Current;
                                        T       item    = ScribeExtractor.ValueFromNode(subNode, default(T));
                                        list.Add(item);
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable2;
                                    if ((disposable2 = (enumerator3 as IDisposable)) != null)
                                    {
                                        disposable2.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.Deep:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                IEnumerator enumerator9 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator9.MoveNext())
                                    {
                                        XmlNode subNode3 = (XmlNode)enumerator9.Current;
                                        T       item7    = ScribeExtractor.SaveableFromNode <T>(subNode3, ctorArgs);
                                        list.Add(item7);
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable8;
                                    if ((disposable8 = (enumerator9 as IDisposable)) != null)
                                    {
                                        disposable8.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.Def:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                IEnumerator enumerator8 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator8.MoveNext())
                                    {
                                        XmlNode subNode2 = (XmlNode)enumerator8.Current;
                                        T       item6    = ScribeExtractor.DefFromNodeUnsafe <T>(subNode2);
                                        list.Add(item6);
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable7;
                                    if ((disposable7 = (enumerator8 as IDisposable)) != null)
                                    {
                                        disposable7.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.BodyPart:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int         num4        = 0;
                                IEnumerator enumerator7 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator7.MoveNext())
                                    {
                                        XmlNode node4 = (XmlNode)enumerator7.Current;
                                        T       item5 = (T)(object)ScribeExtractor.BodyPartFromNode(node4, num4.ToString(), null);
                                        list.Add(item5);
                                        num4++;
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable6;
                                    if ((disposable6 = (enumerator7 as IDisposable)) != null)
                                    {
                                        disposable6.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.LocalTargetInfo:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int         num3        = 0;
                                IEnumerator enumerator6 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator6.MoveNext())
                                    {
                                        XmlNode         node3           = (XmlNode)enumerator6.Current;
                                        LocalTargetInfo localTargetInfo = ScribeExtractor.LocalTargetInfoFromNode(node3, num3.ToString(), LocalTargetInfo.Invalid);
                                        T item4 = (T)(object)localTargetInfo;
                                        list.Add(item4);
                                        num3++;
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable5;
                                    if ((disposable5 = (enumerator6 as IDisposable)) != null)
                                    {
                                        disposable5.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.TargetInfo:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int         num2        = 0;
                                IEnumerator enumerator5 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator5.MoveNext())
                                    {
                                        XmlNode    node2      = (XmlNode)enumerator5.Current;
                                        TargetInfo targetInfo = ScribeExtractor.TargetInfoFromNode(node2, num2.ToString(), TargetInfo.Invalid);
                                        T          item3      = (T)(object)targetInfo;
                                        list.Add(item3);
                                        num2++;
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable4;
                                    if ((disposable4 = (enumerator5 as IDisposable)) != null)
                                    {
                                        disposable4.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.GlobalTargetInfo:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int         num         = 0;
                                IEnumerator enumerator4 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator4.MoveNext())
                                    {
                                        XmlNode          node             = (XmlNode)enumerator4.Current;
                                        GlobalTargetInfo globalTargetInfo = ScribeExtractor.GlobalTargetInfoFromNode(node, num.ToString(), GlobalTargetInfo.Invalid);
                                        T item2 = (T)(object)globalTargetInfo;
                                        list.Add(item2);
                                        num++;
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable3;
                                    if ((disposable3 = (enumerator4 as IDisposable)) != null)
                                    {
                                        disposable3.Dispose();
                                    }
                                }
                                break;
                            }

                            case LookMode.Reference:
                            {
                                List <string> list2       = new List <string>(curXmlParent.ChildNodes.Count);
                                IEnumerator   enumerator2 = curXmlParent.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        XmlNode xmlNode = (XmlNode)enumerator2.Current;
                                        list2.Add(xmlNode.InnerText);
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable;
                                    if ((disposable = (enumerator2 as IDisposable)) != null)
                                    {
                                        disposable.Dispose();
                                    }
                                }
                                Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(list2, string.Empty);
                                break;
                            }
                            }
                        }
                        else
                        {
                            list = null;
                        }
                    }
                    else if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs)
                    {
                        switch (lookMode)
                        {
                        case LookMode.Reference:
                            list = Scribe.loader.crossRefs.TakeResolvedRefList <T>(string.Empty);
                            break;

                        case LookMode.LocalTargetInfo:
                            if (list != null)
                            {
                                for (int j = 0; j < list.Count; j++)
                                {
                                    list[j] = (T)(object)ScribeExtractor.ResolveLocalTargetInfo((LocalTargetInfo)(object)list[j], j.ToString());
                                }
                            }
                            break;

                        case LookMode.TargetInfo:
                            if (list != null)
                            {
                                for (int k = 0; k < list.Count; k++)
                                {
                                    list[k] = (T)(object)ScribeExtractor.ResolveTargetInfo((TargetInfo)(object)list[k], k.ToString());
                                }
                            }
                            break;

                        case LookMode.GlobalTargetInfo:
                            if (list != null)
                            {
                                for (int i = 0; i < list.Count; i++)
                                {
                                    list[i] = (T)(object)ScribeExtractor.ResolveGlobalTargetInfo((GlobalTargetInfo)(object)list[i], i.ToString());
                                }
                            }
                            break;
                        }
                    }
                }
                finally
                {
                    Scribe.ExitNode();
                }
            }
            else if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                if (lookMode == LookMode.Reference)
                {
                    Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(null, label);
                }
                list = null;
            }
        }
コード例 #27
0
        public static void Look <T>(ref List <T> list, bool saveDestroyedThings, string label, LookMode lookMode = LookMode.Undefined, params object[] ctorArgs)
        {
            if (lookMode == LookMode.Undefined && !Scribe_Universal.TryResolveLookMode(typeof(T), out lookMode))
            {
                Log.Error("LookList call with a list of " + typeof(T) + " must have lookMode set explicitly.");
            }
            else if (Scribe.EnterNode(label))
            {
                try
                {
                    if (Scribe.mode == LoadSaveMode.Saving)
                    {
                        if (list == null)
                        {
                            Scribe.saver.WriteAttribute("IsNull", "True");
                        }
                        else
                        {
                            foreach (T item8 in list)
                            {
                                switch (lookMode)
                                {
                                case LookMode.Value:
                                {
                                    T value5 = item8;
                                    Scribe_Values.Look(ref value5, "li", default(T), forceSave: true);
                                    break;
                                }

                                case LookMode.LocalTargetInfo:
                                {
                                    LocalTargetInfo value4 = (LocalTargetInfo)(object)item8;
                                    Scribe_TargetInfo.Look(ref value4, saveDestroyedThings, "li");
                                    break;
                                }

                                case LookMode.TargetInfo:
                                {
                                    TargetInfo value3 = (TargetInfo)(object)item8;
                                    Scribe_TargetInfo.Look(ref value3, saveDestroyedThings, "li");
                                    break;
                                }

                                case LookMode.GlobalTargetInfo:
                                {
                                    GlobalTargetInfo value2 = (GlobalTargetInfo)(object)item8;
                                    Scribe_TargetInfo.Look(ref value2, saveDestroyedThings, "li");
                                    break;
                                }

                                case LookMode.Def:
                                {
                                    Def value = (Def)(object)item8;
                                    Scribe_Defs.Look(ref value, "li");
                                    break;
                                }

                                case LookMode.BodyPart:
                                {
                                    BodyPartRecord part = (BodyPartRecord)(object)item8;
                                    Scribe_BodyParts.Look(ref part, "li");
                                    break;
                                }

                                case LookMode.Deep:
                                {
                                    T target = item8;
                                    Scribe_Deep.Look(ref target, saveDestroyedThings, "li", ctorArgs);
                                    break;
                                }

                                case LookMode.Reference:
                                {
                                    ILoadReferenceable refee = (ILoadReferenceable)(object)item8;
                                    Scribe_References.Look(ref refee, "li", saveDestroyedThings);
                                    break;
                                }
                                }
                            }
                        }
                    }
                    else if (Scribe.mode == LoadSaveMode.LoadingVars)
                    {
                        XmlNode      curXmlParent = Scribe.loader.curXmlParent;
                        XmlAttribute xmlAttribute = curXmlParent.Attributes["IsNull"];
                        if (xmlAttribute != null && xmlAttribute.Value.ToLower() == "true")
                        {
                            if (lookMode == LookMode.Reference)
                            {
                                Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(null, null);
                            }
                            list = null;
                        }
                        else
                        {
                            switch (lookMode)
                            {
                            case LookMode.Value:
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                foreach (XmlNode childNode in curXmlParent.ChildNodes)
                                {
                                    T item = ScribeExtractor.ValueFromNode(childNode, default(T));
                                    list.Add(item);
                                }
                                break;

                            case LookMode.Deep:
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                foreach (XmlNode childNode2 in curXmlParent.ChildNodes)
                                {
                                    T item7 = ScribeExtractor.SaveableFromNode <T>(childNode2, ctorArgs);
                                    list.Add(item7);
                                }
                                break;

                            case LookMode.Def:
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                foreach (XmlNode childNode3 in curXmlParent.ChildNodes)
                                {
                                    T item6 = ScribeExtractor.DefFromNodeUnsafe <T>(childNode3);
                                    list.Add(item6);
                                }
                                break;

                            case LookMode.BodyPart:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int num4 = 0;
                                foreach (XmlNode childNode4 in curXmlParent.ChildNodes)
                                {
                                    T item5 = (T)(object)ScribeExtractor.BodyPartFromNode(childNode4, num4.ToString(), null);
                                    list.Add(item5);
                                    num4++;
                                }
                                break;
                            }

                            case LookMode.LocalTargetInfo:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int num3 = 0;
                                foreach (XmlNode childNode5 in curXmlParent.ChildNodes)
                                {
                                    T item4 = (T)(object)ScribeExtractor.LocalTargetInfoFromNode(childNode5, num3.ToString(), LocalTargetInfo.Invalid);
                                    list.Add(item4);
                                    num3++;
                                }
                                break;
                            }

                            case LookMode.TargetInfo:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int num2 = 0;
                                foreach (XmlNode childNode6 in curXmlParent.ChildNodes)
                                {
                                    T item3 = (T)(object)ScribeExtractor.TargetInfoFromNode(childNode6, num2.ToString(), TargetInfo.Invalid);
                                    list.Add(item3);
                                    num2++;
                                }
                                break;
                            }

                            case LookMode.GlobalTargetInfo:
                            {
                                list = new List <T>(curXmlParent.ChildNodes.Count);
                                int num = 0;
                                foreach (XmlNode childNode7 in curXmlParent.ChildNodes)
                                {
                                    T item2 = (T)(object)ScribeExtractor.GlobalTargetInfoFromNode(childNode7, num.ToString(), GlobalTargetInfo.Invalid);
                                    list.Add(item2);
                                    num++;
                                }
                                break;
                            }

                            case LookMode.Reference:
                            {
                                List <string> list2 = new List <string>(curXmlParent.ChildNodes.Count);
                                foreach (XmlNode childNode8 in curXmlParent.ChildNodes)
                                {
                                    list2.Add(childNode8.InnerText);
                                }
                                Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(list2, "");
                                break;
                            }
                            }
                        }
                    }
                    else if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs)
                    {
                        switch (lookMode)
                        {
                        case LookMode.Reference:
                            list = Scribe.loader.crossRefs.TakeResolvedRefList <T>("");
                            break;

                        case LookMode.LocalTargetInfo:
                            if (list != null)
                            {
                                for (int j = 0; j < list.Count; j++)
                                {
                                    list[j] = (T)(object)ScribeExtractor.ResolveLocalTargetInfo((LocalTargetInfo)(object)list[j], j.ToString());
                                }
                            }
                            break;

                        case LookMode.TargetInfo:
                            if (list != null)
                            {
                                for (int k = 0; k < list.Count; k++)
                                {
                                    list[k] = (T)(object)ScribeExtractor.ResolveTargetInfo((TargetInfo)(object)list[k], k.ToString());
                                }
                            }
                            break;

                        case LookMode.GlobalTargetInfo:
                            if (list != null)
                            {
                                for (int i = 0; i < list.Count; i++)
                                {
                                    list[i] = (T)(object)ScribeExtractor.ResolveGlobalTargetInfo((GlobalTargetInfo)(object)list[i], i.ToString());
                                }
                            }
                            break;
                        }
                    }
                }
                finally
                {
                    Scribe.ExitNode();
                }
            }
            else if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                if (lookMode == LookMode.Reference)
                {
                    Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(null, label);
                }
                list = null;
            }
        }
コード例 #28
0
 public static void Look <T>(ref List <T> list, bool saveDestroyedThings, string label, LookMode lookMode = LookMode.Undefined, params object[] ctorArgs)
 {
     if (lookMode == LookMode.Undefined)
     {
         if (ParseHelper.HandlesType(typeof(T)))
         {
             lookMode = LookMode.Value;
         }
         else if (typeof(T) == typeof(LocalTargetInfo))
         {
             lookMode = LookMode.LocalTargetInfo;
         }
         else if (typeof(T) == typeof(TargetInfo))
         {
             lookMode = LookMode.TargetInfo;
         }
         else if (typeof(T) == typeof(GlobalTargetInfo))
         {
             lookMode = LookMode.GlobalTargetInfo;
         }
         else if (typeof(Def).IsAssignableFrom(typeof(T)))
         {
             lookMode = LookMode.Def;
         }
         else if (typeof(T) == typeof(BodyPartRecord))
         {
             lookMode = LookMode.BodyPart;
         }
         else
         {
             if (!typeof(IExposable).IsAssignableFrom(typeof(T)) || typeof(ILoadReferenceable).IsAssignableFrom(typeof(T)))
             {
                 Log.Error("LookList call with a list of " + typeof(T) + " must have lookMode set explicitly.", false);
                 return;
             }
             lookMode = LookMode.Deep;
         }
     }
     if (Scribe.EnterNode(label))
     {
         try
         {
             if (Scribe.mode == LoadSaveMode.Saving)
             {
                 if (list == null)
                 {
                     Scribe.saver.WriteAttribute("IsNull", "True");
                 }
                 else
                 {
                     foreach (T current in list)
                     {
                         if (lookMode == LookMode.Value)
                         {
                             T t = current;
                             Scribe_Values.Look <T>(ref t, "li", default(T), true);
                         }
                         else if (lookMode == LookMode.LocalTargetInfo)
                         {
                             LocalTargetInfo localTargetInfo = (LocalTargetInfo)((object)current);
                             Scribe_TargetInfo.Look(ref localTargetInfo, saveDestroyedThings, "li");
                         }
                         else if (lookMode == LookMode.TargetInfo)
                         {
                             TargetInfo targetInfo = (TargetInfo)((object)current);
                             Scribe_TargetInfo.Look(ref targetInfo, saveDestroyedThings, "li");
                         }
                         else if (lookMode == LookMode.GlobalTargetInfo)
                         {
                             GlobalTargetInfo globalTargetInfo = (GlobalTargetInfo)((object)current);
                             Scribe_TargetInfo.Look(ref globalTargetInfo, saveDestroyedThings, "li");
                         }
                         else if (lookMode == LookMode.Def)
                         {
                             Def def = (Def)((object)current);
                             Scribe_Defs.Look <Def>(ref def, "li");
                         }
                         else if (lookMode == LookMode.BodyPart)
                         {
                             BodyPartRecord bodyPartRecord = (BodyPartRecord)((object)current);
                             Scribe_BodyParts.Look(ref bodyPartRecord, "li", null);
                         }
                         else if (lookMode == LookMode.Deep)
                         {
                             T t2 = current;
                             Scribe_Deep.Look <T>(ref t2, saveDestroyedThings, "li", ctorArgs);
                         }
                         else if (lookMode == LookMode.Reference)
                         {
                             ILoadReferenceable loadReferenceable = (ILoadReferenceable)((object)current);
                             Scribe_References.Look <ILoadReferenceable>(ref loadReferenceable, "li", saveDestroyedThings);
                         }
                     }
                 }
             }
             else if (Scribe.mode == LoadSaveMode.LoadingVars)
             {
                 XmlNode      curXmlParent = Scribe.loader.curXmlParent;
                 XmlAttribute xmlAttribute = curXmlParent.Attributes["IsNull"];
                 if (xmlAttribute != null && xmlAttribute.Value.ToLower() == "true")
                 {
                     list = null;
                 }
                 else if (lookMode == LookMode.Value)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode subNode in curXmlParent.ChildNodes)
                     {
                         T item = ScribeExtractor.ValueFromNode <T>(subNode, default(T));
                         list.Add(item);
                     }
                 }
                 else if (lookMode == LookMode.Deep)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode subNode2 in curXmlParent.ChildNodes)
                     {
                         T item2 = ScribeExtractor.SaveableFromNode <T>(subNode2, ctorArgs);
                         list.Add(item2);
                     }
                 }
                 else if (lookMode == LookMode.Def)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode subNode3 in curXmlParent.ChildNodes)
                     {
                         T item3 = ScribeExtractor.DefFromNodeUnsafe <T>(subNode3);
                         list.Add(item3);
                     }
                 }
                 else if (lookMode == LookMode.BodyPart)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num = 0;
                     foreach (XmlNode node in curXmlParent.ChildNodes)
                     {
                         T item4 = (T)((object)ScribeExtractor.BodyPartFromNode(node, num.ToString(), null));
                         list.Add(item4);
                         num++;
                     }
                 }
                 else if (lookMode == LookMode.LocalTargetInfo)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num2 = 0;
                     foreach (XmlNode node2 in curXmlParent.ChildNodes)
                     {
                         LocalTargetInfo localTargetInfo2 = ScribeExtractor.LocalTargetInfoFromNode(node2, num2.ToString(), LocalTargetInfo.Invalid);
                         T item5 = (T)((object)localTargetInfo2);
                         list.Add(item5);
                         num2++;
                     }
                 }
                 else if (lookMode == LookMode.TargetInfo)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num3 = 0;
                     foreach (XmlNode node3 in curXmlParent.ChildNodes)
                     {
                         TargetInfo targetInfo2 = ScribeExtractor.TargetInfoFromNode(node3, num3.ToString(), TargetInfo.Invalid);
                         T          item6       = (T)((object)targetInfo2);
                         list.Add(item6);
                         num3++;
                     }
                 }
                 else if (lookMode == LookMode.GlobalTargetInfo)
                 {
                     list = new List <T>(curXmlParent.ChildNodes.Count);
                     int num4 = 0;
                     foreach (XmlNode node4 in curXmlParent.ChildNodes)
                     {
                         GlobalTargetInfo globalTargetInfo2 = ScribeExtractor.GlobalTargetInfoFromNode(node4, num4.ToString(), GlobalTargetInfo.Invalid);
                         T item7 = (T)((object)globalTargetInfo2);
                         list.Add(item7);
                         num4++;
                     }
                 }
                 else if (lookMode == LookMode.Reference)
                 {
                     List <string> list2 = new List <string>(curXmlParent.ChildNodes.Count);
                     foreach (XmlNode xmlNode in curXmlParent.ChildNodes)
                     {
                         list2.Add(xmlNode.InnerText);
                     }
                     Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(list2, string.Empty);
                 }
             }
             else if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs)
             {
                 if (lookMode == LookMode.Reference)
                 {
                     list = Scribe.loader.crossRefs.TakeResolvedRefList <T>(string.Empty);
                 }
                 else if (lookMode == LookMode.LocalTargetInfo)
                 {
                     if (list != null)
                     {
                         for (int i = 0; i < list.Count; i++)
                         {
                             list[i] = (T)((object)ScribeExtractor.ResolveLocalTargetInfo((LocalTargetInfo)((object)list[i]), i.ToString()));
                         }
                     }
                 }
                 else if (lookMode == LookMode.TargetInfo)
                 {
                     if (list != null)
                     {
                         for (int j = 0; j < list.Count; j++)
                         {
                             list[j] = (T)((object)ScribeExtractor.ResolveTargetInfo((TargetInfo)((object)list[j]), j.ToString()));
                         }
                     }
                 }
                 else if (lookMode == LookMode.GlobalTargetInfo && list != null)
                 {
                     for (int k = 0; k < list.Count; k++)
                     {
                         list[k] = (T)((object)ScribeExtractor.ResolveGlobalTargetInfo((GlobalTargetInfo)((object)list[k]), k.ToString()));
                     }
                 }
             }
         }
         finally
         {
             Scribe.ExitNode();
         }
     }
     else if (Scribe.mode == LoadSaveMode.LoadingVars)
     {
         if (lookMode == LookMode.Reference)
         {
             Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(null, label);
         }
         list = null;
     }
 }
コード例 #29
0
        public void ExposeData()
        {
            ILoadReferenceable refee = (ILoadReferenceable)commTarget;

            Scribe_References.Look(ref refee, "commTarget");
            commTarget = (ICommunicable)refee;
            Scribe_References.Look(ref verbToUse, "verbToUse");
            Scribe_References.Look(ref bill, "bill");
            Scribe_References.Look(ref lord, "lord");
            Scribe_References.Look(ref quest, "quest");
            Scribe_Defs.Look(ref def, "def");
            //Scribe_Values.Look(ref loadID, "loadID", 0);
            Scribe_TargetInfo.Look(ref targetA, "targetA");
            Scribe_TargetInfo.Look(ref targetB, "targetB");
            Scribe_TargetInfo.Look(ref targetC, "targetC");
            Scribe_TargetInfo.Look(ref globalTarget, "globalTarget");
            Scribe_Collections.Look(ref targetQueueA, "targetQueueA", LookMode.Undefined);
            Scribe_Collections.Look(ref targetQueueB, "targetQueueB", LookMode.Undefined);
            Scribe_Values.Look(ref count, "count", -1);
            Scribe_Collections.Look(ref countQueue, "countQueue", LookMode.Undefined);
            Scribe_Values.Look(ref startTick, "startTick", -1);
            Scribe_Values.Look(ref expiryInterval, "expiryInterval", -1);
            Scribe_Values.Look(ref checkOverrideOnExpire, "checkOverrideOnExpire", defaultValue: false);
            Scribe_Values.Look(ref playerForced, "playerForced", defaultValue: false);
            Scribe_Collections.Look(ref placedThings, "placedThings", LookMode.Undefined);
            Scribe_Values.Look(ref maxNumMeleeAttacks, "maxNumMeleeAttacks", int.MaxValue);
            Scribe_Values.Look(ref maxNumStaticAttacks, "maxNumStaticAttacks", int.MaxValue);
            Scribe_Values.Look(ref exitMapOnArrival, "exitMapOnArrival", defaultValue: false);
            Scribe_Values.Look(ref failIfCantJoinOrCreateCaravan, "failIfCantJoinOrCreateCaravan", defaultValue: false);
            Scribe_Values.Look(ref killIncappedTarget, "killIncappedTarget", defaultValue: false);
            Scribe_Values.Look(ref haulOpportunisticDuplicates, "haulOpportunisticDuplicates", defaultValue: false);
            Scribe_Values.Look(ref haulMode, "haulMode", HaulMode.Undefined);
            Scribe_Defs.Look(ref plantDefToSow, "plantDefToSow");
            Scribe_Values.Look(ref locomotionUrgency, "locomotionUrgency", LocomotionUrgency.Jog);
            Scribe_Values.Look(ref ignoreDesignations, "ignoreDesignations", defaultValue: false);
            Scribe_Values.Look(ref canBash, "canBash", defaultValue: false);
            Scribe_Values.Look(ref canUseRangedWeapon, "canUseRangedWeapon", defaultValue: true);
            Scribe_Values.Look(ref haulDroppedApparel, "haulDroppedApparel", defaultValue: false);
            Scribe_Values.Look(ref restUntilHealed, "restUntilHealed", defaultValue: false);
            Scribe_Values.Look(ref ignoreJoyTimeAssignment, "ignoreJoyTimeAssignment", defaultValue: false);
            Scribe_Values.Look(ref overeat, "overeat", defaultValue: false);
            Scribe_Values.Look(ref attackDoorIfTargetLost, "attackDoorIfTargetLost", defaultValue: false);
            Scribe_Values.Look(ref takeExtraIngestibles, "takeExtraIngestibles", 0);
            Scribe_Values.Look(ref expireRequiresEnemiesNearby, "expireRequiresEnemiesNearby", defaultValue: false);
            Scribe_Values.Look(ref collideWithPawns, "collideWithPawns", defaultValue: false);
            Scribe_Values.Look(ref forceSleep, "forceSleep", defaultValue: false);
            Scribe_Defs.Look(ref interaction, "interaction");
            Scribe_Values.Look(ref endIfCantShootTargetFromCurPos, "endIfCantShootTargetFromCurPos", defaultValue: false);
            Scribe_Values.Look(ref endIfCantShootInMelee, "endIfCantShootInMelee", defaultValue: false);
            Scribe_Values.Look(ref checkEncumbrance, "checkEncumbrance", defaultValue: false);
            Scribe_Values.Look(ref followRadius, "followRadius", 0f);
            Scribe_Values.Look(ref endAfterTendedOnce, "endAfterTendedOnce", defaultValue: false);
            Scribe_Defs.Look(ref workGiverDef, "workGiverDef");
            //Scribe_Defs.Look(ref jobGiverThinkTree, "jobGiverThinkTree");
            Scribe_Values.Look(ref doUntilGatheringEnded, "doUntilGatheringEnded", defaultValue: false);
            Scribe_Values.Look(ref psyfocusTargetLast, "psyfocusTargetLast", 0f);
            Scribe_Values.Look(ref wasOnMeditationTimeAssignment, "wasOnMeditationTimeAssignment", defaultValue: false);
            Scribe_Values.Look(ref reactingToMeleeThreat, "reactingToMeleeThreat", defaultValue: false);
            Scribe_References.Look(ref ability, "ability");
            //if (Scribe.mode == LoadSaveMode.Saving)
            //{
            //    jobGiverKey = ((jobGiver != null) ? jobGiver.UniqueSaveKey : (-1));
            //}
            //Scribe_Values.Look(ref jobGiverKey, "lastJobGiverKey", -1);
            //if (Scribe.mode == LoadSaveMode.PostLoadInit && jobGiverKey != -1 && !jobGiverThinkTree.TryGetThinkNodeWithSaveKey(jobGiverKey, out jobGiver))
            //{
            //    Log.Warning("Could not find think node with key " + jobGiverKey);
            //}
            if (Scribe.mode == LoadSaveMode.PostLoadInit && verbToUse != null && verbToUse.BuggedAfterLoading)
            {
                verbToUse = null;
                Log.Warning(string.Concat(GetType(), " had a bugged verbToUse after loading."));
            }
        }
コード例 #30
0
ファイル: ScribeUtil.cs プロジェクト: pickar2/Multiplayer
 public void Unregister(ILoadReferenceable reffable)
 {
     allObjectsByLoadID.Remove(reffable.GetUniqueLoadID());
 }