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); }
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; } }
public AbilityValueComponent(AbilityValueComponentTypeEnum type) { this.Type = type; }