public virtual void ExposeData() { Scribe_Defs.Look(ref def, "def"); if (def.HasThingIDNumber) { string value = ThingID; Scribe_Values.Look(ref value, "id"); ThingID = value; } Scribe_Values.Look <sbyte>(ref mapIndexOrState, "map", -1); if (Scribe.mode == LoadSaveMode.LoadingVars && mapIndexOrState >= 0) { mapIndexOrState = -1; } Scribe_Values.Look(ref positionInt, "pos", IntVec3.Invalid); Scribe_Values.Look(ref rotationInt, "rot", Rot4.North); if (def.useHitPoints) { Scribe_Values.Look(ref hitPointsInt, "health", -1); } bool flag = def.tradeability != 0 && def.category == ThingCategory.Item; if (def.stackLimit > 1 || flag) { Scribe_Values.Look(ref stackCount, "stackCount", 0, forceSave: true); } Scribe_Defs.Look(ref stuffInt, "stuff"); string facID = (factionInt == null) ? "null" : factionInt.GetUniqueLoadID(); Scribe_Values.Look(ref facID, "faction", "null"); if (Scribe.mode == LoadSaveMode.LoadingVars || Scribe.mode == LoadSaveMode.ResolvingCrossRefs || Scribe.mode == LoadSaveMode.PostLoadInit) { if (facID == "null") { factionInt = null; } else if (Find.World != null && Find.FactionManager != null) { factionInt = Find.FactionManager.AllFactions.FirstOrDefault((Faction fa) => fa.GetUniqueLoadID() == facID); } } if (Scribe.mode == LoadSaveMode.PostLoadInit) { BackCompatibility.ThingPostLoadInit(this); } }
public virtual void ExposeData() { Scribe_Defs.Look <ThingDef>(ref this.def, "def"); if (this.def.HasThingIDNumber) { string thingID = this.ThingID; Scribe_Values.Look <string>(ref thingID, "id", null, false); this.ThingID = thingID; } Scribe_Values.Look <sbyte>(ref this.mapIndexOrState, "map", -1, false); if (Scribe.mode == LoadSaveMode.LoadingVars && (int)this.mapIndexOrState >= 0) { this.mapIndexOrState = -1; } Scribe_Values.Look <IntVec3>(ref this.positionInt, "pos", IntVec3.Invalid, false); Scribe_Values.Look <Rot4>(ref this.rotationInt, "rot", Rot4.North, false); if (this.def.useHitPoints) { Scribe_Values.Look <int>(ref this.hitPointsInt, "health", -1, false); } bool flag = this.def.tradeability != Tradeability.None && this.def.category == ThingCategory.Item; if (this.def.stackLimit > 1 || flag) { Scribe_Values.Look <int>(ref this.stackCount, "stackCount", 0, true); } Scribe_Defs.Look <ThingDef>(ref this.stuffInt, "stuff"); string facID = (this.factionInt == null) ? "null" : this.factionInt.GetUniqueLoadID(); Scribe_Values.Look <string>(ref facID, "faction", "null", false); if (Scribe.mode == LoadSaveMode.LoadingVars || Scribe.mode == LoadSaveMode.ResolvingCrossRefs || Scribe.mode == LoadSaveMode.PostLoadInit) { if (facID == "null") { this.factionInt = null; } else if (Find.World != null && Find.FactionManager != null) { this.factionInt = Find.FactionManager.AllFactions.FirstOrDefault((Faction fa) => fa.GetUniqueLoadID() == facID); } } if (Scribe.mode == LoadSaveMode.PostLoadInit) { BackCompatibility.ThingPostLoadInit(this); } }