Пример #1
0
        public void growthMonitior(float dt)
        {
            //Determines if the plant is ready to blossom
            if (Api.World.BlockAccessor.GetBlock(Pos.DownCopy()).Id != 0)
            {
                return;
            }
            Room room = rmaker?.GetRoomForPosition(Pos);

            greenhouse = (room != null && room.SkylightCount > room.NonSkylightCount && room.ExitCount == 0);

            if (blossomAt > Api.World.Calendar.TotalHours)
            {
                return;
            }
            float temperature = Api.World.BlockAccessor.GetClimateAt(Pos, EnumGetClimateMode.NowValues).Temperature;

            if ((temperature < minTemp || temperature > maxTemp) && !greenhouse)
            {
                blossomAt += 18;
                return;
            }

            Block         self      = Api.World.BlockAccessor.GetBlock(Pos);
            AssetLocation plantCode = self.CodeWithPart("section", 1);
            Block         plant     = Api.World.GetBlock(plantCode);

            Api.World.BlockAccessor.SetBlock(plant.Id, Pos);
            Api.World.BlockAccessor.SetBlock(self.Id, Pos.DownCopy());
        }
Пример #2
0
        public void UpdateStep(float step)
        {
            //Determines if the plant is ready to blossom
            Room room = rmaker?.GetRoomForPosition(Pos);

            greenhouse = (room != null && room.SkylightCount > room.NonSkylightCount && room.ExitCount == 0);

            if (blossomAt > Api.World.Calendar.TotalHours)
            {
                return;
            }
            float temperature = Api.World.BlockAccessor.GetClimateAt(Pos, EnumGetClimateMode.NowValues).Temperature;

            if ((temperature < minTemp || temperature > maxTemp) && !greenhouse)
            {
                blossomAt += 18;
                return;
            }

            Block  self      = Api.World.BlockAccessor.GetBlock(Pos);
            string plantCode = self.CodeEndWithoutParts(1);
            Block  plant     = Api.World.GetBlock(new AssetLocation("game:" + plantCode));

            Api.World.BlockAccessor.SetBlock(plant.Id, Pos);
        }