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); } }
private void ExposeFactionData() { if (Scribe.mode == LoadSaveMode.Saving) { int currentFactionId = Faction.OfPlayer.loadID; Scribe_Custom.LookValue(currentFactionId, "currentFactionId"); var data = new Dictionary <int, FactionMapData>(factionData); data.Remove(currentFactionId); Scribe_Custom.LookValueDeep(ref data, "factionMapData", map); } else { // The faction whose data is currently set Scribe_Values.Look(ref currentFactionId, "currentFactionId"); Scribe_Custom.LookValueDeep(ref factionData, "factionMapData", map); if (factionData == null) { factionData = new Dictionary <int, FactionMapData>(); } } if (Scribe.mode == LoadSaveMode.LoadingVars) { factionData[currentFactionId] = FactionMapData.NewFromMap(map, currentFactionId); } }
public static void InitFactionDataFromMap(Map map, Faction f) { var mapComp = map.MpComp(); mapComp.factionData[f.loadID] = FactionMapData.NewFromMap(map, f.loadID); var customData = mapComp.customFactionData[f.loadID] = CustomFactionMapData.New(f.loadID, map); foreach (var t in map.listerThings.AllThings) { if (t is ThingWithComps tc && tc.GetComp <CompForbiddable>() is { forbiddenInt: false })
static void DoDebugInfo() { if (MpVersion.IsDebug && Multiplayer.Client != null) { int timerLag = (TickPatch.tickUntil - TickPatch.Timer); string text = $"{Find.TickManager.TicksGame} {TickPatch.Timer} {TickPatch.tickUntil} {timerLag} {Time.deltaTime * 60f}"; Rect rect = new Rect(80f, 60f, 330f, Text.CalcHeight(text, 330f)); Widgets.Label(rect, text); } if (MpVersion.IsDebug && Multiplayer.Client != null && Find.CurrentMap != null) { var async = Find.CurrentMap.AsyncTime(); StringBuilder text = new StringBuilder(); text.Append(async.mapTicks); text.Append($" d: {Find.CurrentMap.designationManager.allDesignations.Count}"); if (Find.CurrentMap.ParentFaction != null) { int faction = Find.CurrentMap.ParentFaction.loadID; MultiplayerMapComp comp = Find.CurrentMap.MpComp(); FactionMapData data = comp.factionMapData.GetValueSafe(faction); if (data != null) { text.Append($" h: {data.listerHaulables.ThingsPotentiallyNeedingHauling().Count}"); text.Append($" sg: {data.haulDestinationManager.AllGroupsListForReading.Count}"); } } text.Append($" {Multiplayer.GlobalIdBlock.current}"); text.Append($"\n{Sync.bufferedChanges.Sum(kv => kv.Value.Count)}"); text.Append($"\n{((uint)async.randState)} {(uint)(async.randState >> 32)}"); text.Append($"\n{(uint)Multiplayer.WorldComp.randState} {(uint)(Multiplayer.WorldComp.randState >> 32)}"); text.Append($"\n{async.cmds.Count} {Multiplayer.WorldComp.cmds.Count} {async.slower.ForcedNormalSpeed}"); Rect rect1 = new Rect(80f, 110f, 330f, Text.CalcHeight(text.ToString(), 330f)); Widgets.Label(rect1, text.ToString()); } }
static void DoDebugInfo() { if (Multiplayer.ShowDevInfo) { int timerLag = (TickPatch.tickUntil - TickPatch.Timer); StringBuilder text = new StringBuilder(); text.Append($"{Faction.OfPlayer.loadID} {Multiplayer.RealPlayerFaction?.loadID} {Find.UniqueIDsManager.nextThingID} j:{Find.UniqueIDsManager.nextJobID} {Find.TickManager.TicksGame} {TickPatch.Timer} {TickPatch.tickUntil} {timerLag} {TickPatch.maxBehind}"); text.Append($"\n{Time.deltaTime * 60f:0.0000} {TickPatch.tickTimer.ElapsedMilliseconds}"); text.Append($"\n{avgDelta = (avgDelta * 59.0 + Time.deltaTime * 60.0) / 60.0:0.0000}"); text.Append($"\n{avgTickTime = (avgTickTime * 59.0 + TickPatch.tickTimer.ElapsedMilliseconds) / 60.0:0.0000} {Find.World.worldObjects.settlements.Count}"); text.Append($"\n{Multiplayer.session?.localCmdId} {Multiplayer.session?.remoteCmdId} {Multiplayer.session?.remoteTickUntil}"); Rect rect = new Rect(80f, 60f, 330f, Text.CalcHeight(text.ToString(), 330f)); Widgets.Label(rect, text.ToString()); if (Input.GetKey(KeyCode.End)) { avgDelta = 0; avgTickTime = 0; } } if (Multiplayer.ShowDevInfo && Multiplayer.Client != null && Find.CurrentMap != null) { var async = Find.CurrentMap.AsyncTime(); StringBuilder text = new StringBuilder(); text.Append($"{Multiplayer.game.sync.knownClientOpinions.FirstOrDefault()?.isLocalClientsOpinion} {async.mapTicks} {TickPatch.shouldPause} {TickPatch.pausedAt} "); text.Append($"z: {Find.CurrentMap.haulDestinationManager.AllHaulDestinationsListForReading.Count()} d: {Find.CurrentMap.designationManager.allDesignations.Count} hc: {Find.CurrentMap.listerHaulables.ThingsPotentiallyNeedingHauling().Count}"); if (Find.CurrentMap.ParentFaction != null) { int faction = Find.CurrentMap.ParentFaction.loadID; MultiplayerMapComp comp = Find.CurrentMap.MpComp(); FactionMapData data = comp.factionData.GetValueSafe(faction); if (data != null) { text.Append($" h: {data.listerHaulables.ThingsPotentiallyNeedingHauling().Count}"); text.Append($" sg: {data.haulDestinationManager.AllGroupsListForReading.Count}"); } } text.Append($" {Multiplayer.GlobalIdBlock.Current} {Find.IdeoManager.IdeosInViewOrder.FirstOrDefault()?.id}"); text.Append($"\n{SyncFieldUtil.bufferedChanges.Sum(kv => kv.Value.Count)} {Find.UniqueIDsManager.nextThingID}"); text.Append($"\n{DeferredStackTracing.acc} {MpInput.Mouse2UpWithoutDrag} {Input.GetKeyUp(KeyCode.Mouse2)} {Input.GetKey(KeyCode.Mouse2)}"); text.Append($"\n{(uint)async.randState} {(uint)(async.randState >> 32)}"); text.Append($"\n{(uint)Multiplayer.WorldComp.randState} {(uint)(Multiplayer.WorldComp.randState >> 32)}"); text.Append($"\n{async.cmds.Count} {Multiplayer.WorldComp.cmds.Count} {async.slower.forceNormalSpeedUntil} {Multiplayer.GameComp.asyncTime}"); text.Append($"\nt{DeferredStackTracing.maxTraceDepth} p{SimplePool<StackTraceLogItemRaw>.FreeItemsCount} {DeferredStackTracingImpl.hashtableEntries}/{DeferredStackTracingImpl.hashtableSize} {DeferredStackTracingImpl.collisions}"); text.Append(Find.WindowStack.focusedWindow is ImmediateWindow win ? $"\nImmediateWindow: {MpUtil.DelegateMethodInfo(win.doWindowFunc?.Method)}" : $"\n{Find.WindowStack.focusedWindow}"); text.Append($"\n{UI.CurUICellSize()} {Find.WindowStack.windows.ToStringSafeEnumerable()}"); Rect rect1 = new Rect(80f, 170f, 330f, Text.CalcHeight(text.ToString(), 330f)); Widgets.Label(rect1, text.ToString()); } //if (Event.current.type == EventType.Repaint) // RandGetValuePatch.tracesThistick = 0; }