80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
using ServerCommon;
|
|
using ServerCore; using ServerBase;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GameServer
|
|
{
|
|
internal class BuildingUpdateTicker : EntityTicker
|
|
{
|
|
public BuildingUpdateTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
|
|
: base(EntityType.BuildingUpdateTicker, onTickIntervalMilliseconds, cts)
|
|
{
|
|
}
|
|
|
|
public override async Task onTaskTick()
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
Stopwatch? stopwatch = null;
|
|
var event_tid = string.Empty;
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
var server_config = server_logic.getServerConfig();
|
|
|
|
if (true == server_config.PerformanceCheckEnable)
|
|
{
|
|
event_tid = System.Guid.NewGuid().ToString("N");
|
|
stopwatch = Stopwatch.StartNew();
|
|
}
|
|
|
|
var modify_floor_linked_infos = new List<ModifyFloorLinkedInfo>();
|
|
|
|
var building_manager = server_logic.getBuildingManager();
|
|
var rental_finish_building_floors = building_manager.checkRentalFinish();
|
|
foreach (var (land_meta_id, building_meta_id, floor) in rental_finish_building_floors)
|
|
{
|
|
result = building_manager.tryRemoveBuildingFloor(building_meta_id, floor);
|
|
if (result.isFail())
|
|
continue;
|
|
|
|
if (!MapManager.Instance.tryRemoveRoomMapTree(building_meta_id, floor, out var removed_room_map_tree))
|
|
continue;
|
|
|
|
var ugc_npc_guids = removed_room_map_tree.UgcNpcs;
|
|
if (ugc_npc_guids.Count < 1)
|
|
continue;
|
|
|
|
var modify_floor_linked_info = MapHelper.makeModifyFloorLinkedInfo(ModifyType.Delete, land_meta_id, building_meta_id, floor, ugc_npc_guids);
|
|
modify_floor_linked_infos.Add(modify_floor_linked_info);
|
|
}
|
|
|
|
MapNotifyHelper.broadcast_S2C_NTF_MODIFY_FLOOR_LINKED_INFOS(modify_floor_linked_infos);
|
|
|
|
if (null != stopwatch)
|
|
{
|
|
var elapsed_msec = stopwatch.ElapsedMilliseconds;
|
|
stopwatch.Stop();
|
|
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
|
|
}
|
|
|
|
await Task.CompletedTask;
|
|
}
|
|
|
|
public override string toBasicString()
|
|
{
|
|
return $"{this.getTypeName()}";
|
|
}
|
|
|
|
public override string toSummaryString()
|
|
{
|
|
return $"{this.getTypeName()}";
|
|
}
|
|
}
|
|
}
|