示例#1
0
 private void SetDisplayColor(Body body, Color color)
 {
     foreach (var sprite in body.EnumerateAll().OfType <Tinter>())
     {
         sprite.VertexColorTint = color;
     }
 }
示例#2
0
        public override Feasibility IsFeasible(Creature agent)
        {
            if (EntityToKill == null || EntityToKill.IsDead)
            {
                return(Feasibility.Infeasible);
            }
            else
            {
                var ai = EntityToKill.EnumerateAll().OfType <Creature>().FirstOrDefault();

                switch (Mode)
                {
                case KillType.Attack:
                    if (!agent.Stats.IsTaskAllowed(Task.TaskCategory.Attack))
                    {
                        return(Feasibility.Infeasible);
                    }
                    return(agent.Faction.Designations.IsDesignation(EntityToKill, DesignationType.Attack) ? Feasibility.Feasible : Feasibility.Infeasible);

                case KillType.Chop:
                    if (!agent.Stats.IsTaskAllowed(Task.TaskCategory.Chop))
                    {
                        return(Feasibility.Infeasible);
                    }
                    return(agent.Faction.Designations.IsDesignation(EntityToKill, DesignationType.Chop) ? Feasibility.Feasible : Feasibility.Infeasible);

                case KillType.Auto:
                    return(Feasibility.Feasible);
                }

                var target = new VoxelHandle(agent.World.ChunkManager.ChunkData,
                                             GlobalVoxelCoordinate.FromVector3(EntityToKill.Position));
                // Todo: Find out if it is calculating the path twice to make PathExists work.
                if (!target.IsValid)
                {
                    return(Feasibility.Infeasible);
                }


                if (ai == null)
                {
                    return(Feasibility.Infeasible);
                }
                Relationship relation =
                    agent.World.Diplomacy.GetPolitics(ai.Faction, agent.Faction).GetCurrentRelationship();
                return((relation == Relationship.Hateful || relation == Relationship.Indifferent) ? Feasibility.Feasible : Feasibility.Infeasible);
            }
        }
示例#3
0
        public bool CanAttack(Body other)
        {
            var creature = other.EnumerateAll().OfType <Creature>().FirstOrDefault();

            if (creature == null)
            {
                return(false);
            }

            if (Player.World.Diplomacy.GetPolitics(creature.Faction, Player.Faction).GetCurrentRelationship() ==
                Relationship.Loving)
            {
                return(false);
            }
            return(true);
        }
示例#4
0
        public override Feasibility IsFeasible(Creature agent)
        {
            if (agent == null || agent.IsDead || EntityToKill == null || EntityToKill.IsDead)
            {
                return(Feasibility.Infeasible);
            }
            else
            {
                var ai = EntityToKill.EnumerateAll().OfType <Creature>().FirstOrDefault();

                if (Mode == KillType.Attack && !agent.Stats.IsTaskAllowed(TaskCategory.Attack))
                {
                    return(Feasibility.Infeasible);
                }

                return(Feasibility.Feasible);
            }
        }
示例#5
0
        bool IsDwarf(Body body)
        {
            if (body == null)
            {
                return(false);
            }

            var dwarves = body.EnumerateAll().OfType <Creature>().ToList();

            if (dwarves.Count <= 0)
            {
                return(false);
            }

            Creature dwarf = dwarves[0];

            return(dwarf.Faction == Player.Faction);
        }
示例#6
0
        bool IsNotSelectedDwarf(Body body)
        {
            if (body == null)
            {
                return(true);
            }

            var dwarves = body.EnumerateAll().OfType <Creature>().ToList();

            if (dwarves.Count <= 0)
            {
                return(false);
            }

            Creature dwarf = dwarves[0];

            return(dwarf.Faction == Player.Faction && !Player.SelectedMinions.Contains(dwarf.AI));
        }