Example #1
0
 public static string[] GetPropertyNames(this Type type, bool requiresWrite)
 {
     PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance).ToArray();
     if (requiresWrite)
     {
         properties = properties.Where(x => x.CanWrite && FsmUtility.GetVariableType(x.PropertyType) != null).ToArray();
     }
     return(properties.Select(x => x.Name).ToArray());
 }
Example #2
0
        public bool SetVariable(string name, object value)
        {
            FsmVariable variable = GetVariable(name);

            if (variable != null && variable.VariableType.IsAssignableFrom(value.GetType()))
            {
                variable.SetValue(value);
                return(true);
            }
            if (value != null)
            {
                variable           = (FsmVariable)ScriptableObject.CreateInstance(FsmUtility.GetVariableType(value.GetType()));
                variable.hideFlags = HideFlags.HideInHierarchy;
                variable.Name      = name;
                variable.SetValue(value);
                Variables = ArrayUtility.Add <FsmVariable> (Variables, variable);
            }
            return(false);
        }
Example #3
0
 public void EnableStateMachine()
 {
     if (stateMachine == null)
     {
         enabled = false;
         return;
     }
     if (!stateMachine.IsInitialized)
     {
         stateMachine = (StateMachine)FsmUtility.Copy(stateMachine);
         stateMachine.Init(this);
     }
     if (!isPaused)
     {
         this.ActiveNode = stateMachine.GetStartNode();
         this.AnyState   = stateMachine.GetAnyState();
     }
     isPaused   = false;
     isDisabled = false;
     enabled    = true;
 }
Example #4
0
 public static string[] GetFieldNames(this Type type)
 {
     FieldInfo[] fields = type.GetAllFields(BindingFlags.Public | BindingFlags.Instance).ToArray();
     fields = fields.Where(x => FsmUtility.GetVariableType(x.FieldType) != null).ToArray();
     return(fields.Select(x => x.Name).ToArray());
 }