Exemplo n.º 1
0
    public void Build(Tile tile)
    {
        if (buildModeIsObjects)
        {
            // Create the InstalledObject and assign it to the designated Tile.

            // Check legality of placing InstalledObject here.
            if (InstalledObject.CheckPlacementValidity(buildModeInstalledObjectType, tile))
            {
                // Create the InstalledObject as a new pending Job.

                WorldController.instance.world.PlaceInstalledObject(buildModeInstalledObjectType, tile);

                Job job = new Job(tile,
                                  (j) => {
                    tile.installedObject.SetInstalled(true);
                });

                // TODO: probably should move to somewhere else, too easy to forget to do this!!
                tile.pendingInstalledObjectJob = job;

                job.RegisterJobCancelCallback(j => { tile.pendingInstalledObjectJob = null; });

                // Add the job to the World's job queue.
                WorldController.instance.world.jobQueue.Enqueue(job);
            }
        }

        else
        {
            // We are in Tile changing mode, not object mode.
            if (tile != null)
            {
                tile.tileType = buildModeTile;
            }
        }
    }