protected override void OnDestroy() { // Save immediately #if UNITY_STANDALONE && !CLIENT_BUILD if (IsServer) { foreach (BasePlayerCharacterEntity playerCharacter in ServerUserHandlers.GetPlayerCharacters()) { if (playerCharacter == null) { continue; } DbServiceClient.UpdateCharacter(new UpdateCharacterReq() { CharacterData = playerCharacter.CloneTo(new PlayerCharacterData()).ToByteString() }); } string mapName = CurrentMapInfo.Id; foreach (BuildingEntity buildingEntity in ServerBuildingHandlers.GetBuildings()) { if (buildingEntity == null) { continue; } DbServiceClient.UpdateBuilding(new UpdateBuildingReq() { MapName = mapName, BuildingData = buildingEntity.CloneTo(new BuildingSaveData()).ToByteString() }); } } #endif base.OnDestroy(); }