コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
        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}\"");
            }
        }