Exemplo n.º 1
0
    protected override void Update()
    {
        base.Update();

        BuildTask.ValidateConstructionSite(Builder);

        if (BuildTask.Target == null)
        {
            return;
        }

        if (!Builder.IsWithinReach(BuildTask.ConstructionSite, BuildTask.ConstructionSiteSize))
        {
            Vector3 edge_of_construction_site =
                BuildTask.ConstructionSite +
                (transform.position - BuildTask.ConstructionSite).normalized * Builder.Reach * 0.9f;

            this.Start <SeekBehavior>().Target = edge_of_construction_site;

            Builder.StopBuilding();
        }
        else
        {
            this.Stop <SeekBehavior>();

            if (BuildTask.Project == null)
            {
                if (BuildTask.IsConstructionSiteClear)
                {
                    BuildTask.PlaceBlueprint();
                }
                else
                {
                    return;
                }
            }

            Builder.Build(BuildTask.Project);
        }
    }