// try reset land claim decay timer private static async void ServerTimerTickCallback() { if (isUpdatingNow) { Logger.Warning( "Cannot process land claim reset decay system tick - not finished the previous update yet"); return; } if (!StructureConstants.IsStructuresDecayEnabled) { return; } // We will time-slice this update just in case there are too many areas. isUpdatingNow = true; TempList.AddRange(Server.World.GetGameObjectsOfProto <ILogicObject, LandClaimAreasGroup>()); await ServerCore.AwaitEndOfFrame; try { foreach (var areasGroup in TempList) { ServerRefreshLandClaimAreasGroup(areasGroup); await ServerCore.YieldIfOutOfTime(); } } finally { isUpdatingNow = false; TempList.Clear(); } }
// refresh structures decay private async void ServerTimerTickCallback() { if (isUpdatingNow) { Logger.Warning("Cannot process structure decay system tick - not finished the previous update yet"); return; } if (!StructureConstants.IsStructureDecayEnabledInEditor && Api.IsEditor) { return; } // It's prohibitively expensive to iterate over all the server world objects at a single time // so we will time-slice this update by gathering all the static world objects first // and then iterating over them with YieldIfOutTime(). var serverTime = ServerGame.FrameTime; isUpdatingNow = true; try { // TODO: this call might be too expensive if there are many built structures in the world TempList.AddRange(Server.World.FindStaticWorldObjectsOfProto <IProtoObjectStructure>()); var objectsDecayedCount = 0; foreach (var worldObject in TempList) { if (ServerProcessDecay(worldObject, serverTime)) { objectsDecayedCount++; await ServerCore.YieldIfOutOfTime(); } } var timeSpent = ServerGame.FrameTime - serverTime; Logger.Info( string.Format( "World decay updated. Total static world objects count: {0}. Decaying objects count: {1}. Total time spent (including time-slicing): {2:F2}s", TempList.Count, objectsDecayedCount, timeSpent)); } finally { isUpdatingNow = false; TempList.Clear(); } }
// refresh structures decay private async void ServerTimerTickCallback() { if (isUpdatingNow) { Logger.Warning( "Cannot process land claim reset decay system tick - not finished the previous update yet"); return; } if (!StructureConstants.IsStructureDecayEnabledInEditor && Api.IsEditor) { return; } // We will time-slice this update just in case there are too many areas. isUpdatingNow = true; try { TempList.AddRange(LandClaimSystem.ServerEnumerateAllAreas()); foreach (var area in TempList) { var worldObject = LandClaimArea.GetPrivateState(area) .ServerLandClaimWorldObject; ServerRefreshLandClaimObject(worldObject); await ServerCore.YieldIfOutOfTime(); } } finally { isUpdatingNow = false; TempList.Clear(); } }