Esempio n. 1
0
    public override void onTaskStop()
    {
        base.onTaskStop();

        this.timeBuilding = 0;

        if (this.buildSite != null)
        {
            this.buildSite.stopPs();
        }

        this.buildSite = null;
    }
Esempio n. 2
0
    public override bool shouldExecute()
    {
        this.buildSite = this.calculateAndSetPathToClosest <CellBehaviorBuildSite>(
            true,
            behavior => behavior.isPrimary && !behavior.isOccupied());

        if (this.buildSite != null)
        {
            this.buildSite.setOccupant(this.owner); // Claim it so no one takes it.
            return(true);
        }

        return(false);
    }
    public override void placeIntoWorld(World world, BuildAreaHighlighter highlight, Position pos, Rotation rotation)
    {
        bool instantBuild = this.shouldBuildInstantly(highlight);

        CellBehaviorBuildSite site = null;

        if (!instantBuild)
        {
            world.setCell(pos, highlight.buildSiteCell, rotation);
            world.liftFog(pos);
            site = world.getBehavior <CellBehaviorBuildSite>(pos);
            site.setPrimary(this.getCellAt(0, 0), this.buildTime, this.fogOption == EnumFogOption.PLACE);
        }

        for (int x = 0; x < this.getHighlightWidth(); x++)
        {
            for (int y = 0; y < this.getHighlightHeight(); y++)
            {
                CellData data = this.getCellAt(x, y);
                if (data != null)
                {
                    Position pos1 = pos.add(x, y);

                    if (instantBuild)
                    {
                        world.setCell(pos1, data, rotation);
                    }
                    else
                    {
                        site.addChildBuildSite(data, pos.add(x, y), this.fogOption == EnumFogOption.PLACE);

                        // Skip over the middle cell, it's already been placed.
                        if (x == 0 && y == 0)
                        {
                            continue;
                        }

                        world.setCell(pos1, highlight.buildSiteCell, rotation);
                    }

                    this.applyFogOpperation(world, pos1);
                }
            }
        }

        // Increase stat
        world.statManager.getCellBuiltStat(this.getCellAt(0, 0))?.increase(1);
    }
Esempio n. 4
0
    public override void placeIntoWorld(World world, BuildAreaHighlighter highlight, Position pos, Rotation rotation)
    {
        if (this.cell == null)
        {
            Debug.LogWarning("Can not place BuildableTile " + this.name + " into world, it has no Cell set.");
            return;
        }

        // Place build site/cell
        if (this.shouldBuildInstantly(highlight))
        {
            world.setCell(pos, this.cell, rotation);
            this.applyFogOpperation(world, pos);
        }
        else
        {
            world.setCell(pos, highlight.buildSiteCell, rotation);
            CellBehaviorBuildSite site = world.getBehavior <CellBehaviorBuildSite>(pos);
            site.setPrimary(this.cell, this.buildTime, this.fogOption == EnumFogOption.PLACE);
        }

        // Increase stat.
        world.statManager.getCellBuiltStat(this.cell)?.increase(1);
    }