Ejemplo n.º 1
0
    public virtual void PlaceOnPlanet(Planet planet, Vector3 position)
    {
        this.planet             = planet;
        this.transform.position = position;
        this.activeWorkers      = (planet.population - planet.activeWorkers) >= this.entityData.activeWorkersRequirement ? this.entityData.activeWorkersRequirement : (planet.population - planet.activeWorkers);

        this.isEnvironmental = this.entityData.activeWorkersRequirement <= 0;

        planet.activeWorkers += this.activeWorkers;

        if (this.entityData.pollution != 0)
        {
            this.StartCoroutine(Pollute(this.entityData.pollution));
        }

        if (this.entityData.electricity != 0)
        {
            planet.AddElectricityPerSecond(this.entityData.electricity);
        }

        if (this.entityData.populationIncrease > 0)
        {
            planet.population += this.entityData.populationIncrease;
        }

        this.hasPlaced = true;

        if (this.activeWorkers < this.entityData.activeWorkersRequirement)
        {
            isRunning = false;
            planet.QueueEntityForLowPopulationActivation(this);
        }

        if (Mathf.Abs(this.entityData.electricity) > planet.electricity)
        {
            isRunning = false;
            planet.QueueEntityForLowElectricityActivation(this);
        }

        planet.happiness += this.entityData.happiness;

        this.StartCoroutine(GenerateMoney());
    }