Пример #1
0
    public override void Convert()
    {
        if (HasRover)
        {
            if (HasWater)
            {
#warning needs to only push if amount < max
                AttachedRover.Data.Water.Push(WaterIn.Get(Matter.Water).Pull(WaterPerTickUnits));
            }

            if (HasOxygen)
            {
#warning needs to only push if amount < max
                AttachedRover.Data.Oxygen.Push(OxygenIn.Get(Matter.Oxygen).Pull(OxygenPerTickUnits));
            }
        }
    }
Пример #2
0
    private bool PullWater()
    {
        if (WaterIn != null)
        {
            float newWater = WaterIn.Get(Matter.Water).Pull(WaterPerSecond * Time.fixedDeltaTime);
            waterBuffer += newWater;
            Data.MatterHistory.Consume(Matter.Water, newWater);

            float waterThisTick = WaterPerSecond * Time.fixedDeltaTime;

            if (waterBuffer >= waterThisTick)
            {
                waterBuffer -= waterThisTick;
                return(true);
            }
        }

        return(false);
    }
Пример #3
0
        protected virtual void FarmTick()
        {
            if (this.HasPower && this.IsOn && this.FlexData.IsWaterOn && this.FlexData.IsHeatOn)
            {
                cropFailureTicks = 0;

                if (this.WaterIn != null && !this.CanHarvest)
                {
                    if (Data.Containers[Matter.Water].CurrentAmount < this.WaterConsumptionPerTickInUnits)
                    {
                        Data.Containers[Matter.Water].Push(WaterIn.Get(Matter.Water).Pull(this.WaterConsumptionPerTickInUnits));
                    }

                    if (Data.Containers[Matter.Water].CurrentAmount >= this.WaterConsumptionPerTickInUnits)
                    {
                        oldBiomass = Data.Containers[Matter.Biomass].CurrentAmount;
                        Data.Containers[Matter.Water].Pull(WaterConsumptionPerTickInUnits);
                        Data.Containers[Matter.Biomass].Push(BiomassProductionPerTickInUnits);
                        CheckForAmountChange();

                        if (CanHarvest)
                        {
                            ToggleHarvestTrigger(true);
                        }
                    }
                }
            }
            else
            {
                if (this.Data.Containers[Matter.Biomass].CurrentAmount > 0f)
                {
                    float lossAmount = 0;
                    if (!FlexData.IsHeatOn)
                    {
                        lossAmount += BiomassProductionPerTickInUnits * FrostBiomassDamageCoefficient;
                    }
                    if (!FlexData.IsWaterOn)
                    {
                        lossAmount += BiomassProductionPerTickInUnits * DroughtBiomassDamageCoefficient;
                    }

                    oldBiomass = Data.Containers[Matter.Biomass].CurrentAmount;

                    Data.Containers[Matter.Biomass].Pull(lossAmount);

                    CheckForAmountChange();

                    if (cropFailureTicks == 0)
                    {
                        //GuiBridge.Instance.ComputerAudioSource.PlayOneShot(CropFailure)
                        cropFailureTicks++;
                    }
                    else if (cropFailureTicks > 59 * 2)
                    {
                        cropFailureTicks = 0;
                    }
                    else
                    {
                        cropFailureTicks++;
                    }
                }
            }

            UpdateText();
        }