Example #1
0
        public static void TransferWater(CompWaterContainer fromWc, CompWaterContainer toWc, float litres)
        {
            if (litres > toWc.FreeSpaceLitres)
            {
                if (litres > toWc.FreeSpaceLitres + 0.001f)
                {
                    Log.Error(string.Format("TransferWater() trying to put {0} litres into {1} with "
                        + "{2} litres free space.", litres, toWc.parent.Label, toWc.FreeSpaceLitres));
                }
                litres = toWc.FreeSpaceLitres;
            }

            float transfer = fromWc.RemoveWater(litres);
            toWc.AddWater(transfer);
        }
Example #2
0
        public static Toil WaterPlant(Plant plant, CompWaterContainer fromWC, float waterLitres)
        {
            var toil = new Toil();
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration = 180;
            toil.initAction = delegate
            {
                if (fromWC == null || plant == null)
                {
                    Log.Error("WaterPlant has a null parameter.");
                    toil.actor.jobs.curDriver.EndJobWith(JobCondition.Errored);
                    return;
                }

                if (fromWC.StoredLitres < waterLitres)
                {
                    toil.actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable);
                }

                fromWC.RemoveWater(waterLitres);
                plant.Watered();
            };
            return toil;
        }
Example #3
0
 public float DrinkFrom(CompWaterContainer waterContainer, float litresWanted)
 {
     float litresDrunk = waterContainer.RemoveWater(litresWanted);
     CurLevelLitres += litresDrunk;
     return litresDrunk;
 }