/// <summary> /// Initializes a new instance of the <see cref="AspectView"/> class. /// </summary> /// <param name="thing">The thing to get the Aspect info for.</param> /// <param name="name">The name of the Aspect.</param> public AspectView(BaseThing thing, string name) { this.Title = name; this.Effective = thing.EffectiveAspect(name, "None"); if (thing.BaseAspects.TryGetValue(name, out string? @base) && !string.IsNullOrEmpty(@base)) { this.Base = @base; } if (thing.DynamicAspects.TryGetValue(name, out string?dynamic) && !string.IsNullOrEmpty(dynamic)) { this.Dynamic = dynamic; } if (thing.BaseDefinition.Aspects.TryGetValue(name, out AspectDefinition? definition) && definition.Dynamic) { this.DynamicScript = definition.DynamicValue; } var current = thing.GetCurrentAspectEffect(name); if (current != null) { this.CurrentEffect = current.Value; } StringBuilder sb = new StringBuilder(); if (this.DynamicScript != null) { sb.AppendLine($"Dynamic Script: {this.DynamicScript}"); } foreach (AspectEffect effect in thing.GetAspectEffectsModifying(name)) { EffectView view = new EffectView(effect); string str = $"{view.Title} {view.EffectString}"; if (effect == current) { str += $" (Current)"; } sb.AppendLine(str); } this.Tooltip = sb.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="AttributeView"/> class. /// </summary> /// <param name="thing">The thing to get the attribute info for.</param> /// <param name="name">The name of the attribute.</param> public AttributeView(BaseThing thing, string name) { this.Title = name; if (thing.BaseAttributes.TryGetValue(name, out int @base)) { this.Base = @base; } if (thing.DynamicAttributes.TryGetValue(name, out int dynamic)) { this.Dynamic = dynamic; } if (thing.BaseDefinition.Attributes.TryGetValue(name, out AttributeDefinition? def)) { this.DynamicScript = def.DynamicValue; } this.Effective = thing.EffectiveAttribute(name); StringBuilder sb = new StringBuilder(); if (this.DynamicScript != null) { sb.AppendLine($"Dynamic Script: {this.DynamicScript}"); } foreach (AttributeEffect effect in thing.GetAttributeEffectsModifying(name)) { this.EffectValue += effect.Manitude; EffectView view = new EffectView(effect); sb.AppendLine($"{view.Title} {view.EffectString}"); } this.Tooltip = sb.ToString(); }