public override void DoAction(Transition trans)
        {
            LordToil_DefendPoint lordToil_DefendPoint = (LordToil_DefendPoint)trans.target;
            Pawn pawn = TraderCaravanUtility.FindTrader(lordToil_DefendPoint.lord);

            if (pawn != null)
            {
                lordToil_DefendPoint.SetDefendPoint(pawn.Position);
                return;
            }
            IEnumerable <Pawn> source = lordToil_DefendPoint.lord.ownedPawns.Where((Pawn x) => x.GetTraderCaravanRole() == TraderCaravanRole.Carrier);

            if (source.Any())
            {
                lordToil_DefendPoint.SetDefendPoint(source.RandomElement().Position);
            }
            else
            {
                lordToil_DefendPoint.SetDefendPoint(lordToil_DefendPoint.lord.ownedPawns.RandomElement().Position);
            }
        }
示例#2
0
        public override StateGraph CreateGraph()
        {
            StateGraph      stateGraph      = new StateGraph();
            LordToil_Travel lordToil_Travel = new LordToil_Travel(this.travelDest);

            stateGraph.StartingToil = lordToil_Travel;
            LordToil_DefendPoint lordToil_DefendPoint = new LordToil_DefendPoint(false);

            stateGraph.AddToil(lordToil_DefendPoint);
            Transition transition = new Transition(lordToil_Travel, lordToil_DefendPoint, false, true);

            transition.AddTrigger(new Trigger_PawnHarmed(1f, false, null));
            transition.AddPreAction(new TransitionAction_SetDefendLocalGroup());
            transition.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition, false);
            Transition transition2 = new Transition(lordToil_DefendPoint, lordToil_Travel, false, true);

            transition2.AddTrigger(new Trigger_TicksPassedWithoutHarm(1200));
            transition2.AddPreAction(new TransitionAction_EnsureHaveExitDestination());
            stateGraph.AddTransition(transition2, false);
            return(stateGraph);
        }
        public override void DoAction(Transition trans)
        {
            LordToil_DefendPoint lordToil_DefendPoint = (LordToil_DefendPoint)trans.target;
            Pawn pawn = TraderCaravanUtility.FindTrader(lordToil_DefendPoint.lord);

            if (pawn != null)
            {
                lordToil_DefendPoint.SetDefendPoint(pawn.Position);
            }
            else
            {
                IEnumerable <Pawn> source = from x in lordToil_DefendPoint.lord.ownedPawns
                                            where x.GetTraderCaravanRole() == TraderCaravanRole.Carrier
                                            select x;
                if (source.Any <Pawn>())
                {
                    lordToil_DefendPoint.SetDefendPoint(source.RandomElement <Pawn>().Position);
                }
                else
                {
                    lordToil_DefendPoint.SetDefendPoint(lordToil_DefendPoint.lord.ownedPawns.RandomElement <Pawn>().Position);
                }
            }
        }
        public override void DoAction(Transition trans)
        {
            LordToil_DefendPoint lordToil_DefendPoint = (LordToil_DefendPoint)trans.target;

            lordToil_DefendPoint.SetDefendPoint(lordToil_DefendPoint.lord.ownedPawns.RandomElement <Pawn>().Position);
        }