Exemplo n.º 1
0
        public Building(Vector2Int position, TilableDef def)
        {
            this.position = position;
            this.def      = def;
            this.recipe   = new Recipe(this.def.recipeDef, this, position);
            this.work     = 0;

            if (this.def.type == TilableType.BuildingConnected)
            {
                this.mainGraphic = GraphicInstance.GetNew(
                    this.def.graphics,
                    new Color(112 / 255f, 78 / 255f, 46 / 255f, .5f),               // update alpha when constructed
                    Res.textures[this.def.graphics.textureName + "_0"],
                    1
                    );
                this._connectedUtility = new ConnectedTilable(this);
            }
            this.addGraphics = new Dictionary <string, GraphicInstance>();

            Tilable tilable = Loki.map.grids[Layer.Plant].GetTilableAt(this.position);

            if (tilable != null && tilable.def.cuttable)
            {
                tilable.AddOrder(Defs.orders["cut_plants"]);
            }
        }
Exemplo n.º 2
0
 public ConnectedTilable(Tilable tilable)
 {
     this.tilable        = tilable;
     this.connections    = new bool[8];
     this.connectionsInt = -1;
     this.allCorners     = false;
     this.corners        = new bool[4];
 }
Exemplo n.º 3
0
 public ConnectedTilable(Tilable tilable)
 {
     this.tilable        = tilable;
     this.connections    = new bool[8];
     this.connectionsInt = -1;
     this.allCorners     = false;
     this.corners        = new bool[4];
     this.defColor       = tilable.mainGraphic.color;
 }
Exemplo n.º 4
0
        /// Check if this.tilable is linked with an other tilable at "position".
        private bool HasLink(Vector2Int position)
        {
            Tilable tilable = Loki.map.GetTilableAt(position, this.tilable.def.layer);

            if (tilable == null || this.tilable.def != tilable.def)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
0
 public static void InRadius(int r, Vector2Int o, Vector2Int c, ref HashSet <Vector2Int> s)
 {
     if (c != null)
     {
         s.Add(c);
     }
     foreach (Vector2Int neighbour in Tilable.GetNeighboursPosition(c))
     {
         if (
             neighbour.x >= 0 && neighbour.y >= 0 && neighbour.x <= Loki.map.size.x && neighbour.y <= Loki.map.size.y &&
             !s.Contains(neighbour) &&
             Utils.Distance(neighbour, o) <= r)
         {
             Tilable.InRadius(r, o, neighbour, ref s);
         }
     }
 }