public void SetValue(ColonistHistoryRecord other) { if (this.IsList) { this.Values = new List <object>(other.Values); } else { if (this.ValueType == typeof(int)) { this.Value = (int)other.Value; return; } else if (this.ValueType == typeof(float)) { this.Value = (float)other.Value; return; } else if (this.ValueType == typeof(string)) { string s = other.Value as string; if (s != null) { this.Value = String.Copy(s); } else { this.Value = null; } return; } Log.Warning("ValueType is " + this.ValueType); this.Value = other.Value; } }
public static void ResolveDrawEntries(ColonistHistoryData data) { RecordReportUtility.cachedDrawEntries.Clear(); if (ColonistHistoryMod.Settings.hideUnrecorded) { foreach (ColonistHistoryDef def in ColonistHistoryMod.Settings.ColonistHistorysOrder) { foreach (ColonistHistoryRecord record in data.records.records) { if (def == record.Parent) { RecordReportUtility.cachedDrawEntries.Add(new RecordDrawEntry(record)); } } } } else { CompRecorder.ResolveAvailableRecords(); foreach (ColonistHistoryDef def in ColonistHistoryMod.Settings.ColonistHistorysOrder) { foreach (RecordIdentifier recordID in CompRecorder.AvailableRecords) { if (recordID.colonistHistoryDef == def) { ColonistHistoryRecord record = data.GetRecord(recordID, true); RecordReportUtility.cachedDrawEntries.Add(new RecordDrawEntry(record)); } } } } }
public bool IsEqualValue(ColonistHistoryRecord other) { if (!this.RecordID.IsSame(other.RecordID)) { return(false); } if (!this.IsList) { if ((this.Value != null) != (other.Value != null)) { return(false); } else if ((this.Value == null) && (other.Value == null)) { return(true); } return(this.Value.Equals(other.Value)); } else { if (this.Values.NullOrEmpty() != other.Values.NullOrEmpty()) { return(false); } else if (this.Values.NullOrEmpty() && other.Values.NullOrEmpty()) { return(true); } return(this.Values.SequenceEqual(other.Values)); } }
public ColonistHistoryRecord(ColonistHistoryRecord src) { this.Def = src.Def; this.Label = src.Label; this.Parent = src.Parent; if (src.IsList) { this.Values = src.Values; } else { this.Value = src.Value; } this.ValueType = Parent.valueType; this.DefType = Parent.defType; this.isUnrecorded = src.IsUnrecorded; if (Value == null) { Value = "ColonistHistory.NullValue".Translate(); this.isNull = true; } if (this.isUnrecorded) { Value = "ColonistHistory.UnrecordedValue".Translate(); } }
public override string GetValueAsString(ColonistHistoryRecord record) { if (record.Value is int) { return(((int)record.Value).ToStringTicksToPeriod(true, false, true, true)); } return(base.GetValueAsString(record)); }
public override string GetValueAsString(ColonistHistoryRecord record) { if (record.Value is float) { return(((float)record.Value).ToString("0.##")); } return(base.GetValueAsString(record)); }
public ColonistHistoryRecord GetRecord(RecordIdentifier recordID, bool returnUnrecorded) { ColonistHistoryRecord record = this.records.records.Find(r => r.RecordID.Equals(recordID)); if (record == null && returnUnrecorded) { return(new ColonistHistoryRecord(recordID)); } return(record); }
private static void RegisterValue(ColonistHistoryRecord record) { if (!record.IsList) { LightWeightSaver.tableValues[record.RecordID] = record.Value; } else { LightWeightSaver.tableValues[record.RecordID] = record.Values; } }
private static bool RegisterTable(ColonistHistoryRecord record) { if (!LightWeightSaver.tableIsUnrecorded.ContainsKey(record.RecordID)) { LightWeightSaver.tableIsUnrecorded[record.RecordID] = record.IsUnrecorded; } else if (LightWeightSaver.tableIsUnrecorded[record.RecordID] != record.IsUnrecorded) { LightWeightSaver.tableIsUnrecorded[record.RecordID] = record.IsUnrecorded; RegisterValue(record); return(true); } if (!LightWeightSaver.tableValues.ContainsKey(record.RecordID)) { RegisterValue(record); return(true); } bool isChanged = false; if (!record.IsList) { if (record.IsNull) { isChanged = LightWeightSaver.tableValues[record.RecordID] != null; } else { isChanged = !record.Value.Equals(LightWeightSaver.tableValues[record.RecordID]); } } else { if (record.IsNullOrEmpty) { isChanged = LightWeightSaver.tableValues[record.RecordID] != null; } else { isChanged = !record.Values.SequenceEqual((List <object>)LightWeightSaver.tableValues[record.RecordID]); } } if (isChanged) { RegisterValue(record); } return(isChanged); }
public void ResolveGraph() { this.cachedGraph = new Dictionary <Pawn, List <Vector2> >(); if (this.comp != null) { foreach (Pawn pawn in this.comp.Colonists) { ColonistHistoryDataList dataList = this.comp.GetRecords(pawn); if (!dataList.log.NullOrEmpty()) { this.cachedGraph[pawn] = new List <Vector2>(); if (dataList != null) { foreach (ColonistHistoryData data in dataList.log) { ColonistHistoryRecord record = data.GetRecord(recordID, false); if ((record != null && !record.IsUnrecorded) || ColonistHistoryMod.Settings.treatingUnrecordedAsZero) { float x = GenDate.TickAbsToGame(data.recordTick); float y = 0f; if (record != null) { y = record.ValueForGraph; } if (this.cachedGraph[pawn].Count == 0 && ColonistHistoryMod.Settings.addZeroBeforeFirst) { this.cachedGraph[pawn].Add(new Vector2(x - 0.001f, 0)); } this.cachedGraph[pawn].Add(new Vector2(x, y)); } } } } } } }
public RecordDrawEntry(ColonistHistoryRecord data) { this.data = data; }
public virtual string GetValueAsString(ColonistHistoryRecord record) { return(record.Value.ToStringSafe()); }
public virtual string GetValuesAsString(ColonistHistoryRecord record) { return(string.Join(", ", record.Values.Select(value => this.GetValuesAsStringInternal(value)))); }