/// <summary> /// Deserialization Constructor /// </summary> public StatData(StatPacket statPacket, List <StatData> appliedStats) { Debug.Assert(statPacket != null, "New StatData being given a null StatPacket!"); Debug.Assert(appliedStats != null, "New StatData being given null list of applied stats!"); this.statId = new SaveableGuid(statPacket.statId); this.statReference = RpgDataRegistry.Instance.SearchAnyStat(this.statId.GuidData); Debug.Assert(this.statReference != null, "Could not deserialize a stat because its definition cannot be found. ID: " + statPacket.statId); this.type = this.statReference.GetStatType(); this.rawSpPool = statPacket.rawSpPool; this.useFactor = statPacket.useFactor; this.characterAppliedStats = appliedStats; // Initialize the SpDeriver switch (this.type) { case StatType.Base: this.linkedStatsDerivedPool = new BaseSpDeriver(this.statReference as BaseStat); break; case StatType.Secondary: this.linkedStatsDerivedPool = new SecondarySpDeriver(this.statReference as SecondaryStat); break; case StatType.Skill: this.linkedStatsDerivedPool = new SkillSpDeriver(this.statReference as SkillStat); break; default: Debug.LogError("Somebody added a new entry into the enum StatType"); break; } // Initialize the AbilityAggregator this.abilityModifications = new AbilityAggregator(this.statId.GuidData); }