예제 #1
0
    public override void Stop(AI ai)
    {
        AttackHarness harness = ai.WorkingMemory.GetItem <AttackHarness>("attacktargetharness");

        if (harness != null)
        {
            harness.VacateAttack(ai.Body);
        }

        harness = ai.WorkingMemory.GetItem <AttackHarness>("waitharness");
        if (harness != null)
        {
            harness.VacateAttack(ai.Body);
        }

        ai.WorkingMemory.RemoveItem("attacktargetharness");
        ai.WorkingMemory.RemoveItem("attacktargetharnessslot");
        ai.WorkingMemory.RemoveItem("waitharness");
        ai.WorkingMemory.RemoveItem("waitharnessslot");

        base.Stop(ai);
    }
예제 #2
0
    public override ActionResult Execute(AI ai)
    {
        AttackHarness meleeHarness = ai.WorkingMemory.GetItem <AttackHarness>("attacktargetharness");

        if (meleeHarness != null)
        {
            meleeHarness.VacateAttack(ai.Body);
        }

        AttackHarness waitHarness = ai.WorkingMemory.GetItem <AttackHarness>("waitharness");

        if (waitHarness != null)
        {
            waitHarness.VacateAttack(ai.Body);
        }

        int  tAttackSlot = -1;
        bool foundSlot   = false;

        if (meleeHarness != null)
        {
            foundSlot = meleeHarness.OccupyClosestAttackSlot(ai.Body, out tAttackSlot, null);
            if (foundSlot)
            {
                ai.WorkingMemory.SetItem <int>("attacktargetharnessslot", tAttackSlot);
            }
            else
            {
                ai.WorkingMemory.SetItem <int>("attacktargetharnessslot", -1);
            }
        }
        if (!foundSlot)
        {
            ai.WorkingMemory.SetItem <int>("attacktargetharnessslot", -1);
        }

        if ((!foundSlot) && (waitHarness != null))
        {
            tAttackSlot = -1;
            foundSlot   = waitHarness.OccupyClosestAttackSlot(ai.Body, out tAttackSlot, null);
            if (foundSlot)
            {
                ai.WorkingMemory.SetItem <int>("waitharnessslot", tAttackSlot);
            }
            else
            {
                ai.WorkingMemory.SetItem <int>("waitharnessslot", -1);
            }
        }
        else
        {
            ai.WorkingMemory.SetItem <int>("waitharnessslot", -1);
        }

        if (!foundSlot)
        {
            return(ActionResult.FAILURE);
        }

        return(ActionResult.RUNNING);
    }