Exemplo n.º 1
0
        public static void LoadCustomProperties(this BuildingInfo building, CustomizableProperties properties)
        {
            var ai             = building.m_buildingAI;
            var buildingFields = ai.GetType().GetFields();
            var customFields   = properties.GetType().GetFields();
            var fields         = new Dictionary <string, FieldInfo>();

            foreach (var customField in customFields)
            {
                fields.Add(customField.Name, customField);
            }

            foreach (var buildingField in buildingFields)
            {
                try
                {
                    if (fields.TryGetValue(buildingField.Name, out FieldInfo fieldInfo))
                    {
                        buildingField.SetValue(ai, fieldInfo.GetValue(properties));
                    }
                }
                catch (Exception e)
                {
                    Debug.LogWarning(e);
                }
            }
        }
Exemplo n.º 2
0
 public CustomizablePropertiesEntry(string key, CustomizableProperties value)
 {
     Key   = key;
     Value = value;
 }