public void Customize(CharacterInfo customizations, ContentManager contentLoader) { foreach (KeyValuePair <ActorComponent.ComponentType, ActorComponent> kvp in mComponents) { ICustomizable candidate = kvp.Value as ICustomizable; if (candidate != null) { candidate.Customize(customizations, contentLoader); } } }
public void Customize(CharacterInfo customizations, ContentManager contentLoader) { foreach (KeyValuePair <Type, Behavior> behavior in Behaviors) { ICustomizable candidate = behavior.Value as ICustomizable; if (candidate != null) { candidate.Customize(customizations, contentLoader); } } }
public static void ApplyOption(ICustomizable customizable, string name, object value) { var property = customizable.GetType().GetProperties() .FirstOrDefault(p => p.GetCustomAttribute <OptionAttribute>()?.Name == name); if (property == null) { throw new KryptonParserException($"Unknown option \"{name}\""); } try { property.SetValue(customizable, value); } catch { throw new KryptonParserException($"Invalid value \"{value}\" for option \"{name}\""); } }