Beispiel #1
0
 public bool Remove(ResourceAmount resourceAmount)
 {
     return(Remove(new List <ResourceAmount>()
     {
         resourceAmount
     }));
 }
Beispiel #2
0
        public ResourceEntity(ComponentManager manager, ResourceAmount resourceType, Vector3 position) :
            base(manager, ResourceLibrary.Resources[resourceType.ResourceType].Name,
                 Matrix.CreateTranslation(position), new Vector3(0.75f, 0.75f, 0.75f), Vector3.Zero, 0.5f, 0.5f, 0.999f, 0.999f, new Vector3(0, -10, 0))
        {
            Resource = resourceType;
            if (Resource.NumResources > 1)
            {
                Name = String.Format("Pile of {0} {1}s", Resource.NumResources, Resource.ResourceType);
            }
            Restitution = 0.1f;
            Friction    = 0.1f;
            Resource type = ResourceLibrary.Resources[resourceType.ResourceType];

            Tags.Add(type.Name);
            Tags.Add("Resource");

            if (type.Tags.Contains(DwarfCorp.Resource.ResourceTags.Flammable))
            {
                AddChild(new Health(Manager, "health", 10.0f, 0.0f, 10.0f));
                AddChild(new Flammable(Manager, "Flames"));
            }

            PropogateTransforms();
            CreateCosmeticChildren(Manager);
            Orientation = OrientMode.Fixed;
        }
Beispiel #3
0
 public StockResourceAct(CreatureAI agent, ResourceAmount item)
     : base(agent)
 {
     ItemToStock = item.CloneResource();
     Name = "Stock Item";
     Tree = null;
 }
Beispiel #4
0
        public void AddResources(List <ResourceAmount> resources)
        {
            foreach (ResourceAmount resource in resources)
            {
                ResourceLibrary.ResourceType resourceName = resource.ResourceType.Type;
                if (PutResources.ContainsKey(resourceName))
                {
                    ResourceAmount amount = PutResources[resourceName];
                    amount.NumResources += resource.NumResources;
                }
                else
                {
                    ResourceAmount amount = new ResourceAmount();
                    amount.NumResources += resource.NumResources;
                    amount.ResourceType  = resource.ResourceType;

                    PutResources[resourceName] = amount;
                }
            }

            if (MeetsBuildRequirements())
            {
                Build();
            }
        }
        public List <ResourceAmount> ListResourcesWithTag(Resource.ResourceTags tag, bool allowHeterogenous = true)
        {
            var resources = ListResources();

            if (allowHeterogenous)
            {
                return((from pair in resources
                        where Library.GetResourceType(pair.Value.Type).Tags.Contains(tag)
                        select pair.Value).ToList());
            }

            ResourceAmount maxAmount = null;

            foreach (var pair in resources)
            {
                var resource = Library.GetResourceType(pair.Value.Type);
                if (!resource.Tags.Contains(tag))
                {
                    continue;
                }
                if (maxAmount == null || pair.Value.Count > maxAmount.Count)
                {
                    maxAmount = pair.Value;
                }
            }
            return(maxAmount != null ? new List <ResourceAmount>()
            {
                maxAmount
            } : new List <ResourceAmount>());
        }
Beispiel #6
0
        public bool AddResources(ResourceAmount resources)
        {
            ResourceAmount amount = new ResourceAmount(resources.ResourceType, resources.NumResources);

            foreach (Stockpile stockpile in Stockpiles)
            {
                int space = stockpile.Resources.MaxResources - stockpile.Resources.CurrentResourceCount;

                if (space >= amount.NumResources)
                {
                    stockpile.Resources.AddResource(amount);
                    stockpile.HandleBoxes();
                    return(true);
                }
                else
                {
                    stockpile.Resources.AddResource(amount);
                    amount.NumResources -= space;
                    stockpile.HandleBoxes();
                    if (amount.NumResources == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #7
0
 public StashResourcesAct(CreatureAI agent, Zone zone, ResourceAmount resources) :
     base(agent)
 {
     Zone      = zone;
     Resources = resources;
     Name      = "Stash " + Resources.Type;
 }
Beispiel #8
0
 public bool Remove(ResourceAmount resourceAmount, RestockType type)
 {
     return(Remove(new List <ResourceAmount>()
     {
         resourceAmount
     }, type));
 }
Beispiel #9
0
        public override Act CreateScript(Creature creature)
        {
            var voxtype  = VoxelLibrary.GetVoxelType(VoxType);
            var resource = creature.Faction.ListResources().Where(r => voxtype.CanBuildWith(ResourceLibrary.GetResourceByName(r.Key))).FirstOrDefault();

            if (resource.Key == null)
            {
                return(null);
            }

            var resources = new ResourceAmount(resource.Value.ResourceType, 1);

            return(new Select(
                       new Sequence(
                           new GetResourcesAct(creature.AI, new List <ResourceAmount>()
            {
                resources
            }),
                           new Domain(() => Validate(creature.AI, Voxel, resources),
                                      new GoToVoxelAct(Voxel, PlanAct.PlanType.Radius, creature.AI, 4.0f)),
                           new PlaceVoxelAct(Voxel, creature.AI, resources, VoxType)),
                       new Wrap(creature.RestockAll))
            {
                Name = "Build Voxel"
            });
        }
Beispiel #10
0
        public bool Validate(CreatureAI creature, VoxelHandle voxel, ResourceAmount resources)
        {
            bool success = creature.Faction.Designations.IsVoxelDesignation(voxel, DesignationType.Put) &&
                           creature.Creature.Inventory.HasResource(resources);

            return(success);
        }
Beispiel #11
0
        public bool Remove(ResourceAmount resourceAmount, RestockType type)
        {
            for (int i = 0; i < resourceAmount.Count; i++)
            {
                var kRemove = -1;
                for (int k = 0; k < Resources.Count; k++)
                {
                    if (type == RestockType.None && Resources[k].MarkedForRestock)
                    {
                        continue;
                    }
                    else if (type == RestockType.RestockResource && !Resources[k].MarkedForRestock)
                    {
                        continue;
                    }
                    if (Resources[k].Resource != resourceAmount.Type)
                    {
                        continue;
                    }
                    kRemove = k;
                    break;
                }

                if (kRemove < 0)
                {
                    return(false);
                }

                Resources.RemoveAt(kRemove);
            }

            return(true);
        }
 public StockResourceAct(CreatureAI agent, ResourceAmount item) :
     base(agent)
 {
     ItemToStock = item.CloneResource();
     Name        = "Stock Item";
     Tree        = null;
 }
 public StockResourceTask(ResourceAmount entity)
 {
     Category       = TaskCategory.Gather;
     EntityToGather = entity.CloneResource();
     Name           = "Stock Entity: " + entity.ResourceType + " " + entity.NumResources;
     Priority       = PriorityType.Low;
 }
Beispiel #14
0
 public PlaceVoxelAct(Voxel voxel, CreatureAI agent, ResourceAmount resource)
     : base(agent)
 {
     Agent = agent;
     Voxel = voxel;
     Name = "Build Voxel " + voxel.ToString();
     Resource = resource;
 }
Beispiel #15
0
 public PlaceVoxelAct(Voxel voxel, CreatureAI agent, ResourceAmount resource) :
     base(agent)
 {
     Agent    = agent;
     Voxel    = voxel;
     Name     = "Build Voxel " + voxel.ToString();
     Resource = resource;
 }
 public SearchFreeStockpileAct(CreatureAI creature, string stockName, string voxName, ResourceAmount itemToStock)
     : base(creature)
 {
     Name = "Search Stockpile " + stockName;
     StockpileName = stockName;
     VoxelName = voxName;
     Item = itemToStock;
 }
Beispiel #17
0
 public StockResourceTask(ResourceAmount entity)
 {
     Category        = TaskCategory.Gather;
     EntityToGather  = entity.CloneResource();
     Name            = "Stock Entity: " + entity.ResourceType + " " + entity.NumResources;
     Priority        = PriorityType.Medium;
     ReassignOnDeath = false;
     BoredomIncrease = GameSettings.Default.Boredom_NormalTask;
 }
Beispiel #18
0
 public StockResourceTask(ResourceAmount entity)
 {
     Category        = TaskCategory.Gather;
     EntityToGather  = entity.CloneResource();
     Name            = "Stock Entity: " + entity.ResourceType + " " + entity.NumResources;
     Priority        = PriorityType.Low;
     ReassignOnDeath = false;
     BoredomIncrease = 0.1f;
 }
Beispiel #19
0
        public bool HasResources(ResourceAmount resource)
        {
            if (resource != null && Resources.ContainsKey(resource.Type))
            {
                int toReturn = Resources[resource.Type].Count;
                return(toReturn >= resource.Count);;
            }

            return(false);
        }
Beispiel #20
0
 public TransferResourcesTask(WorldManager World, string stockpile, ResourceAmount resources)
 {
     this.World      = World;
     Priority        = TaskPriority.Medium;
     StockpileFrom   = stockpile;
     Resources       = resources;
     Name            = String.Format("Transfer {0} {1} from {2}", Resources.Count, Resources.Type, stockpile);
     AutoRetry       = true;
     ReassignOnDeath = true;
 }
Beispiel #21
0
        public bool Verify(List <Voxel> refs, ResourceLibrary.ResourceType type)
        {
            ResourceAmount        requiredResources = new ResourceAmount(type, refs.Count);
            List <ResourceAmount> res = new List <ResourceAmount>()
            {
                requiredResources
            };

            return(Faction.HasResources(res));
        }
Beispiel #22
0
        public PlaceVoxelAct(
            VoxelHandle Location,
            CreatureAI Agent,
            ResourceAmount Resource) :
            base(Agent)
        {
            this.Location = Location;
            this.Resource = Resource;

            Name = "Build DestinationVoxel " + Location.ToString();
        }
        public override IEnumerable <Status> Run()
        {
            if (Tree != null)
            {
                return(base.Run());
            }
            var coins = new ResourceAmount("Coins", 1);

            Tree = new DepositMoney(Agent, Money);
            Tree.Initialize();
            return(base.Run());
        }
Beispiel #24
0
 public bool Pickup(ResourceAmount resourceAmount, RestockType restock)
 {
     for (int i = 0; i < resourceAmount.NumResources; i++)
     {
         Resources.Add(new InventoryItem()
         {
             Resource         = resourceAmount.ResourceType,
             MarkedForRestock = restock == RestockType.RestockResource
         });
     }
     return(true);
 }
Beispiel #25
0
 public void AddResource(ResourceAmount tradeGood, RestockType type = RestockType.RestockResource)
 {
     for (int i = 0; i < tradeGood.Count; i++)
     {
         Resources.Add(new InventoryItem()
         {
             Resource         = tradeGood.Type,
             MarkedForRestock = type == RestockType.RestockResource,
             MarkedForUse     = type != RestockType.RestockResource
         });
     }
 }
        public bool AddResources(ResourceAmount resources)
        {
            var amount   = new ResourceAmount(resources.Type, resources.Count);
            var resource = Library.GetResourceType(amount.Type);

            foreach (Stockpile stockpile in EnumerateZones().Where(s => s is Stockpile && (s as Stockpile).IsAllowed(resources.Type)))
            {
                int space = stockpile.Resources.MaxResources - stockpile.Resources.CurrentResourceCount;

                if (space >= amount.Count)
                {
                    stockpile.Resources.AddResource(amount);
                    stockpile.HandleBoxes();
                    foreach (var tag in resource.Tags)
                    {
                        if (!PersistentData.CachedResourceTagCounts.ContainsKey(tag))
                        {
                            PersistentData.CachedResourceTagCounts[tag] = 0;
                        }
                        PersistentData.CachedResourceTagCounts[tag] += amount.Count;
                    }

                    RecomputeCachedVoxelstate();
                    return(true);
                }
                else
                {
                    var amountToMove = space;
                    stockpile.Resources.AddResource(new ResourceAmount(resources.Type, amountToMove));
                    amount.Count -= amountToMove;

                    stockpile.HandleBoxes();
                    foreach (var tag in resource.Tags)
                    {
                        if (!PersistentData.CachedResourceTagCounts.ContainsKey(tag))
                        {
                            PersistentData.CachedResourceTagCounts[tag] = 0;
                        }
                        PersistentData.CachedResourceTagCounts[tag] += amountToMove;
                    }

                    RecomputeCachedVoxelstate();

                    if (amount.Count == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #27
0
        public bool RemoveResourcesWithToss(ResourceAmount resources, Vector3 position, Zone Zone) // Todo: Kill this one.
        {
            if (!Zone.Resources.HasResource(resources))
            {
                return(false);
            }
            if (!(Zone is Stockpile))
            {
                return(false);
            }

            var stock = Zone as Stockpile;

            // Todo: Stockpile deals with it's own boxes.
            var resourceType = Library.GetResourceType(resources.Type);
            var num          = stock.Resources.RemoveMaxResources(resources, resources.Count);

            stock.HandleBoxes();

            foreach (var tag in resourceType.Tags)
            {
                if (PersistentData.CachedResourceTagCounts.ContainsKey(tag)) // Move cache into worldmanager...
                {
                    PersistentData.CachedResourceTagCounts[tag] -= num;
                    Trace.Assert(PersistentData.CachedResourceTagCounts[tag] >= 0);
                }
            }

            for (int i = 0; i < num; i++)
            {
                // Make a toss from the last crate to the agent.
                var startPosition = stock.Voxels.Count > 0 ? stock.Voxels.First().Center + new Vector3(0.0f, 1.0f, 0.0f) : Vector3.Zero;
                if (stock.Boxes.Count > 0)
                {
                    startPosition = stock.Boxes.Last().Position + MathFunctions.RandVector3Cube() * 0.5f;
                }

                GameComponent newEntity = EntityFactory.CreateEntity <GameComponent>(resources.Type + " Resource", startPosition);

                TossMotion toss = new TossMotion(1.0f + MathFunctions.Rand(0.1f, 0.2f), 2.5f + MathFunctions.Rand(-0.5f, 0.5f), newEntity.LocalTransform, position);
                if (newEntity.GetRoot().GetComponent <Physics>().HasValue(out var newPhysics))
                {
                    newPhysics.CollideMode = Physics.CollisionMode.None;
                }
                newEntity.AnimationQueue.Add(toss);
                toss.OnComplete += () => newEntity.Die();
            }

            RecomputeCachedVoxelstate();
            return(true);
        }
Beispiel #28
0
        public int RemoveMaxResources(ResourceAmount resource, int count)
        {
            if (resource != null && Resources.ContainsKey(resource.Type))
            {
                int toReturn = Math.Min(count, Resources[resource.Type].Count);

                Resources[resource.Type].Count -= toReturn;
                CurrentResourceCount           -= toReturn;

                return(toReturn);
            }

            return(0);
        }
Beispiel #29
0
        public bool Validate(CreatureAI creature, VoxelHandle voxel, ResourceAmount resources)
        {
            if (creature.Blackboard.GetData <bool>("NoPath", false))
            {
                if (creature.Faction == creature.World.PlayerFaction)
                {
                    creature.World.MakeAnnouncement(String.Format("{0} cancelled build task because it is unreachable", creature.Stats.FullName));
                    creature.World.Master.TaskManager.CancelTask(this);
                }
                return(false);
            }

            return(creature.Creature.Inventory.HasResource(resources));
        }
Beispiel #30
0
        public static RoomData InitializeData()
        {
            Dictionary <ResourceLibrary.ResourceType, ResourceAmount> balloonPortResources = new Dictionary <ResourceLibrary.ResourceType, ResourceAmount>();
            ResourceAmount balloonStoneRequired = new ResourceAmount
            {
                ResourceType = ResourceLibrary.Resources[ResourceLibrary.ResourceType.Wood],
                NumResources = 1
            };

            balloonPortResources[ResourceLibrary.ResourceType.Wood] = balloonStoneRequired;

            RoomTile[,] flagTemplate =
            {
                {
                    RoomTile.None,
                    RoomTile.Wall | RoomTile.Edge
                },
                {
                    RoomTile.Wall | RoomTile.Edge,
                    RoomTile.Flag
                }
            };

            RoomTile[,] flagAccesories =
            {
                {
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None
                }
            };

            RoomTemplate flag = new RoomTemplate(PlacementType.All, flagTemplate, flagAccesories);


            List <RoomTemplate> balloonTemplates = new List <RoomTemplate>
            {
                flag
            };
            Texture2D roomIcons = TextureManager.GetTexture(ContentPaths.GUI.room_icons);

            return(new RoomData(BalloonPortName, 0, "Stockpile", balloonPortResources, balloonTemplates, new ImageFrame(roomIcons, 16, 1, 0))
            {
                Description = "Balloons pick up / drop off resources here.",
                CanBuildBelowGround = false
            });
        }
Beispiel #31
0
        public void DoTrade(TradeEvent trade)
        {
            PlayerFation.RemoveResources(trade.GoodsSent, Vector3.Zero, false);

            foreach (ResourceAmount resource in trade.GoodsReceived)
            {
                PlayerFation.AddResources(resource);

                List <ResourceAmount> removals = new List <ResourceAmount>();
                foreach (ResourceAmount other in Resources)
                {
                    if (other.ResourceType != resource.ResourceType)
                    {
                        continue;
                    }
                    other.NumResources -= resource.NumResources;

                    if (other.NumResources <= 0)
                    {
                        removals.Add(other);
                    }
                }

                Resources.RemoveAll(removals.Contains);
            }

            foreach (ResourceAmount other in trade.GoodsSent)
            {
                if (Resources.All(r => r.ResourceType != other.ResourceType))
                {
                    Resources.Add(other);
                }
                else
                {
                    ResourceAmount other1 = other;
                    foreach (
                        ResourceAmount r in Resources.Where(k => k.ResourceType == other1.ResourceType))
                    {
                        r.NumResources += other.NumResources;
                    }
                }
            }
            Envoy.DistributeGoods();
            PlayerFation.Economy.CurrentMoney -= trade.MoneySent;
            PlayerFation.Economy.CurrentMoney += trade.MoneyReceived;
            Envoy.TradeMoney -= trade.MoneyReceived;
            Envoy.TradeMoney += trade.MoneySent;
        }
Beispiel #32
0
        public bool AddResources(ResourceAmount resources)
        {
            ResourceAmount amount   = new ResourceAmount(resources.ResourceType, resources.NumResources);
            var            resource = ResourceLibrary.GetResourceByName(amount.ResourceType);

            foreach (Stockpile stockpile in Stockpiles)
            {
                int space = stockpile.Resources.MaxResources - stockpile.Resources.CurrentResourceCount;

                if (space >= amount.NumResources)
                {
                    stockpile.Resources.AddResource(amount);
                    stockpile.HandleBoxes();
                    foreach (var tag in resource.Tags)
                    {
                        if (!CachedResourceTagCounts.ContainsKey(tag))
                        {
                            CachedResourceTagCounts[tag] = 0;
                        }
                        CachedResourceTagCounts[tag] += amount.NumResources;
                    }
                    RecomputeCachedVoxelstate();
                    return(true);
                }
                else
                {
                    stockpile.Resources.AddResource(amount);
                    amount.NumResources -= space;
                    stockpile.HandleBoxes();
                    foreach (var tag in resource.Tags)
                    {
                        if (!CachedResourceTagCounts.ContainsKey(tag))
                        {
                            CachedResourceTagCounts[tag] = 0;
                        }
                        CachedResourceTagCounts[tag] += space;
                    }
                    RecomputeCachedVoxelstate();
                    if (amount.NumResources == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #33
0
        public static RoomData InitializeData()
        {
            Dictionary<ResourceLibrary.ResourceType, ResourceAmount> bedroomResources = new Dictionary<ResourceLibrary.ResourceType, ResourceAmount>();
            ResourceAmount woodRequired = new ResourceAmount
            {
                ResourceType = ResourceLibrary.Resources[ResourceLibrary.ResourceType.Wood],
                NumResources = 1
            };
            bedroomResources[ResourceLibrary.ResourceType.Wood] = woodRequired;

            List<RoomTemplate> bedroomTemplates = new List<RoomTemplate>();

            RoomTile[,] bedTemplate =
            {
                {
                    RoomTile.None,
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.Wall | RoomTile.Edge,
                    RoomTile.Pillow,
                    RoomTile.Bed
                },
                {
                    RoomTile.None,
                    RoomTile.Open,
                    RoomTile.None
                }
            };

            RoomTile[,] bedAccessories =
            {
                {
                    RoomTile.None,
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.Chair,
                    RoomTile.None
                }
            };
            RoomTemplate bed = new RoomTemplate(PlacementType.All, bedTemplate, bedAccessories);

            RoomTile[,] lampTemplate =
            {
                {
                    RoomTile.None,
                    RoomTile.Wall | RoomTile.Edge
                },
                {
                    RoomTile.Wall | RoomTile.Edge,
                    RoomTile.Lamp
                }
            };

            RoomTile[,] lampAccessories =
            {
                {
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None
                }
            };

            RoomTemplate lamp = new RoomTemplate(PlacementType.All, lampTemplate, lampAccessories);

            bedroomTemplates.Add(lamp);
            bedroomTemplates.Add(bed);
            Texture2D roomIcons = TextureManager.GetTexture(ContentPaths.GUI.room_icons);
            return new RoomData(BedRoomName, 0, "BrownTileFloor", bedroomResources, bedroomTemplates, new ImageFrame(roomIcons, 16, 2, 1))
            {
                Description = "Dwarves relax and rest here",
                CanBuildAboveGround = false
            };
        }
 public void SetResource(ResourceAmount amount)
 {
     Agent.Blackboard.SetData(ResourceName, amount);
 }
Beispiel #35
0
        public List<Body> RemoveAndCreate(ResourceAmount resources)
        {
            List<Body> toReturn = new List<Body>();

            if(!Resources.RemoveResource(resources.CloneResource()))
            {
                return toReturn;
            }

            for(int i = 0; i < resources.NumResources; i++)
            {
                Body newEntity = EntityFactory.CreateEntity<Body>(resources.ResourceType.ResourceName + " Resource",
                    GlobalTransform.Translation + MathFunctions.RandVector3Cube()*0.5f);
                toReturn.Add(newEntity);
            }

            return toReturn;
        }
Beispiel #36
0
 public bool Remove(ResourceAmount resourceAmount)
 {
     return Resources.RemoveResource(resourceAmount);
 }
Beispiel #37
0
 public bool Pickup(ResourceAmount resourceAmount)
 {
     return Resources.AddResource(resourceAmount);
 }
Beispiel #38
0
 protected bool Equals(ResourceAmount other)
 {
     return Equals(ResourceType, other.ResourceType) && NumResources == other.NumResources;
 }
Beispiel #39
0
        public void AddResources(List<ResourceAmount> resources)
        {
            foreach(ResourceAmount resource in resources)
            {
                ResourceLibrary.ResourceType resourceName = resource.ResourceType.Type;
                if(PutResources.ContainsKey(resourceName))
                {
                    ResourceAmount amount = PutResources[resourceName];
                    amount.NumResources += resource.NumResources;
                }
                else
                {
                    ResourceAmount amount = new ResourceAmount();
                    amount.NumResources += resource.NumResources;
                    amount.ResourceType = resource.ResourceType;

                    PutResources[resourceName] = amount;
                }
            }

            if(MeetsBuildRequirements())
            {
                Build();
            }
        }
Beispiel #40
0
 public bool Verify(List<Voxel> refs, ResourceLibrary.ResourceType type)
 {
     ResourceAmount requiredResources = new ResourceAmount(type, refs.Count);
     List<ResourceAmount> res = new List<ResourceAmount>() {requiredResources};
     return Faction.HasResources(res);
 }
Beispiel #41
0
        public override IEnumerable<Status> Run()
        {
            if(Target == null)
            {
                yield return Status.Fail;
            }

            switch (PickType)
            {
                case (PickUpType.Room):
                case (PickUpType.Stockpile):
                    {
                        if (Zone == null)
                        {
                            yield return Status.Fail;
                            break;
                        }
                        bool removed = Zone.Resources.RemoveResource(new ResourceAmount(Target.Tags[0]));

                        if (removed)
                        {
                            if(Creature.Inventory.Pickup(Target))
                            {
                                Agent.Blackboard.SetData(StashedItemOut, new ResourceAmount(Target));
                                SoundManager.PlaySound(ContentPaths.Audio.dig, Agent.Position);
                                yield return Status.Success;
                            }
                            else
                            {
                                yield return Status.Fail;
                            }
                        }
                        else
                        {
                            yield return Status.Fail;
                        }
                        break;
                    }
                case (PickUpType.None):
                    {
                        if (!Creature.Inventory.Pickup(Target))
                        {
                            yield return Status.Fail;
                        }

                        if (Creature.Faction.GatherDesignations.Contains(Target))
                        {
                            Creature.Faction.GatherDesignations.Remove(Target);
                        }

                        ResourceAmount resource = new ResourceAmount(Target);
                        Agent.Blackboard.SetData(StashedItemOut, resource);
                        Creature.DrawIndicator(resource.ResourceType.Image);
                        SoundManager.PlaySound(ContentPaths.Audio.dig, Agent.Position);
                        yield return Status.Success;
                        break;
                    }
            }
        }
Beispiel #42
0
        public void AddShipDesignation(ResourceAmount resource, Room port)
        {
            // TODO: Reimplement
            /*
            List<Body> componentsToShip = new List<Body>();

            foreach (Stockpile s in Stockpiles)
            {
                for (int i = componentsToShip.Count; i < resource.NumResources; i++)
                {
                    Body r = s.FindItemWithTag(resource.ResourceType.ResourceName, componentsToShip);

                    if (r != null)
                    {
                        componentsToShip.Add(r);
                    }
                }
            }

            ShipDesignations.Add(new ShipOrder(resource, port));
            */
        }
Beispiel #43
0
        public bool AddResources(ResourceAmount resources)
        {
            ResourceAmount amount = new ResourceAmount(resources.ResourceType, resources.NumResources);
            foreach (Stockpile stockpile in Stockpiles)
            {
                int space = stockpile.Resources.MaxResources - stockpile.Resources.CurrentResourceCount;

                if(space >= amount.NumResources)
                {
                    stockpile.Resources.AddResource(amount);
                    stockpile.HandleBoxes();
                    return true;
                }
                else
                {
                    stockpile.Resources.AddResource(amount);
                    amount.NumResources -= space;
                    stockpile.HandleBoxes();
                    if(amount.NumResources == 0)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #44
0
 public StockResourceTask(ResourceAmount entity)
 {
     EntityToGather = entity.CloneResource();
     Name = "Stock Entity: " + entity.ResourceType.ResourceName + " " + entity.NumResources;
     Priority = PriorityType.Low;
 }
Beispiel #45
0
 public ShipOrder(ResourceAmount resource, Room port)
 {
     Resource = resource;
     Port = port;
     Assignments = new List<Task>();
 }
Beispiel #46
0
        public bool HasAvailableResources(int numVoxels, Faction faction)
        {
            foreach (KeyValuePair<ResourceLibrary.ResourceType, ResourceAmount> resources in RequiredResources)
            {
                ResourceAmount required = new ResourceAmount(resources.Value)
                {
                    NumResources = (int) (numVoxels*resources.Value.NumResources*0.25f)
                };
                if (!faction.HasResources(new List<ResourceAmount>() {required}))
                {
                    return false;
                }
            }

            return true;
        }
Beispiel #47
0
        public override IEnumerable<Status> Run()
        {
            if (Tree == null)
            {
                if (ItemToStock == null)
                {
                    ItemToStock = Agent.Blackboard.GetData<ResourceAmount>(ItemID);
                }

                if (ItemToStock != null)
                {

                    Tree = new Sequence(
                        new SetBlackboardData<ResourceAmount>(Agent, "GatheredResource", ItemToStock.CloneResource()),
                        new SearchFreeStockpileAct(Agent, "TargetStockpile", "FreeVoxel"),

                                        new Select(
                                                    new Sequence(
                                                                    new GoToVoxelAct("FreeVoxel", PlanAct.PlanType.Adjacent, Agent),
                                                                    new PutResourceInZone(Agent, "TargetStockpile", "FreeVoxel", "GatheredResource")
                                                                )
                                                  )

                        ) | new Wrap(OnFail)
                     ;

                    Tree.Initialize();
                }
            }

            return base.Run();
        }
Beispiel #48
0
        public static RoomData InitializeData()
        {
            RoomTile[,] lampTemplate =
            {
                {
                    RoomTile.None,
                    RoomTile.Wall | RoomTile.Edge
                },
                {
                    RoomTile.Wall | RoomTile.Edge,
                    RoomTile.Lamp
                }
            };

            RoomTile[,] lampAccessories =
            {
                {
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None
                }
            };

            RoomTemplate lamp = new RoomTemplate(PlacementType.All, lampTemplate, lampAccessories);
            ResourceAmount woodRequired = new ResourceAmount
            {
                ResourceType = ResourceLibrary.Resources[ResourceLibrary.ResourceType.Wood],
                NumResources = 1
            };
            Dictionary<ResourceLibrary.ResourceType, ResourceAmount> commonRoomResources = new Dictionary<ResourceLibrary.ResourceType, ResourceAmount>();
            commonRoomResources[ResourceLibrary.ResourceType.Wood] = woodRequired;

            ResourceAmount stoneRquired = new ResourceAmount
            {
                ResourceType = ResourceLibrary.Resources[ResourceLibrary.ResourceType.Stone],
                NumResources = 1
            };

            commonRoomResources[ResourceLibrary.ResourceType.Stone] = stoneRquired;

            List<RoomTemplate> commonRoomTemplates = new List<RoomTemplate>();

            RoomTile[,] tableTemps =
            {
                {
                    RoomTile.None,
                    RoomTile.Open,
                    RoomTile.None
                },
                {
                    RoomTile.Open,
                    RoomTile.Table,
                    RoomTile.Open
                },
                {
                    RoomTile.None,
                    RoomTile.Open,
                    RoomTile.None
                }
            };

            RoomTile[,] tableAcc =
            {
                {
                    RoomTile.None,
                    RoomTile.Chair,
                    RoomTile.None
                },
                {
                    RoomTile.Chair,
                    RoomTile.None,
                    RoomTile.Chair
                },
                {
                    RoomTile.None,
                    RoomTile.Chair,
                    RoomTile.None
                }
            };
            RoomTemplate table = new RoomTemplate(PlacementType.All, tableTemps, tableAcc);

            commonRoomTemplates.Add(lamp);
            commonRoomTemplates.Add(table);
            Texture2D roomIcons = TextureManager.GetTexture(ContentPaths.GUI.room_icons);
            return new RoomData(CommonRoomName, 1, "CobblestoneFloor", commonRoomResources, commonRoomTemplates, new ImageFrame(roomIcons, 16, 2, 0))
            {
                Description = "Dwarves come here to socialize and drink",
                CanBuildAboveGround = false
            };
        }
Beispiel #49
0
 public ResourceAmount(ResourceAmount other)
 {
     ResourceType = other.ResourceType;
     NumResources = other.NumResources;
 }
Beispiel #50
0
        public static RoomData InitializeData()
        {
            List<RoomTemplate> trainingTemplates = new List<RoomTemplate>();

            RoomTile[,] targetTemp =
            {
                {
                    RoomTile.Open,
                    RoomTile.Open,
                    RoomTile.Open
                },
                {
                    RoomTile.Open,
                    RoomTile.Strawman,
                    RoomTile.Open
                },
                {
                    RoomTile.Open,
                    RoomTile.Open,
                    RoomTile.Open
                }
            };

            RoomTile[,] strawAcc =
            {
                {
                    RoomTile.None,
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None,
                    RoomTile.Target
                },
                {
                    RoomTile.None,
                    RoomTile.None,
                    RoomTile.None
                }
            };

            RoomTemplate straw = new RoomTemplate(PlacementType.All, targetTemp, strawAcc);
            RoomTile[,] lampTemplate =
            {
                {
                    RoomTile.None,
                    RoomTile.Wall | RoomTile.Edge
                },
                {
                    RoomTile.Wall | RoomTile.Edge,
                    RoomTile.Lamp
                }
            };

            RoomTile[,] lampAccessories =
            {
                {
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None
                }
            };

            RoomTemplate lamp = new RoomTemplate(PlacementType.All, lampTemplate, lampAccessories);
            trainingTemplates.Add(lamp);
            trainingTemplates.Add(straw);
            Dictionary<ResourceLibrary.ResourceType, ResourceAmount> roomResources = new Dictionary<ResourceLibrary.ResourceType, ResourceAmount>();
            ResourceAmount woodRequired = new ResourceAmount
            {
                ResourceType = ResourceLibrary.Resources[ResourceLibrary.ResourceType.Stone],
                NumResources = 1
            };
            roomResources[ResourceLibrary.ResourceType.Stone] = woodRequired;
            Texture2D roomIcons = TextureManager.GetTexture(ContentPaths.GUI.room_icons);
            return new RoomData(TrainingRoomName, 3, "CobblestoneFloor", roomResources, trainingTemplates, new ImageFrame(roomIcons, 16, 3, 0))
            {
                Description = "Military dwarves train here"
            };
        }
Beispiel #51
0
        public static RoomData InitializeData()
        {
            Dictionary<ResourceLibrary.ResourceType, ResourceAmount> balloonPortResources = new Dictionary<ResourceLibrary.ResourceType, ResourceAmount>();
            ResourceAmount balloonStoneRequired = new ResourceAmount
            {
                ResourceType = ResourceLibrary.Resources[ResourceLibrary.ResourceType.Wood],
                NumResources = 1
            };
            balloonPortResources[ResourceLibrary.ResourceType.Wood] = balloonStoneRequired;

            RoomTile[,] flagTemplate =
            {
                {
                    RoomTile.None,
                    RoomTile.Wall | RoomTile.Edge
                },
                {
                    RoomTile.Wall | RoomTile.Edge,
                    RoomTile.Flag
                }
            };

            RoomTile[,] flagAccesories =
            {
                {
                    RoomTile.None,
                    RoomTile.None
                },
                {
                    RoomTile.None,
                    RoomTile.None
                }
            };

            RoomTemplate flag = new RoomTemplate(PlacementType.All, flagTemplate, flagAccesories);

            List<RoomTemplate> balloonTemplates = new List<RoomTemplate>
            {
                flag
            };
            Texture2D roomIcons = TextureManager.GetTexture(ContentPaths.GUI.room_icons);
            return new RoomData(BalloonPortName, 0, "Stockpile", balloonPortResources, balloonTemplates, new ImageFrame(roomIcons, 16, 1, 0))
            {
                Description = "Balloons pick up / drop off resources here.",
                CanBuildBelowGround = false
            };
        }