//
        // Stats
        //



        /// <summary>
        ///     Adds a new Stat to this Character. Also creates an internal record for the stat.
        ///     Will not add a particular stat more than once.
        /// </summary>
        public void AddStat(AbstractStat newStat)
        {
            // Check if this stat was already added
            StatData statData = this.SearchStat(newStat);

            // Add the stat
            if (statData == null)
            {
                statData = new StatData(newStat, this.appliedStats);
                this.appliedStats.Add(statData);

                // Apply all abilities that this new stat takes
                foreach (AbilityData ability in this.appliedAbilities)
                {
                    statData.ApplyOneAbility(ability);
                }

                this.RecalculateAllLinkedStatsPools();
                this.UpdateReadOnlyStatsList();
            }
            else
            {
                if (Debug.isDebugBuild)
                {
                    Debug.LogWarning("The stat " + newStat.Name + " was already added to " + this.Name);
                }
            }
        }
        /// <summary>
        ///     Deserialization Constructor
        /// </summary>
        public RpgCharacterData(RpgCharacterPacket rpgCharacterPacket)
        {
            Debug.Assert(rpgCharacterPacket != null, "RpgCharacterData could not be deserialized because the packet was null!");

            this.id                = new SaveableGuid(rpgCharacterPacket.id);
            this.name              = rpgCharacterPacket.name;
            this.hp                = rpgCharacterPacket.hp;
            this.maxHp             = rpgCharacterPacket.maxHp;
            this.additionalMaxHp   = rpgCharacterPacket.additionalMaxHp;
            this.unallocatedSpPool = rpgCharacterPacket.unallocatedSpPool;
            this.assignmentType    = rpgCharacterPacket.assignmentType;

            this.xpData           = new XpData(rpgCharacterPacket.xpDataPacket);
            this.appliedStats     = new List <StatData>();
            this.appliedAbilities = new List <AbilityData>();

            this.numOfStats     = rpgCharacterPacket.appliedStats.Count;
            this.numOfAbilities = rpgCharacterPacket.appliedAbilities.Count;


            // Deserialize abilties first, so we can just loop through stats later to apply abilities
            foreach (AbilityPacket abilityPacket in rpgCharacterPacket.appliedAbilities)
            {
                AbilityData newAbility = new AbilityData(abilityPacket);
                this.appliedAbilities.Add(newAbility);
            }

            foreach (StatPacket statPacket in rpgCharacterPacket.appliedStats)
            {
                StatData newStat = new StatData(statPacket, this.appliedStats);
                this.appliedStats.Add(newStat);

                // Apply all abilities that this new stat takes
                foreach (AbilityData ability in this.appliedAbilities)
                {
                    newStat.ApplyOneAbility(ability);
                }
            }

            this.RecalculateAllLinkedStatsPools();

            this.UpdateReadOnlyStatsList();
            this.UpdateReadOnlyAbilitiesList();
        }