public static FloatMenuAcceptanceReport CanAttack(Caravan caravan, WarObject wo)
 {
     if (wo == null || !wo.Spawned)
     {
         return(false);
     }
     if (wo.Faction != null && !wo.Faction.HostileTo(caravan.Faction))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public virtual bool ShouldInteractWith(Caravan car, WarObject rwo)
        {
            List <CaravanTargetData> ctdList = WorldUtility.Get_WCPT().GetCaravaTargetData;

            if (ctdList != null && ctdList.Count > 0)
            {
                for (int i = 0; i < ctdList.Count; i++)
                {
                    if (ctdList[i].caravan == car && ctdList[i].caravanTarget == rwo)
                    {
                        return(car.Faction != null && car.Faction == Faction.OfPlayer);
                    }
                }
            }
            return(false);
        }
 public static FloatMenuAcceptanceReport CanEngage(Caravan caravan, WarObject wo)
 {
     if (wo == null || !wo.Spawned)
     {
         return(false);
     }
     if (wo.Faction != null && wo.Faction.HostileTo(caravan.Faction))
     {
         return(false);
     }
     if (wo is Trader)
     {
         Trader trader = wo as Trader;
         if (!trader.tradedWithPlayer) //trader.TradedWith.Contains(caravan))
         {
             return(FloatMenuAcceptanceReport.WithFailMessage("Already Traded"));
         }
     }
     return(true);
 }
Exemplo n.º 4
0
        public override void ScanAction(float range)
        {
            //Scouts will prioritize other units
            List <WorldObject> worldObjects = WorldUtility.GetWorldObjectsInRange(this.Tile, range);

            if (worldObjects != null && worldObjects.Count > 0)
            {
                for (int i = 0; i < worldObjects.Count; i++)
                {
                    WorldObject wo = worldObjects[i];
                    if (wo.Faction != this.Faction && wo != this.DestinationTarget && (this.DestinationTarget == null || (this.DestinationTarget != null && Find.WorldGrid.ApproxDistanceInTiles(wo.Tile, this.Tile) < Find.WorldGrid.ApproxDistanceInTiles(this.DestinationTarget.Tile, this.Tile))))
                    {
                        //Log.Message("" + this.Name + " scanned nearby object " + this.targetWorldObject.Label);
                        if (wo is Caravan && interactable) //or rimwar caravan, or diplomat, or merchant; ignore scouts and settlements
                        {
                            //Log.Message(this.Name + "scanned a player caravan");
                            Caravan playerCaravan = wo as Caravan;
                            //Log.Message("evaluating player caravan with " + playerCaravan.PlayerWealthForStoryteller + " wealth");
                            if (CaravanDetected(playerCaravan) && (playerCaravan.PlayerWealthForStoryteller / 100) <= (int)(this.RimWarPoints) && this.Faction.HostileTo(playerCaravan.Faction))
                            {
                                this.DestinationTarget = playerCaravan;
                                break;
                                //Log.Message(this.Label + " engaging nearby warband " + wo.Label);
                            }
                        }
                        if (wo is WarObject && this.Faction.HostileTo(wo.Faction))
                        {
                            WarObject warObject = wo as WarObject;
                            if (warObject.RimWarPoints <= this.RimWarPoints)
                            {
                                this.DestinationTarget = wo;
                                break;
                            }
                        }
                    }
                }
            }
            base.ScanAction(1f);
        }
Exemplo n.º 5
0
        public void ScanForNearbyEnemy(int range)
        {
            List <WorldObject> worldObjects = WorldUtility.GetWorldObjectsInRange(this.Tile, range);

            if (worldObjects != null && worldObjects.Count > 0)
            {
                for (int i = 0; i < worldObjects.Count; i++)
                {
                    WorldObject wo = worldObjects[i];
                    if (wo.Faction != this.Faction && wo.Faction.HostileTo(this.Faction) && wo != this.DestinationTarget)
                    {
                        //Log.Message("" + this.Name + " scanned nearby object " + this.targetWorldObject.Label);
                        if (wo is Caravan) //or rimwar caravan, or diplomat, or merchant; ignore scouts and settlements
                        {
                            Caravan playerCaravan = wo as Caravan;
                            //Log.Message("evaluating player caravan with " + playerCaravan.PlayerWealthForStoryteller + " wealth");
                            if (playerCaravan.PlayerWealthForStoryteller <= (int)(this.RimWarPoints * 1.5f))
                            {
                                //Log.Message(this.Label + " engaging nearby warband " + wo.Label);
                                this.DestinationTarget = wo;
                                break;
                            }
                        }
                        if (wo is WarObject)
                        {
                            WarObject warObject = wo as WarObject;
                            if (warObject.RimWarPoints <= this.RimWarPoints)
                            {
                                this.DestinationTarget = wo;
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 public WarObject_Tweener(WarObject warObject)
 {
     this.warObject = warObject;
 }
Exemplo n.º 7
0
 public static int CostToMove(WarObject warObject, int start, int end, int?ticksAbs = default(int?))
 {
     return(CostToMove(warObject.TicksPerMove, start, end, ticksAbs));
 }
Exemplo n.º 8
0
 public WarObject_PathFollower(WarObject warObject)
 {
     this.warObject = warObject;
 }
Exemplo n.º 9
0
 public override void EngageNearbyWarObject(WarObject rwo)
 {
     IncidentUtility.ResolveRimWarBattle(this, rwo);
     ImmediateAction(rwo);
 }
Exemplo n.º 10
0
 public virtual void EngageNearbyWarObject(WarObject rwo)
 {
 }
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, WarObject warObject)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(() => CanAttack(caravan, warObject), () => new CaravanArrivalAction_AttackWarObject(warObject), "RW_AttackWarObject".Translate(warObject.Label), caravan, warObject.Tile, warObject));
 }
 public CaravanArrivalAction_AttackWarObject(WarObject warObject)
 {
     this.wo = warObject;
 }
 public CaravanArrivalAction_EngageWarObject(WarObject warObject)
 {
     this.wo = warObject;
 }