ClearSides FindClearSides(ResourceType t, CPos p)
		{
			var ret = ClearSides.None;
			if (!CellContains(p + new CVec(0, -1), t))
				ret |= ClearSides.Top | ClearSides.TopLeft | ClearSides.TopRight;

			if (!CellContains(p + new CVec(-1, 0), t))
				ret |= ClearSides.Left | ClearSides.TopLeft | ClearSides.BottomLeft;

			if (!CellContains(p + new CVec(1, 0), t))
				ret |= ClearSides.Right | ClearSides.TopRight | ClearSides.BottomRight;

			if (!CellContains(p + new CVec(0, 1), t))
				ret |= ClearSides.Bottom | ClearSides.BottomLeft | ClearSides.BottomRight;

			if (!CellContains(p + new CVec(-1, -1), t))
				ret |= ClearSides.TopLeft;

			if (!CellContains(p + new CVec(1, -1), t))
				ret |= ClearSides.TopRight;

			if (!CellContains(p + new CVec(-1, 1), t))
				ret |= ClearSides.BottomLeft;

			if (!CellContains(p + new CVec(1, 1), t))
				ret |= ClearSides.BottomRight;

			return ret;
		}
        ClearSides FindClearSides(ResourceType t, CPos p)
        {
            var ret = ClearSides.None;
            if (Tiles[p + new CVec(0, -1)].Type != t)
                ret |= ClearSides.Top | ClearSides.TopLeft | ClearSides.TopRight;

            if (Tiles[p + new CVec(-1, 0)].Type != t)
                ret |= ClearSides.Left | ClearSides.TopLeft | ClearSides.BottomLeft;

            if (Tiles[p + new CVec(1, 0)].Type != t)
                ret |= ClearSides.Right | ClearSides.TopRight | ClearSides.BottomRight;

            if (Tiles[p + new CVec(0, 1)].Type != t)
                ret |= ClearSides.Bottom | ClearSides.BottomLeft | ClearSides.BottomRight;

            if (Tiles[p + new CVec(-1, -1)].Type != t)
                ret |= ClearSides.TopLeft;

            if (Tiles[p + new CVec(1, -1)].Type != t)
                ret |= ClearSides.TopRight;

            if (Tiles[p + new CVec(-1, 1)].Type != t)
                ret |= ClearSides.BottomLeft;

            if (Tiles[p + new CVec(1, 1)].Type != t)
                ret |= ClearSides.BottomRight;

            return ret;
        }
Beispiel #3
0
        public SeedsResource(Actor self, SeedsResourceInfo info)
        {
            this.info = info;

            resourceType = self.World.WorldActor.TraitsImplementing<ResourceType>()
                .FirstOrDefault(t => t.Info.Name == info.ResourceType);

            if (resourceType == null)
                throw new InvalidOperationException("No such resource type `{0}`".F(info.ResourceType));

            resLayer = self.World.WorldActor.Trait<ResourceLayer>();
        }
Beispiel #4
0
        bool CellContainsMaxDensity(CPos c, ResourceType t)
        {
            if (!Tiles.Contains(c))
                return false;

            if (FindClearSides(t, c) != ClearSides.None)
                return false;

            var tile = Tiles[c];

            // Empty tile
            if (tile.Type == null)
            {
                return false;
            }

            var density = ResourceDensityAt(c);

            return density > tile.Type.Info.MaxDensity / 2;
        }
 protected override string ChooseRandomVariant(ResourceType t)
 {
     return D2kResourceLayer.Variants.Keys.Random(Game.CosmeticRandom);
 }
Beispiel #6
0
 public void AcceptResource(ResourceType type)
 {
     if (!contents.ContainsKey(type.Info)) contents[type.Info] = 1;
     else contents[type.Info]++;
 }
Beispiel #7
0
        ClearSides FindMaxDensityClearSides(ResourceType t, CPos p)
        {
            var ret = ClearSides.None;
            if (!CellContainsMaxDensity(p + new CVec(0, -1), t))
                ret |= ClearSides.Top;

            if (!CellContainsMaxDensity(p + new CVec(-1, 0), t))
                ret |= ClearSides.Left;

            if (!CellContainsMaxDensity(p + new CVec(1, 0), t))
                ret |= ClearSides.Right;

            if (!CellContainsMaxDensity(p + new CVec(0, 1), t))
                ret |= ClearSides.Bottom;

            return ret;
        }
Beispiel #8
0
        bool CellContainsMaxDensity(CPos c, ResourceType t)
        {
            if (!RenderContent.Contains(c))
                return false;

            if (FindClearSides(t, c) != ClearSides.None)
                return false;

            var tile = RenderContent[c];
            return tile.Density > tile.Type.Info.MaxDensity / 2;
        }
Beispiel #9
0
 bool CellContains(CPos c, ResourceType t)
 {
     return RenderContent.Contains(c) && RenderContent[c].Type == t;
 }
		bool CellContains(CPos c, ResourceType t)
		{
			return Tiles.Contains(c) && Tiles[c].Type == t;
		}
Beispiel #11
0
 // We do not handle Harvested notification
 public void Harvested(Actor self, ResourceType resource)
 {
 }
Beispiel #12
0
 // We do not handle Harvested notification
 void INotifyHarvesterAction.Harvested(Actor self, ResourceType resource)
 {
 }
Beispiel #13
0
 Sprite[] ChooseContent(ResourceType t)
 {
     return(t.info.Sprites[world.SharedRandom.Next(t.info.Sprites.Length)]);
 }