Example #1
0
 public GoToZoneAct(CreatureAI agent, Zone zone)
     : base(agent)
 {
     Tree = null;
     Name = "Goto zone : " + zone.ID;
     Destination = zone;
 }
 public PlaceRoomResourcesAct(CreatureAI agent, BuildRoomOrder buildRoom, List<ResourceAmount> resources)
     : base(agent)
 {
     Name = "Place BuildRoom resources";
     BuildRoom = buildRoom;
     Resources = resources;
 }
Example #3
0
 public StockResourceAct(CreatureAI agent, ResourceAmount item)
     : base(agent)
 {
     ItemToStock = item.CloneResource();
     Name = "Stock Item";
     Tree = null;
 }
Example #4
0
 public DigAct(CreatureAI creature, string targetVoxel)
     : base(creature)
 {
     TargetVoxelName = targetVoxel;
     Name = "Dig!";
     EnergyLoss = 10.0f;
 }
Example #5
0
 public CraftItemAct(CreatureAI creature, Voxel voxel, string type)
     : base(creature)
 {
     ItemType = type;
     Voxel = voxel;
     Name = "Build craft item";
 }
 public SearchFreeStockpileAct(CreatureAI creature, string stockName, string voxName)
     : base(creature)
 {
     Name = "Search Stockpile " + stockName;
     StockpileName = stockName;
     VoxelName = voxName;
 }
 public SetTargetVoxelFromEntityAct(CreatureAI creature, string entityName, string voxelOut)
     : base(creature)
 {
     Name = "Set Target Voxel";
     VoxelOutName = voxelOut;
     EntityName = entityName;
 }
Example #8
0
 public GoToEntityAct(Body entity, CreatureAI creature)
     : base(creature)
 {
     Name = "Go to entity";
     EntityName = "TargetEntity";
     Entity = entity;
 }
Example #9
0
 public GatherManager(CreatureAI creature)
 {
     Creature = creature;
     ItemsToGather = new List<Body>();
     StockOrders = new List<StockOrder>();
     VoxelOrders = new List<BuildVoxelOrder>();
 }
Example #10
0
 public GatherItemAct(CreatureAI agent, Body item)
     : base(agent)
 {
     ItemToGather = item;
     Name = "Gather Item";
     Tree = null;
 }
Example #11
0
 public SearchFreeStockpileAct(CreatureAI creature, string stockName, string voxName, ResourceAmount itemToStock) :
     base(creature)
 {
     Name          = "Search Stockpile " + stockName;
     StockpileName = stockName;
     VoxelName     = voxName;
     Item          = itemToStock;
 }
Example #12
0
 public PutResourceInZone(CreatureAI agent, string stockpileName, string voxelname, string resourceName)
     : base(agent)
 {
     VoxelName = voxelname;
     Name = "Put Item";
     StockpileName = stockpileName;
     ResourceName = resourceName;
 }
Example #13
0
 public SleepAct(CreatureAI creature) :
     base(creature)
 {
     Name         = "Sleep";
     RechargeRate = 1.0f;
     Teleport     = false;
     Type         = SleepType.Sleep;
 }
Example #14
0
 public FindAndEatFoodAct(CreatureAI agent, bool MustPay) :
     base(agent)
 {
     Name         = "Find and Eat Edible";
     FoodTag      = "PreparedFood";
     FallbackTag  = "Edible";
     this.MustPay = MustPay;
 }
Example #15
0
 public IEnumerable <Act.Status> OnRechargeEnd(CreatureAI creature)
 {
     creature.Creature.OverrideCharacterMode = false;
     creature.Creature.CurrentCharacterMode  = CharacterMode.Idle;
     creature.Creature.Physics.Orientation   = Physics.OrientMode.RotateY;
     creature.Physics.Active = true;
     yield return(Act.Status.Success);
 }
Example #16
0
 public WanderAct(CreatureAI creature, float seconds, float turnTime, float radius) :
     base(creature)
 {
     Name       = "Wander";
     WanderTime = new Timer(seconds, false);
     TurnTime   = new Timer(turnTime, false);
     Radius     = radius;
 }
Example #17
0
 public PutMoneyInZoneAct(CreatureAI agent, string stockpileName, string voxelname, DwarfBux money) :
     base(agent)
 {
     Money         = money;
     VoxelName     = voxelname;
     Name          = "Stash money in zone";
     StockpileName = stockpileName;
 }
Example #18
0
 public PutResourceInZone(CreatureAI agent, string stockpileName, string voxelname, string resourceName) :
     base(agent)
 {
     VoxelName     = voxelname;
     Name          = "Put Item";
     StockpileName = stockpileName;
     ResourceName  = resourceName;
 }
Example #19
0
 public GatherItemAct(CreatureAI agent, string item) :
     base(agent)
 {
     ItemID       = item;
     Tree         = null;
     ItemToGather = null;
     Name         = "Gather Item";
 }
Example #20
0
 public CraftResourceAct(CreatureAI creature, CraftItem CraftItem, List <ResourceApparentTypeAmount> RawMaterials, ResourceDes Des) :
     base(creature)
 {
     this.ItemType     = CraftItem;
     this.RawMaterials = RawMaterials;
     this.Des          = Des;
     Name = "Build craft item";
 }
Example #21
0
 public StockResourceAct(CreatureAI agent, string item) :
     base(agent)
 {
     ItemID      = item;
     Tree        = null;
     ItemToStock = null;
     Name        = "Stock Item";
 }
Example #22
0
 public GoToVoxelAct(VoxelHandle voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 3.0f) :
     base(creature)
 {
     Radius   = radius;
     Voxel    = voxel;
     Name     = "Go to DestinationVoxel";
     PlanType = planType;
 }
Example #23
0
 public GoToZoneAct(CreatureAI agent, string zone) :
     base(agent)
 {
     Tree            = null;
     Name            = "Goto zone : " + zone;
     Destination     = null;
     DestinationName = zone;
 }
Example #24
0
        public DigAct(CreatureAI creature, KillVoxelTask OwnerTask) :
            base(creature)
        {
            Name       = "Dig!";
            EnergyLoss = 10.0f;

            this.OwnerTask = OwnerTask;
        }
Example #25
0
 public GoToVoxelAct(Voxel voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f) :
     base(creature)
 {
     Radius   = radius;
     Voxel    = voxel;
     Name     = "Go to Voxel";
     PlanType = planType;
 }
Example #26
0
 public GoToNamedVoxelAct(string voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 3.0f) :
     base(creature)
 {
     Radius    = radius;
     PlanType  = planType;
     VoxelName = voxel;
     Name      = "Go to DestinationVoxel " + voxel;
 }
Example #27
0
 public GoToEntityAct(Body entity, CreatureAI creature) :
     base(creature)
 {
     Name         = "Go to entity";
     EntityName   = "TargetEntity";
     Entity       = entity;
     MovingTarget = true;
 }
 public GetNearestFreeVoxelInZone(CreatureAI agent, Zone targetZone, string outputVoxel, bool reserve)
     : base(agent)
 {
     Name = "Get Free Voxel";
     OutputVoxel = outputVoxel;
     TargetZone = targetZone;
     ReserveVoxel = reserve;
 }
Example #29
0
 public CreateCraftItemAct(VoxelHandle voxel, CreatureAI agent, CraftDesignation itemType) :
     base(agent)
 {
     Agent = agent;
     Voxel = voxel;
     Name  = "Create craft item";
     Item  = itemType;
 }
Example #30
0
 public GatherItemAct(CreatureAI agent, string item)
     : base(agent)
 {
     ItemID = item;
     Tree = null;
     ItemToGather = null;
     Name = "Gather Item";
 }
Example #31
0
 public PlaceVoxelAct(Voxel voxel, CreatureAI agent, ResourceAmount resource) :
     base(agent)
 {
     Agent    = agent;
     Voxel    = voxel;
     Name     = "Build Voxel " + voxel.ToString();
     Resource = resource;
 }
Example #32
0
 public CreateCraftItemAct(Voxel voxel, CreatureAI agent, string itemType)
     : base(agent)
 {
     Agent = agent;
     Voxel = voxel;
     Name = "Create craft item";
     ItemType = itemType;
 }
Example #33
0
 public PlaceVoxelAct(Voxel voxel, CreatureAI agent, ResourceAmount resource)
     : base(agent)
 {
     Agent = agent;
     Voxel = voxel;
     Name = "Build Voxel " + voxel.ToString();
     Resource = resource;
 }
Example #34
0
 public StockResourceAct(CreatureAI agent, string item)
     : base(agent)
 {
     ItemID = item;
     Tree = null;
     ItemToStock = null;
     Name = "Stock Item";
 }
Example #35
0
 public StashAct(CreatureAI agent, PickUpType type, Zone zone, string targetName, string stashedItemOut) :
     base(agent)
 {
     Name           = "Stash " + targetName;
     PickType       = type;
     Zone           = zone;
     TargetName     = targetName;
     StashedItemOut = stashedItemOut;
 }
Example #36
0
 public StashAct(CreatureAI agent, PickUpType type, Zone zone, string targetName, string stashedItemOut)
     : base(agent)
 {
     Name = "Stash " + targetName;
     PickType = type;
     Zone = zone;
     TargetName = targetName;
     StashedItemOut = stashedItemOut;
 }
Example #37
0
        protected virtual void OnFire(CreatureAI creature)
        {
            MinionFired handler = Fire;

            if (handler != null)
            {
                handler(creature);
            }
        }
Example #38
0
 public void AddFailureReason(CreatureAI Agent, String Reason)
 {
     FailureReasons.RemoveAll(r => r.StartsWith(Agent.Stats.FullName));
     FailureReasons.Add(String.Format("{0}: {1}", Agent.Stats.FullName, Reason));
     if (FailureReasons.Count > ReasonsToKeep)
     {
         FailureReasons.RemoveAt(0);
     }
 }
Example #39
0
 public GetResourcesAct(CreatureAI agent, Resource.ResourceTags resources) :
     base(agent)
 {
     Name      = "Get Resources";
     Resources = new List <Quantitiy <Resource.ResourceTags> >()
     {
         new Quantitiy <Resource.ResourceTags>(resources)
     };
 }
Example #40
0
        public bool Verify(CreatureAI creature)
        {
            if (creature.Blackboard.GetData <bool>("NoPath", false))
            {
                return(false);
            }

            return(Entity != null && !Entity.IsDead);
        }
Example #41
0
        public bool Validate(CreatureAI creature, VoxelHandle voxel, ResourceTypeAmount Resource)
        {
            if (creature.Blackboard.GetData <bool>("NoPath", false))
            {
                return(false);
            }

            return(creature.Creature.Inventory.HasResource(Resource));
        }
Example #42
0
 public KillEntityAct(Body entity, CreatureAI creature, KillEntityTask.KillType mode) :
     base(creature)
 {
     Mode   = mode;
     Entity = entity;
     Name   = "Kill Entity";
     Tree   = new ForLoop(new Parallel(new Sequence(new GoToEntityAct(entity, creature),
                                                    new MeleeAct(Agent, entity)), new Wrap(Verify)), 5, true);
 }
Example #43
0
 public GetResourcesWithTag(CreatureAI agent, String Tag) :
     base(agent)
 {
     Name      = "Get Resources";
     Resources = new List <ResourceTagAmount>()
     {
         new ResourceTagAmount(Tag, 1)
     };
 }
Example #44
0
 public KillEntityAct(Body entity, CreatureAI creature, KillEntityTask.KillType mode)
     : base(creature)
 {
     Mode = mode;
     Entity = entity;
     Name = "Kill Entity";
     Tree = new ForLoop(new Parallel(new Sequence(new GoToEntityAct(entity, creature),
                         new MeleeAct(Agent, entity)), new Wrap(Verify)), 5, true);
 }
Example #45
0
        public bool CheckIsDigDesignation(CreatureAI creature, KillVoxelTask OwnerTask)
        {
            if (OwnerTask.Voxel.IsValid)
            {
                return(creature.World.PersistentData.Designations.IsVoxelDesignation(OwnerTask.Voxel, DesignationType.Dig));
            }

            return(false);
        }
Example #46
0
        public void Sense()
        {
            if (Allies == null && Creature != null)
            {
                Allies = Creature.Faction;
            }

            List <CreatureAI> sensed = new List <CreatureAI>();

            VoxelHandle currentVoxel = new VoxelHandle(World.ChunkManager.ChunkData, GlobalVoxelCoordinate.FromVector3(Position));

            if (!(currentVoxel.IsValid && currentVoxel.IsEmpty))
            {
                return;
            }

            foreach (var thing in Manager.World.CollisionManager.EnumerateIntersectingObjects(BoundingBox, CollisionManager.CollisionType.Both))
            {
                Body body = thing as Body;
                if (body == null)
                {
                    continue;
                }
                CreatureAI minion = body.GetRoot().GetComponent <CreatureAI>();
                if (minion == null)
                {
                    continue;
                }
                Faction faction = minion.Faction;
                if (World.Diplomacy.GetPolitics(Allies, faction).GetCurrentRelationship() !=
                    Relationship.Hateful)
                {
                    continue;
                }

                if (!minion.Active)
                {
                    continue;
                }


                float dist = (minion.Position - GlobalTransform.Translation).LengthSquared();

                if (dist < SenseRadius && !VoxelHelpers.DoesRayHitSolidVoxel(
                        Manager.World.ChunkManager.ChunkData, Position, minion.Position))
                {
                    sensed.Add(minion);
                }
            }


            if (sensed.Count > 0)
            {
                OnEnemySensed.Invoke(sensed);
            }
        }
Example #47
0
 public BuildVoxelsAct(CreatureAI creature, List<Voxel> voxels, List<VoxelType> types)
     : base(creature)
 {
     Voxels = new List<KeyValuePair<Voxel, VoxelType>>();
     for (int i = 0; i < voxels.Count; i++)
     {
         Voxels.Add(new KeyValuePair<Voxel, VoxelType>(voxels[i], types[i]));
     }
     Name = "Build voxels";
 }
Example #48
0
 public FollowPathAct(CreatureAI agent, string pathName) :
     base(agent)
 {
     Name             = "Follow path";
     PathName         = pathName;
     ValidPathTimer   = new Timer(.75f, false);
     RandomTimeOffset = MathFunctions.Rand(0.0f, 0.1f);
     BlendStart       = true;
     BlendEnd         = true;
 }
Example #49
0
 public BuildVoxelsAct(CreatureAI creature, List <Voxel> voxels, List <VoxelType> types) :
     base(creature)
 {
     Voxels = new List <KeyValuePair <Voxel, VoxelType> >();
     for (int i = 0; i < voxels.Count; i++)
     {
         Voxels.Add(new KeyValuePair <Voxel, VoxelType>(voxels[i], types[i]));
     }
     Name = "Build voxels";
 }
Example #50
0
 public FlyWanderAct(CreatureAI creature, float seconds, float turnTime, float radius, float altitude)
     : base(creature)
 {
     Altitude = altitude;
     Name = "FlyWander " + seconds;
     WanderTime = new Timer(seconds, false);
     TurnTime = new Timer(turnTime, false);
     Radius = radius;
     YRadius = 2.0f;
     GravityCompensation = 0.1f;
     Damping = 0.25f;
     TurnThreshold = 2.0f;
 }
Example #51
0
 public GoToVoxelAct(string voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f)
     : base(creature)
 {
     Name = "Go to Voxel " + voxel;
     Tree = new Sequence(
             new ForLoop(
                 new Sequence(
                               new PlanAct(Agent, "PathToVoxel", voxel, planType) { Radius = radius},
                               new FollowPathAnimationAct(Agent, "PathToVoxel")
                              )
                                , 3, true),
                               new StopAct(Agent));
 }
Example #52
0
 public GoToVoxelAct(Voxel voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f)
     : base(creature)
 {
     Voxel = voxel;
     Name = "Go to Voxel";
     if(Voxel != null)
     {
         Tree = new Sequence(
                               new SetBlackboardData<Voxel>(Agent, "TargetVoxel", Voxel),
                               new PlanAct(Agent, "PathToVoxel", "TargetVoxel", planType) { Radius = radius},
                               new FollowPathAnimationAct(Agent, "PathToVoxel"),
                               new StopAct(Agent));
     }
 }
Example #53
0
        public GuardVoxelAct(CreatureAI agent, Voxel voxel)
            : base(agent)
        {
            Voxel = voxel;
            Name = "Guard Voxel " + voxel;

            Tree = new Sequence
                (
                    new GoToVoxelAct(voxel, PlanAct.PlanType.Adjacent, agent),
                    new StopAct(Agent),
                    new WhileLoop(new WanderAct(Agent, 1.0f, 0.5f, 0.1f), new Condition(LoopCondition)),
                    new Condition(ExitCondition)
                );
        }
Example #54
0
 public PlanAct(CreatureAI agent, string pathOut, string target, PlanType planType)
     : base(agent)
 {
     Type = planType;
     Name = "Plan to " + target;
     PlannerTimer = new Timer(1.0f, false);
     MaxExpansions = 1000;
     PathOut = pathOut;
     TargetName = target;
     PlanSubscriber = new PlanSubscriber(PlayState.PlanService);
     WaitingOnResponse = false;
     MaxTimeouts = 4;
     Timeouts = 0;
     Radius = 0;
 }
Example #55
0
 public KillVoxelAct(Voxel voxel, CreatureAI creature)
     : base(creature)
 {
     Voxel = voxel;
     Name = "Kill Voxel " + voxel.Position;
     Tree = new Sequence(
         new SetBlackboardData<Voxel>(creature, "DigVoxel", voxel),
         new Sequence(
                       new Wrap(() => IncrementAssignment(creature, "DigVoxel", 1)),
                       new GoToVoxelAct(voxel, PlanAct.PlanType.Adjacent, creature),
                       new Wrap(() => CheckIsDigDesignation(creature, "DigVoxel")),
                       new DigAct(Agent, "DigVoxel"),
                       new ClearBlackboardData(creature, "DigVoxel")
                     )
                     | new Wrap(() => IncrementAssignment(creature, "DigVoxel", -1)) & false);
 }
Example #56
0
        public BuildRoomAct(CreatureAI agent, BuildRoomOrder buildRoom)
            : base(agent)
        {
            Name = "Build BuildRoom " + buildRoom.ToString();
            Resources = buildRoom.ListRequiredResources();

            Tree = new Sequence(new GetResourcesAct(Agent, Resources),
                new Sequence(
                    new Wrap(() => IsRoomBuildOrder(buildRoom)),
                    SetTargetVoxelFromRoomAct(buildRoom, "TargetVoxel"),
                    new Wrap(() => IsRoomBuildOrder(buildRoom)),
                    new GoToVoxelAct("TargetVoxel", PlanAct.PlanType.Adjacent, Agent),
                    new Wrap(() => IsRoomBuildOrder(buildRoom)),
                    new Wrap(() => Creature.HitAndWait(buildRoom.VoxelOrders.Count * 0.5f / agent.Stats.BuildSpeed, true)),
                    new Wrap(() => IsRoomBuildOrder(buildRoom)),
                    new PlaceRoomResourcesAct(Agent, buildRoom, Resources)
                    , new Wrap(Creature.RestockAll)) | new Wrap(Creature.RestockAll)
                );
        }
Example #57
0
 public FarmAct(CreatureAI agent)
     : base(agent)
 {
     Name = "Work a farm";
 }
Example #58
0
        public void Initialize()
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            Sprite = new CharacterSprite(Graphics, Manager, "Elf Sprite", Physics, Matrix.CreateTranslation(new Vector3(0, 0.35f, 0)));
            foreach (Animation animation in Stats.CurrentClass.Animations)
            {
                Sprite.AddAnimation(animation.Clone());
            }

            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

            Sensors = new EnemySensor(Manager, "EnemySensor", Physics, Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero);

            AI = new CreatureAI(this, "Elf AI", Sensors, PlanService);

            Attacks = new List<Attack>() { new Attack(Stats.CurrentClass.Attacks[0]) };

            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 16
                }
            };

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);
            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);

            SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture);
            List<Point> shP = new List<Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);
            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");
            Physics.Tags.Add("Goblin");

            DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount = 5,
                SoundToPlay = ContentPaths.Entities.Goblin.Audio.goblinhurt1
            };
            Flames = new Flammable(Manager, "Flames", Physics, this);

            NoiseMaker.Noises["Hurt"] = new List<string>
            {
                ContentPaths.Entities.Goblin.Audio.goblinhurt1,
                ContentPaths.Entities.Goblin.Audio.goblinhurt2,
                ContentPaths.Entities.Goblin.Audio.goblinhurt3,
                ContentPaths.Entities.Goblin.Audio.goblinhurt4,
            };

            MinimapIcon minimapIcon = new MinimapIcon(Physics, new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.map_icons), 16, 3, 0));

            NoiseMaker.Noises["Chew"] = new List<string>
            {
                ContentPaths.Audio.chew
            };

            NoiseMaker.Noises["Jump"] = new List<string>
            {
                ContentPaths.Audio.jump
            };

            Stats.FullName = TextGenerator.GenerateRandom("$elfname");
            //Stats.LastName = TextGenerator.GenerateRandom("$elffamily");
            Stats.Size = 4;
        }
Example #59
0
 public ClearBlackboardData(CreatureAI creature, string data)
     : base(creature)
 {
     Name = "Clear " + data;
     DataKey = data;
 }
Example #60
0
 public CreatureAct(CreatureAI agent)
 {
     Agent = agent;
     Name = "Creature Act";
 }