public override void ServerInitialize(IServerConfiguration serverConfiguration) { if (Api.IsEditor) { return; } var autosaveIntervalMinutes = Api.Server.Core.AutosaveIntervalMinutes; if (autosaveIntervalMinutes < AutosavegameIntervalMinutesMin || autosaveIntervalMinutes > AutosavegameIntervalMinutesMax) { throw new Exception( string.Format("Autosave interval should be in range from {0} to {1} (both inclusive)", AutosavegameIntervalMinutesMin, AutosavegameIntervalMinutesMax)); } Server.Core.AutosaveOnQuit = true; Api.Logger.Important($"Server auto-save enabled. Interval: {autosaveIntervalMinutes} minutes"); serverFramesBetweenAutoSaves = 60 * autosaveIntervalMinutes * ServerGame.FrameRate; SetNextAutoSaveFrameNumber(); // Randomize the next autosave date a bit (up to +60 seconds) // to ensure that if there are several game servers they will not save together // affecting performance of each other. serverNextAutoSaveFrameNumber = (uint)(serverNextAutoSaveFrameNumber + ServerGame.FrameRate * RandomHelper.Next(0, 61)); TriggerEveryFrame.ServerRegister(Instance.Update, "Autosave manager"); }
protected override void PrepareProtoStatusEffect() { base.PrepareProtoStatusEffect(); if (Api.IsClient) { return; } // cache the server zone prototype this.serverZone = this.ServerZoneProto; // cache the tile offsets // but select only every third tile (will help to reduce the load without damaging accuracy too much) this.serverTileOffsetsCircle = ShapeTileOffsetsHelper .GenerateOffsetsCircle(EnvironmentalRadiationLookupAreaDiameter) .ToArray(); this.serverTileOffsetsCircle = ShapeTileOffsetsHelper.SelectOffsetsWithRate( this.serverTileOffsetsCircle, rate: 3); // setup timer (tick every frame) TriggerEveryFrame.ServerRegister( callback: this.ServerGlobalUpdate, name: "System." + this.ShortId); }
public override void ServerInitialize(IServerConfiguration serverConfiguration) { if (Api.IsEditor) { return; } var autosaveIntervalMinutes = Api.Server.Core.AutosaveIntervalMinutes; if (autosaveIntervalMinutes < AutosavegameIntervalMinutesMin || autosaveIntervalMinutes > AutosavegameIntervalMinutesMax) { throw new Exception( string.Format("Autosave interval should be in range from {0} to {1} (both inclusive)", AutosavegameIntervalMinutesMin, AutosavegameIntervalMinutesMax)); } Server.Core.AutosaveOnQuit = true; Api.Logger.Important($"Server auto-save enabled. Interval: {autosaveIntervalMinutes} minutes"); framesBetweenAutoSaves = 60 * autosaveIntervalMinutes * ServerGame.FrameRate; SetNextAutoSaveFrameNumber(); TriggerEveryFrame.ServerRegister(Update, "Autosave manager"); }
protected override void PrepareSystem() { if (IsClient) { // only server will consume vehicle energy return; } TriggerEveryFrame.ServerRegister( callback: ServerUpdate, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient) { // only server will update health value return; } TriggerEveryFrame.ServerRegister( callback: ServerUpdate, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient || !RateStructuresDecayEnabled.SharedValue) { return; } // configure time interval trigger TriggerEveryFrame.ServerRegister( callback: ServerUpdate, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient) { BootstrapperClientGame.InitCallback += this.ClientInitCallback; return; } // configure time interval trigger TriggerEveryFrame.ServerRegister( callback: ServerGlobalUpdate, name: "System." + this.ShortId); }
protected override void PrepareProtoStatusEffect() { base.PrepareProtoStatusEffect(); if (Api.IsClient) { return; } // setup timer (tick every frame) TriggerEveryFrame.ServerRegister( callback: this.ServerGlobalUpdate, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient) { ClientInputContext.Start("Enter/Exit vehicle") .HandleButtonDown(GameButton.VehicleEnterExit, this.ClientOnVehicleEnterExitButtonPress); } else { TriggerEveryFrame.ServerRegister(ServerProcessVehicleQuitRequests, nameof(VehicleSystem)); } }
protected override void PrepareProtoStatusEffect() { instance = this; if (IsServer) { // setup timer (tick every frame) TriggerEveryFrame.ServerRegister( callback: ServerGlobalUpdate, name: "System." + this.ShortId); PlayerCharacterTechnologies.ServerCharacterGainedLearningPoints += this.ServerPlayerCharacterGainedLearningPointsHandler; } }
protected override void PrepareProtoStatusEffect() { instance = this; if (IsServer) { if (!SharedLocalServerHelper.IsLocalServer) { TriggerEveryFrame.ServerRegister( callback: ServerGlobalUpdate, name: "System." + this.ShortId); } PlayerCharacterTechnologies.ServerCharacterGainedLearningPoints += this.ServerPlayerCharacterGainedLearningPointsHandler; } }
protected override void PrepareSystem() { if (IsClient) { // only server will update structure decay return; } if (!StructureConstants.IsStructuresDecayEnabled) { return; } ServerDecayingProtoStructures = Api.FindProtoEntities <IProtoObjectStructure>().ToArray(); // configure time interval trigger TriggerEveryFrame.ServerRegister( callback: ServerUpdate, name: "System." + this.ShortId); }
protected override void PrepareProtoVehicle( InputItems buildRequiredItems, InputItems repairStageRequiredItems, out int repairStagesCount) { buildRequiredItems .Add <ItemKeinite>(120) .Add <ItemToxin>(120) .Add <ItemPragmiumHeart>(3) .Add <ItemTyrantHeart>(3) .Add <ItemVialBiomaterial>(50); repairStagesCount = 0; // this mech has health regeneration and cannot be repaired in any other way if (IsServer) { TriggerEveryFrame.ServerRegister( callback: this.ServerUpdateStructurePointsRegeneration, name: "System." + this.ShortId + ".ArmorRegeneration"); } }
protected override void PrepareSystem() { if (IsClient) { return; } ServerCharacterDeathMechanic.CharacterDeath += ServerCharacterDeathHandler; if (PveSystem.ServerIsPvE) { return; } TriggerEveryFrame.ServerRegister( callback: ServerRecoverPvpScore, name: "System." + this.ShortId); // print PvP leaderboard after the server initialization is over // (it will also enable printing it every hour) ServerTimersSystem.AddAction( delaySeconds: 1, ServerPrintPvpLeaderboardEveryHour); }
protected override void PrepareProtoStatusEffect() { base.PrepareProtoStatusEffect(); if (Api.IsClient) { return; } this.serverFrameOffset = (byte)this.Id.GetHashCode(); // cache the server zone prototype this.serverZone = this.ServerZoneProto; // cache the tile offsets this.serverTileOffsetsCircle = ShapeTileOffsetsHelper .GenerateOffsetsCircle(EnvironmentalRadiationLookupAreaDiameter) .ToArray(); // setup timer (tick every frame) TriggerEveryFrame.ServerRegister( callback: this.ServerGlobalUpdate, name: "System." + this.ShortId); }
protected override void PrepareSystem() { if (IsClient) { return; } if (!PveSystem.ServerIsPvE) { return; } if (SharedLocalServerHelper.IsLocalServer || Api.IsEditor) { // don't despawn offline players on the local server and in Editor return; } // setup timer (tick every frame) TriggerEveryFrame.ServerRegister( callback: ServerGlobalUpdate, name: "System." + this.ShortId); }
public override void ServerInitialize(IServerConfiguration serverConfiguration) { TriggerEveryFrame.ServerRegister(SharedProcessQueue, nameof(SharedWallConstructionRefreshHelper) + ".Process"); Server.World.WorldBoundsChanged += () => Queue.Clear(); }
public override void ServerInitialize(IServerConfiguration serverConfiguration) { TriggerEveryFrame.ServerRegister(ServerUpdateAllianceRequestsExpiration, $"{nameof(FactionSystem)}.{nameof(ServerUpdateAllianceRequestsExpiration)}"); }