コード例 #1
0
        public static void Prefix(MapEvent __instance)
        {
            if (MapEventCustomMembers.DefendersRanAway.TryRemove(__instance.Id, out _))
            {
                // Defender ran away
                // this._attackersRanAway = false;
                MapEvent__attackersRanAway.SetValue(__instance, false);

                // Place denfenders further away from attackers to prevent instantly get caught again
                foreach (PartyBase party in (IEnumerable <PartyBase>)__instance.DefenderSide.Parties)
                {
                    if (party.IsMobile)
                    {
                        MobileParty mobileParty = party.MobileParty;
                        if (mobileParty.IsActive && mobileParty.AttachedTo == null)
                        {
                            if (mobileParty.BesiegerCamp != null && mobileParty.BesiegerCamp.SiegeParties.Contains <PartyBase>(mobileParty.Party))
                            {
                                mobileParty.BesiegerCamp.RemoveSiegeParty(mobileParty);
                            }
                            Vec2 pointAroundPosition = mobileParty.FindReachablePointAroundPosition(mobileParty.Position2D, 3.1f, 3f, true);
                            mobileParty.Position2D = pointAroundPosition;
                            mobileParty.SetMoveModeHold();
                            mobileParty.IgnoreForHours(0.5f);
                        }
                    }
                }
            }
        }
コード例 #2
0
 private void DailyCheckBehaviour(MobileParty mb)
 {
     if (!registeredParties.Contains(mb))
     {
         return;
     }
     if (mb.Ai.AiState == AIState.Undefined || mb.Ai.AiState == AIState.WaitingAtSettlement)
     {
         if (yesterdayIdleParties.Contains(mb))
         {
             Settlement closestHostile = CampaignUtils.GetClosestHostileSettlement(mb);
             if (closestHostile == null)
             {
                 return;
             }
             mb.SetMoveGoToPoint(mb.FindReachablePointAroundPosition(closestHostile.GatePosition, 10));
             yesterdayIdleParties.Remove(mb);
         }
         else
         {
             yesterdayIdleParties.Add(mb);
         }
     }
     else
     {
         yesterdayIdleParties.Remove(mb);
     }
 }