Beispiel #1
0
            public override void ServerUpdateConfiguration()
            {
                if (this.nextTriggerTime > Server.Game.FrameTime)
                {
                    return;
                }

                var fromSeconds = this.intervalFromSeconds;
                var toSeconds   = this.intervalToSeconds;

                if (this.adjustRateToPlayersNumber)
                {
                    fromSeconds = ServerSpawnRateScaleHelper.AdjustDurationByRate(fromSeconds);
                    toSeconds   = ServerSpawnRateScaleHelper.AdjustDurationByRate(toSeconds);
                }

                this.nextTriggerTime = Server.Game.FrameTime + fromSeconds;

                // add random interval (if necessary)
                var deltaInterval = toSeconds - fromSeconds;

                if (deltaInterval >= float.Epsilon)
                {
                    this.nextTriggerTime += deltaInterval * RandomHelper.NextDouble();
                }

                this.ServerInvokeTrigger();
            }
Beispiel #2
0
        private void ServerResetHarvestGrownState(IStaticWorldObject worldObject)
        {
            var publicState  = GetPublicState(worldObject);
            var privateState = GetPrivateState(worldObject);

            publicState.HasHarvest = false;
            privateState.ServerTimeProduceHarvest = Server.Game.FrameTime
                                                    + ServerSpawnRateScaleHelper.AdjustDurationByRate(
                this.TimeToGiveHarvestTotalSeconds);
        }
        protected override int SharedCalculatePresetDesiredCount(
            ObjectSpawnPreset preset,
            IServerZone zone,
            int currentCount,
            int desiredCountByDensity)
        {
            // respawn no more than 66% of pragmium source objects per iteration
            // but scale automatically with the number of players online
            var spawnMaxPerIteration = (int)Math.Ceiling(desiredCountByDensity
                                                         * 0.66
                                                         * ServerSpawnRateScaleHelper.CalculateCurrentRate());

            return(Math.Min(currentCount + spawnMaxPerIteration,
                            desiredCountByDensity));
        }
Beispiel #4
0
        protected virtual double ServerCalculateGrowthStageDuration(
            byte growthStage,
            TPrivateState privateState,
            TPublicState publicState)
        {
            var objectVegetation = privateState.GameObject;
            var duration         = this.cachedGrowthStageDurationSeconds;

            if (LandClaimSystem.SharedIsObjectInsideAnyArea((IStaticWorldObject)objectVegetation))
            {
                // don't apply scaled rate to vegetation located inside the land claim areas
                // (as these are usually planted by players inside their bases and protected)
                return(duration);
            }

            return(ServerSpawnRateScaleHelper.AdjustDurationByRate(duration));
        }
Beispiel #5
0
        protected override int SharedCalculatePresetDesiredCount(
            ObjectSpawnPreset preset,
            IServerZone zone,
            int currentCount,
            int desiredCountByDensity)
        {
            desiredCountByDensity = (int)Math.Round(desiredCountByDensity * this.spawnRateMultiplier,
                                                    MidpointRounding.AwayFromZero);

            // respawn no more than 66% of brood nests per iteration
            // but scale automatically with the number of players online
            var spawnMaxPerIteration = (int)Math.Ceiling(desiredCountByDensity
                                                         * 0.66
                                                         * ServerSpawnRateScaleHelper.CalculateCurrentRate());

            return(Math.Min(currentCount + spawnMaxPerIteration,
                            desiredCountByDensity));
        }