Ejemplo n.º 1
0
        protected Vec3d DetermineTranslation()
        {
            double horiztontalTranslation, verticalTranslation;

            horiztontalTranslation = SpawnerRand.NextDouble();
            verticalTranslation    = SpawnerRand.NextDouble();

            bool isMovingEast  = Convert.ToBoolean(SpawnerRand.Next(0, 2));
            bool isMovingSouth = Convert.ToBoolean(SpawnerRand.Next(0, 2));

            Vec3d randomTranslation = new Vec3d
            {
                X = horiztontalTranslation,
                Y = verticalTranslation,
                Z = 1 - horiztontalTranslation
            };

            if (isMovingEast != false)
            {
                randomTranslation.X *= -1;
            }

            if (isMovingSouth != false)
            {
                randomTranslation.Y *= -1;
            }

            return(randomTranslation);
        }
Ejemplo n.º 2
0
        protected override void OnSpawnerTick(float deltaTime)
        {
            if (ServerAPI.World.ElapsedMilliseconds - TimeSinceSpawn > NextShower)
            {
                if (ServerAPI.World.AllOnlinePlayers.Length > 0)
                {
                    MeteorCode        = GetRandomEntityCode();
                    ShowerTranslation = DetermineTranslation();

                    int numShowerMeteors = SpawnerRand.Next(0, ServerAPI.World.Config.GetInt("MaxMeteorsPerShower"));
                    int showerTime       = SpawnerRand.Next(ServerAPI.World.Config.GetInt("MinimumShowerDurationInMinutes"), ServerAPI.World.Config.GetInt("MaximumShowerDurationInMinutes"));

                    UnregisterShowerCallbacks();

                    ShowerCallbacks = new long[numShowerMeteors];

                    for (int i = 0; i < ShowerCallbacks.Length; i++)
                    {
                        double offsetTime = SpawnerRand.NextDouble();

                        ShowerCallbacks[i] = ServerAPI.Event.RegisterCallback(SpawnShowerMeteor, (int)(MeteoricExpansionHelpers.ConvertMinutesToMilliseconds(SpawnerRand.Next(0, showerTime)) + MeteoricExpansionHelpers.ConvertMinutesToMilliseconds(offsetTime)));
                    }

                    NextSpawn = SpawnerRand.Next(MinShowerSpawnTime, MaxShowerSpawnTime) + SpawnerRand.NextDouble();
                    NextSpawn = MeteoricExpansionHelpers.ConvertMinutesToMilliseconds(NextSpawn);

                    TimeSinceSpawn = ServerAPI.World.ElapsedMilliseconds + MeteoricExpansionHelpers.ConvertMinutesToMilliseconds(showerTime);
                }
            }
        }
Ejemplo n.º 3
0
        //-- Spawn a meteor made with random rock and metals above the first online player every number of seconds as determined by tickIntervalInSeconds --//
        //-- Eventually spawns will happen between the minMeteorSpawnTime and maxMeteorSpawnTime --//
        protected override void OnSpawnerTick(float deltaTime)
        {
            if (ServerAPI.World.ElapsedMilliseconds - TimeSinceSpawn > NextSpawn)
            {
                if (ServerAPI.World.AllOnlinePlayers.Length > 0)
                {
                    ServerAPI.World.SpawnEntity(GenerateEntity());
                }

                NextSpawn = SpawnerRand.Next(MinSpawnTime, MaxSpawnTime) + SpawnerRand.NextDouble();
                NextSpawn = MeteoricExpansionHelpers.ConvertMinutesToMilliseconds(NextSpawn);

                TimeSinceSpawn = this.ServerAPI.World.ElapsedMilliseconds;
            }
        }
Ejemplo n.º 4
0
        protected override void Initialize(ICoreServerAPI sApi)
        {
            ConfigDisableFallingMeteors = sApi.World.Config.GetBool("DisableFallingMeteors");

            if (ConfigDisableFallingMeteors == false)
            {
                base.Initialize(sApi);

                EntityTypeToSpawn = typeof(EntityFallingMeteor);

                SpawnTickListener = ServerAPI.Event.RegisterGameTickListener(OnSpawnerTick, SPAWNER_TICK_INTERVAL);

                MinSpawnTime = ServerAPI.World.Config.GetInt("MinimumMinutesBetweenMeteorSpawns");
                MaxSpawnTime = ServerAPI.World.Config.GetInt("MaximumMinutesBetweenMeteorSpawns");

                MinSpawnDistance = ServerAPI.World.Config.GetInt("MinimumSpawnDistanceInChunks");
                MaxSpawnDistance = ServerAPI.World.Config.GetInt("MaximumSpawnDistanceInChunks");

                NextSpawn = SpawnerRand.Next(MinSpawnTime, MaxSpawnTime) + SpawnerRand.NextDouble();
                NextSpawn = MeteoricExpansionHelpers.ConvertMinutesToMilliseconds(NextSpawn);

                MeteoricExpansionHelpers.InitializeHelpers(ServerAPI.World.Seed);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Offsets meteor spawn position so that it does not spawn directly above the player. Be sure to set the MinSpawnDistance and MaxSpawnDistance before calling the base method.
        /// </summary>
        /// <returns></returns>
        protected virtual double GetSpawnOffset()
        {
            int    negativeRand = SpawnerRand.Next(0, 2);
            double spawnOffset  = SpawnerRand.Next(ServerAPI.WorldManager.ChunkSize * MinSpawnDistance, ServerAPI.WorldManager.ChunkSize * MaxSpawnDistance) + SpawnerRand.NextDouble();

            if (negativeRand == 0)
            {
                return(-spawnOffset);
            }

            return(spawnOffset);
        }