Exemplo n.º 1
0
        public FactionArmy CreateArmyFor(FactionInteraction factionInteraction, bool useForGenerator)
        {
            var army = new FactionArmy(factionInteraction, this, useForGenerator);

            army.DepletionFromWar = 0;

            return(army);
        }
Exemplo n.º 2
0
        public bool GiveTo(FactionArmy army, War war)
        {
            if (!GiveWorkerTo(army, war))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
 private void Awake()
 {
     if (factionArmy == null)
     {
         factionArmy = this;
     }
     else
     {
         Destroy(this);
     }
 }
Exemplo n.º 4
0
        public void RemoveArmy(FactionInteraction factionInteraction)
        {
            for (int i = 0; i < armys.Count; i++)
            {
                FactionArmy army = armys[i];

                if (army.Faction == factionInteraction)
                {
                    armys.Remove(army);

                    break;
                }
            }
        }
        private void AffectDepletionFromWar(Faction assault, float attackerPoints, Faction defender, float defendersPoints)
        {
            FactionArmy attackerArmy = War.Armys.FirstOrDefault(x => x.Faction.Faction == assault);

            if (attackerArmy != null)
            {
                attackerArmy.DepletionFromWar += attackerPoints;
            }
            FactionArmy defenderArmy = War.Armys.FirstOrDefault(x => x.Faction.Faction == defender);

            if (defenderArmy != null)
            {
                defenderArmy.DepletionFromWar += defendersPoints;
            }
        }
Exemplo n.º 6
0
        private bool TryFindArmyOrderFor(FactionArmy army, out ArmyOrderDef armyOrder)
        {
            armyOrder = null;
            foreach (var order in DefDatabase <ArmyOrderDef> .AllDefs)
            {
                if (order.targetGoals.Contains(WarGoalDef))
                {
                    if (order.Worker.CanGive(army, this))
                    {
                        armyOrder = order;
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 7
0
        public bool CanGive(FactionArmy army, War war)
        {
            if (army.lastGiveOrderTicks.TryGetValue(def, out int value))
            {
                int daysPassed = Mathf.FloorToInt((Find.TickManager.TicksGame - war.StartTicks) / 60000f);
                if (daysPassed < def.earliestWarDay)
                {
                    return(false);
                }

                float num = (Find.TickManager.TicksGame - value) / 60000f;
                if (num < def.minRefireDays)
                {
                    return(false);
                }
            }

            if (!CanGiveSubTo(army, war))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
 public void AddArmy(FactionArmy factionArmy)
 {
     armys.Add(factionArmy);
 }
Exemplo n.º 9
0
 protected virtual bool GiveWorkerTo(FactionArmy army, War war)
 {
     return(true);
 }
Exemplo n.º 10
0
 protected virtual bool CanGiveSubTo(FactionArmy army, War war)
 {
     return(true);
 }