protected sealed override void PrepareProto() { var effects = new Effects(); this.PrepareEffects(effects); this.ProtoEffects = effects.ToReadOnly(); this.PrepareProtoStatusEffect(); if (this.IntensityAutoDecreasePerSecondFraction < 0 || this.IntensityAutoDecreasePerSecondFraction > 1) { throw new Exception( $"Invalid value of the property {nameof(this.IntensityAutoDecreasePerSecondFraction)}: it must be in [0;1] range"); } this.isAutoDecrease = this.IntensityAutoDecreasePerSecondValue > 0 || this.IntensityAutoDecreasePerSecondFraction > 0; if (IsServer && this.GetType().HasOverride(nameof(this.ServerOnAutoAdd), isPublic: false)) { TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(this.ServerAutoAddRepeatIntervalSeconds), callback: this.ServerAutoAddTimerCallback, name: "StatusEffect.AutoAddCallback." + this.ShortId); } this.HasStatEffects = !this.ProtoEffects.IsEmpty; }
protected override void PrepareSystem() { if (IsClient) { return; } if (PveSystem.ServerIsPvE) { // there is no need for faction karma system on PvE servers return; } if (!Server.Database.TryGet(nameof(FactionLeaderboardSystem), DatabaseKeyLastUpdateTime, out serverLastUpdateTime)) { serverLastUpdateTime = Server.Game.FrameTime; Server.Database.Set(nameof(FactionLeaderboardSystem), DatabaseKeyLastUpdateTime, serverLastUpdateTime); } FactionSystem.ServerCharacterJoinedOrLeftFaction += ServerCharacterJoinedOrLeftFactionHandler; ServerCharacterDeathMechanic.CharacterDeath += ServerCharacterDeathHandler; TriggerTimeInterval.ServerConfigureAndRegister( TimeSpan.FromSeconds(1), ServerUpdate, "System." + this.ShortId); }
protected override void PrepareProtoSkill(SkillConfig config) { byte maxLevel = 20; config.Category = GetCategory <SkillCategoryPersonal>(); config.MaxLevel = maxLevel; var stats = new[] { HealthMax, StaminaMax, FoodMax, WaterMax }; foreach (var statName in stats) { config.AddStatEffect( statName, formulaPercentBonus: level => level); config.AddStatEffect( statName, level: maxLevel, percentBonus: 5); } if (IsServer) { TriggerTimeInterval.ServerConfigureAndRegister( TimeSpan.FromSeconds(TimerIntervalSeconds), this.ServerTimerTick, "Skill.SurvivalAddExperience"); } }
public override void ServerInitialize(IServerConfiguration serverConfiguration) { // doesn't work here as FindGameObjectsOfProto is not available during bootstrap //var allParties = Server.World.FindGameObjectsOfProto<ILogicObject, Party>(); //foreach (var party in allParties) //{ // ServerRegisterParty(party); //} TriggerTimeInterval.ServerConfigureAndRegister(TimeSpan.FromSeconds(1), ServerInvitations.UpdateInvitationsExpiration, "Party invitations expiration updater"); }
protected override void PrepareSystem() { if (IsClient) { // only server will update food and water values return; } // configure time interval trigger TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(1), callback: this.ServerTimerTickCallback, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient) { // only server will update structure decay return; } // configure time interval trigger TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(StructureConstants.StructureDecaySystemUpdateIntervalSeconds), callback: this.ServerTimerTickCallback, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsServer) { // configure time interval trigger TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(CheckTimeIntervalSeconds), callback: this.TimerTickCallback, name: "System." + this.ShortId); } else // if (IsClient) { ClientTimersSystem.AddAction(CheckTimeIntervalSeconds, this.TimerTickCallback); } }
protected override void PrepareSystem() { if (IsClient) { ClientRefreshCurrentUnstuckRequestStatus(); } else { // configure server time interval trigger TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(1), callback: this.ServerTimerTickCallback, name: "System." + this.ShortId); } }
protected sealed override void PrepareProto() { var effects = new Effects(); this.PrepareEffects(effects); this.ProtoEffects = effects.ToReadOnly(); this.PrepareProtoStatusEffect(); this.isAutoDecrease = this.IntensityAutoDecreasePerSecondValue > 0; if (this.IntensityAutoDecreasePerSecondValue <= 0 && ((this.DisplayMode & StatusEffectDisplayMode.IconShowTimeRemains) != 0 || (this.DisplayMode & StatusEffectDisplayMode.TooltipShowTimeRemains) != 0)) { throw new Exception( string.Format( "{0} has {1} or {2} but its {3} is <= 0 so it's not possible to calculate how much time remains", this.ShortId, nameof(StatusEffectDisplayMode.IconShowTimeRemains), nameof(StatusEffectDisplayMode.TooltipShowTimeRemains), nameof(this.IntensityAutoDecreasePerSecondValue))); } this.HasStatEffects = !this.ProtoEffects.IsEmpty; if ((this.DisplayMode & StatusEffectDisplayMode.IconShowIntensityPercent) != 0 && (this.DisplayMode & StatusEffectDisplayMode.IconShowTimeRemains) != 0) { throw new Exception( string.Format("{0} has both {1} and {2} in its {3}", this.ShortId, nameof(StatusEffectDisplayMode.IconShowIntensityPercent), nameof(StatusEffectDisplayMode.IconShowTimeRemains), nameof(this.DisplayMode))); } if (IsServer && this.GetType().HasOverride(nameof(this.ServerOnAutoAdd), isPublic: false)) { TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(this.ServerAutoAddRepeatIntervalSeconds), callback: this.ServerAutoAddTimerCallback, name: "StatusEffect.AutoAddCallback." + this.ShortId); } }
protected override void PrepareSystem() { if (IsClient) { return; } if (!PveSystem.ServerIsPvE) { return; } TriggerTimeInterval.ServerConfigureAndRegister( callback: ServerUpdate, name: "System." + this.ShortId, interval: TimeSpan.FromSeconds(10)); }
protected override void PrepareSystem() { if (IsClient || PveSystem.ServerIsPvE) { return; } LandClaimSystem.ServerRaidBlockStartedOrExtended += ServerRaidBlockStartedOrExtendedHandler; Server.Characters.PlayerOnlineStateChanged += ServerPlayerOnlineStateChangedHandler; TriggerTimeInterval.ServerConfigureAndRegister( TimeSpan.FromSeconds(1), ServerUpdate, "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient) { return; } if (!PveSystem.ServerIsPvE) { return; } Server.Characters.PlayerOnlineStateChanged += this.ServerPlayerOnlineStateChangedHandler; TriggerTimeInterval.ServerConfigureAndRegister( callback: ServerUpdate, name: "System." + this.ShortId, interval: TimeSpan.FromSeconds(10)); }
protected override void PrepareSystem() { if (IsClient) { return; } serverMetrics = Api.FindProtoEntities <ProtoFactionScoreMetric>() .ToArray(); foreach (var metric in serverMetrics) { metric.ServerInitialize(); if (metric.PowerCoefficient <= 0 || metric.PowerCoefficient > 1) { Logger.Error("Incorrect value of " + nameof(ProtoFactionScoreMetric.PowerCoefficient) + " in " + metric.GetType().FullName + ": the power must be within (0;1] range"); } } if (!Server.Database.TryGet(nameof(FactionLeaderboardSystem), DatabaseKeyLastUpdateTime, out serverLastUpdateTime)) { serverLastUpdateTime = Server.Game.FrameTime; Server.Database.Set(nameof(FactionLeaderboardSystem), DatabaseKeyLastUpdateTime, serverLastUpdateTime); } TriggerTimeInterval.ServerConfigureAndRegister( TimeSpan.FromSeconds(1), ServerUpdate, "System." + this.ShortId); Server.Characters.PlayerOnlineStateChanged += this.ServerPlayerOnlineStateChangedHandler; }
protected override void PrepareSystem() { if (IsClient) { // only server will update food and water values return; } // ReSharper disable once ConditionIsAlwaysTrueOrFalse // ReSharper disable once RedundantLogicalConditionalExpressionOperand if (Api.IsEditor && !IsEnabledInEditor) { return; } // configure time interval trigger TriggerTimeInterval.ServerConfigureAndRegister( interval: TimeSpan.FromSeconds(TimeIntervalSeconds), callback: ServerTimerTickCallback, name: "System." + this.ShortId); }