コード例 #1
0
        public AbilityValueComponent GetValueComponentOrThrow(AbilityValueComponentTypeEnum type)
        {
            if (!this.ValueComponentsByType.TryGetValue(type, out var avc) || (avc == null))
            {
                throw new ArgumentException($"Ability value component not found with type '{type}'.");
            }

            return(avc);
        }
コード例 #2
0
        public void SetComponentValue(AbilityValueComponentTypeEnum type, int value)
        {
            //if (value < this.Definition.MinValue)
            //    throw new ArgumentOutOfRangeException(nameof(value), $"Value '{value}' of component with type '{type}' of ability '{this.Definition.Name ?? this.Definition.Code}' is below the minimum '{this.Definition.MinValue}'.");

            if (!this.ValueComponentsByType.TryGetValue(type, out var component) || (component == null))
            {
                this.ValueComponentsByType[type] = new AbilityValueComponent(type)
                {
                    Value = value
                }
            }
            ;
            else
            {
                component.Value = value;
            }
        }
コード例 #3
0
 public AbilityValueComponent(AbilityValueComponentTypeEnum type)
 {
     this.Type = type;
 }