コード例 #1
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            totalHoursWaterRetention = Api.World.Calendar.HoursPerDay + 0.5;

            upPos = base.Pos.UpCopy();
            wsys  = api.ModLoader.GetModSystem <WeatherSystemBase>();
            allowundergroundfarming = Api.World.Config.GetBool("allowUndergroundFarming", false);
            allowcropDeath          = Api.World.Config.GetBool("allowCropDeath", true);

            if (api is ICoreServerAPI)
            {
                RegisterGameTickListener(Update, 3300 + rand.Next(400));
                api.ModLoader.GetModSystem <POIRegistry>().AddPOI(this);
                roomreg = Api.ModLoader.GetModSystem <RoomRegistry>();
            }


            if (Block.Attributes != null)
            {
                delayGrowthBelowSunLight = Block.Attributes["delayGrowthBelowSunLight"].AsInt(19);
                lossPerLevel             = Block.Attributes["lossPerLevel"].AsFloat(0.1f);

                if (weedNames == null)
                {
                    weedNames = Block.Attributes["weedBlockCodes"].AsObject <CodeAndChance[]>();
                    for (int i = 0; weedNames != null && i < weedNames.Length; i++)
                    {
                        totalWeedChance += weedNames[i].Chance;
                    }
                }
            }
        }
コード例 #2
0
        public override void Initialize(ICoreAPI api, JsonObject properties)
        {
            base.Initialize(api, properties);

            if (api.Side == EnumAppSide.Server)
            {
                Blockentity.RegisterGameTickListener(onRootTick, 5000, api.World.Rand.Next(5000));
            }

            roomreg = api.ModLoader.GetModSystem <RoomRegistry>();

            blockBranch = be.Block as BlockFruitTreeBranch;

            RegisterTreeType(bebr.TreeType);

            double totalDays = api.World.Calendar.TotalDays;

            if (TreePlantedTotalDays == 0)
            {
                TreePlantedTotalDays  = totalDays;
                LastRootTickTotalDays = totalDays;
            }
            else
            {
                // In case this block was imported from another older world. In that case lastCheckAtTotalDays would be a future date.
                TreePlantedTotalDays  = Math.Min(TreePlantedTotalDays, totalDays);
                LastRootTickTotalDays = Math.Min(LastRootTickTotalDays, totalDays);
            }
        }
コード例 #3
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            Inventory.LateInitialize(InventoryClassName + "-" + Pos.X + "/" + Pos.Y + "/" + Pos.Z, api);
            Inventory.Pos = Pos;
            Inventory.ResolveBlocksOrItems();
            Inventory.OnAcquireTransitionSpeed = Inventory_OnAcquireTransitionSpeed;
            if (api.Side == EnumAppSide.Client)
            {
                Inventory.OnInventoryOpened += Inventory_OnInventoryOpenedClient;
            }

            RegisterGameTickListener(OnTick, 10000);

            roomReg = Api.ModLoader.GetModSystem <RoomRegistry>();
            room    = roomReg.GetRoomForPosition(Pos);
        }
コード例 #4
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            if (api is ICoreServerAPI)
            {
                if (transitionHoursLeft <= 0)
                {
                    transitionHoursLeft  = GetHoursForNextStage();
                    lastCheckAtTotalDays = api.World.Calendar.TotalDays;
                }

                RegisterGameTickListener(CheckGrow, 8000);

                api.ModLoader.GetModSystem <POIRegistry>().AddPOI(this);
                roomreg = Api.ModLoader.GetModSystem <RoomRegistry>();

                if (totalDaysForNextStageOld != null)
                {
                    transitionHoursLeft = ((double)totalDaysForNextStageOld - Api.World.Calendar.TotalDays) * Api.World.Calendar.HoursPerDay;
                }
            }
        }