コード例 #1
0
        public override void StartServerSide(ICoreServerAPI api)
        {
            sapi = api;

            if (api.ModLoader.IsModSystemEnabled("Vintagestory.ServerMods.WorldEdit.WorldEdit"))
            {
                RegisterUtil.RegisterTool(api.ModLoader.GetModSystem("Vintagestory.ServerMods.WorldEdit.WorldEdit"));
            }

            // Set up day/night cycle
            api.WorldManager.SetBlockLightLevels(config.BlockLightLevels);
            api.WorldManager.SetSunLightLevels(config.SunLightLevels);
            api.WorldManager.SetSunBrightness(config.SunBrightness);

            api.Event.PlayerCreate     += Event_PlayerCreate;
            api.Event.PlayerNowPlaying += Event_PlayerPlaying;
            api.Event.PlayerJoin       += Event_PlayerJoin;

            api.Event.ServerRunPhase(EnumServerRunPhase.ModsAndConfigReady, loadConfig);

            api.Event.ServerRunPhase(EnumServerRunPhase.GameReady, () => {
                applyConfig();
                config.ResolveStartItems(api.World);
                api.World.Calendar.OnGetSolarSphericalCoords = GetSolarSphericalCoords;
                api.World.Calendar.OnGetHemisphere           = GetHemisphere;
            });

            AiTaskRegistry.Register <AiTaskBellAlarm>("bellalarm");
            AiTaskRegistry.Register <AiTaskThrowAtEntity>("throwatentity");
        }
コード例 #2
0
        public override void Start(ICoreAPI api)
        {
            GameVersion.EnsureEqualVersionOrKillExecutable(api, System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion, GameVersion.OverallVersion, "VSSurvivalMod");

            this.api = api;
            api.Network.RegisterChannel("survivalCoreConfig").RegisterMessageType <SurvivalConfig>();

            RegisterDefaultBlocks();
            RegisterDefaultBlockBehaviors();
            RegisterDefaultBlockEntityBehaviors();

            RegisterDefaultCollectibleBehaviors();

            RegisterDefaultCropBehaviors();
            RegisterDefaultItems();
            RegisterDefaultEntities();
            RegisterDefaultEntityBehaviors();
            RegisterDefaultBlockEntities();

            api.RegisterMountable("bed", BlockBed.GetMountable);
            AiTaskRegistry.Register("throwatentity", typeof(AiTaskThrowAtEntity));

            metalsByCode = new Dictionary <string, MetalPropertyVariant>();

            MetalProperty metals = api.Assets.TryGet("worldproperties/block/metal.json").ToObject <MetalProperty>();

            for (int i = 0; i < metals.Variants.Length; i++)
            {
                // Metals currently don't have a domain
                metalsByCode[metals.Variants[i].Code.Path] = metals.Variants[i];
            }
        }
コード例 #3
0
 static EntityButterfly()
 {
     AiTaskRegistry.Register <AiTaskButterflyWander>("butterflywander");
     AiTaskRegistry.Register <AiTaskButterflyRest>("butterflyrest");
     AiTaskRegistry.Register <AiTaskButterflyChase>("butterflychase");
     AiTaskRegistry.Register <AiTaskButterflyFlee>("butterflyflee");
     AiTaskRegistry.Register <AiTaskButterflyFeedOnFlowers>("butterflyfeedonflowers");
 }
コード例 #4
0
        static EntityFish()
        {
            AiTaskRegistry.Register <AiTaskFishMoveFast>("fishmovefast");
            AiTaskRegistry.Register <AiTaskFishOutOfWater>("fishoutofwater");

            //TODO: in flowing water, either leap or swim faster?  align against flow
            //TODO: die if out of water for too long
        }
コード例 #5
0
 public static void RegisterAiTask <T>(this ICoreServerAPI sapi, string code) where T : AiTaskBase
 {
     AiTaskRegistry.Register <T>(code);
 }
コード例 #6
0
 public static void RegisterAiTask(this ICoreServerAPI sapi, string code, Type type)
 {
     AiTaskRegistry.Register(code, type);
 }