コード例 #1
0
        /// <inheritdoc />
        public bool TryGetValue(TStatType key, out RPGStatValue <TStatType> value)
        {
            if (ContainsKey(key))
            {
                return(InternalMap.TryGetValue(key, out value));
            }

            //Kinda crappy we have to allocate but it's likely Gen0
            value = RPGStatValue <TStatType> .Empty[key];
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Do not call this method externally ever.
        /// (NOT THREAD-SAFE)
        /// </summary>
        /// <param name="statDefinition"></param>
        public void AddStats(RPGStatValue <TStatType> statDefinition)
        {
            if (statDefinition == null)
            {
                throw new ArgumentNullException(nameof(statDefinition));
            }

            if (this.ContainsKey(statDefinition.StatType))
            {
                InternalMap[statDefinition.StatType] = new RPGStatValue <TStatType>(statDefinition.StatType, InternalMap[statDefinition.StatType].Value + statDefinition.Value);
            }
            else
            {
                InternalMap[statDefinition.StatType] = statDefinition;
            }
        }