public static Subaction GenerateSubactionFromData(SubactionData data)
 {
     try{
         Subaction subaction = ScriptableObject.CreateInstance("Subaction" + data.SubactionName) as Subaction;
         subaction.arg_dict = data.arguments;
         return(subaction);
     } catch {
         Debug.Log("Could not find subaction named " + data.SubactionName);
         return(null);
     }
 }
    public static Subaction AddNewSubaction(string subactionName, List <Subaction> group)
    {
        Subaction sub = GetSubaction(subactionName);

        if (sub != null)
        {
            sub.generateDefaultArguments();
            group.Add(sub);
        }
        return(sub);
    }
    public static Subaction GetSubaction(string subactionName)
    {
        Type t = Type.GetType("Subaction" + subactionName);

        if (t != null)
        {
            object obj = Activator.CreateInstance(t);
            if (obj.GetType().IsSubclassOf(typeof(Subaction)))
            {
                Subaction sub = (Subaction)obj;
                sub.SubactionName = subactionName;
                return(sub);
            }
            return(null);
        }
        return(null);
    }
 private void CheckCondAndExecute(Subaction subact)
 {
     if (!cond_list.Contains(false)) //If there are no falses in the list, execute the action
     {
         //This will only execute the subaction if we aren't in the builder, or if this one will always execute
         if (!isInBuilder || subact.canExecuteInBuilder())
         {
             subact.Execute(actor, this);
         }
     }
     else
     {
         //Check if the subaction is one of the control subactions, we execute it anyway
         if (subact.isConditional())
         {
             subact.Execute(actor, this);
         }
     }
 }
    /// <summary>
    /// Checks if the given subaction will work on this BattleObject.
    /// It does this by checking if all of the required components are included.
    /// </summary>
    /// <param name="subact">The Subaction to validate on</param>
    /// <returns>True if this BattleObject meets all of the requirements of the subaction, false otherwise.</returns>
    public bool ValidateSubaction(Subaction subact)
    {
        //We start with a true, and && it with the existance of each requirement.
        bool ret = true;

        foreach (string req in subact.GetRequirements())
        {
            switch (req)
            {
            case "ActionHandler":
                ret = ret && (actionHandler != null);     //if ret is true, and the action handler is set, it stays true
                break;

            case "AbstractFighter":
                ret = ret && (abstractFighter != null);     //if ret is true, and the action handler is set, it stays true
                break;

            case "motionHandler":
                ret = ret && (motionHandler != null);     //if ret is true, and the action handler is set, it stays true
                break;
            }
        }
        return(ret);
    }
Beispiel #6
0
        private void CreateParamEditor(Subaction action)
        {
            if (action == null)
            {
                return;
            }

            panel1.Controls.Clear();

            for (int i = action.Parameters.Length - 1; i >= 0; i--)
            {
                var p = action.Parameters[i];

                if (p.Name == "None")
                {
                    continue;
                }

                Panel group = new Panel();
                group.Dock   = DockStyle.Top;
                group.Height = 24;

                if (p.IsFloat)
                {
                    SAFloatEditor editor = new SAFloatEditor();
                    group.Controls.Add(editor);
                }
                else
                if (p.IsPointer)
                {
                    if (Reference == null)
                    {
                        PointerBox.SelectedIndex = 0;
                    }
                    group.Controls.Add(PointerBox);
                }
                else
                if (p.Hex)
                {
                    SAHexEditor editor = new SAHexEditor();
                    editor.SetBitSize(p.BitCount);
                    group.Controls.Add(editor);

                    group.Controls.Add(new Label()
                    {
                        Text = "0x", Dock = DockStyle.Left
                    });
                }
                else
                if (p.HasEnums)
                {
                    SAEnumEditor editor = new SAEnumEditor();
                    editor.SetEnums(p.Enums);
                    group.Controls.Add(editor);
                }
                else
                {
                    SAIntEditor editor = new SAIntEditor();
                    editor.SetBitSize(p.BitCount);
                    group.Controls.Add(editor);
                }

                group.Controls.Add(new Label()
                {
                    Text = p.Name + ":", Dock = DockStyle.Left, Width = 200
                });

                panel1.Controls.Add(group);
            }

            ReadjustHeight();
        }