58 lines
2.3 KiB
C#
58 lines
2.3 KiB
C#
using ServerCommon;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ServerCore; using ServerBase;
|
|
|
|
namespace GameServer
|
|
{
|
|
internal static class LocationHelper
|
|
{
|
|
public static string getCurrentInstanceRoomId(this Player player)
|
|
{
|
|
var location_attribute = player.getOriginEntityAttribute<LocationAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(location_attribute, () => $"location_attribute is null !!! - {player.toBasicString()}");
|
|
|
|
return location_attribute.CurrentIndunLocation.InstanceRoomId;
|
|
}
|
|
|
|
public static UserLocationInfo getUserLocationInfo(this Player player)
|
|
{
|
|
var location_action = player.getEntityAction<LocationAction>();
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
|
|
var is_channel = server_logic.getServerType().toServerType() == ServerType.Channel ? 1 : 0;
|
|
var channel_no = (is_channel == 1) ? (int)server_logic.getChannelNo() : 0;
|
|
|
|
var location_info = new UserLocationInfo
|
|
{
|
|
Id = location_action.getCurrentMapMId(),
|
|
ChannelNumber = channel_no,
|
|
IsChannel = is_channel
|
|
};
|
|
return location_info;
|
|
}
|
|
|
|
public static PositionInfo getCurrentPositionInfo(this Player player)
|
|
{
|
|
var position_info = new PositionInfo();
|
|
|
|
var game_zone_action = player.getEntityAction<GameZoneAction>();
|
|
NullReferenceCheckHelper.throwIfNull(game_zone_action, () => $"game_zone_action is null !!! - {player.toBasicString()}");
|
|
|
|
var location_action = player.getEntityAction<LocationAction>();
|
|
NullReferenceCheckHelper.throwIfNull(location_action, () => $"location_action is null !!! - {player.toBasicString()}");
|
|
|
|
position_info.ServerName = GameServerApp.getServerLogic().getServerName();
|
|
position_info.MapFileType = game_zone_action.getLinkedToMap()?.MapFileType ?? MapFileType.None;
|
|
position_info.MapMid = location_action.getCurrentMapMId();
|
|
position_info.RoomId = game_zone_action.getLinkedToMap()?.m_room_id ?? "";
|
|
position_info.Pos = location_action.getCurrentPos();
|
|
|
|
return position_info;
|
|
}
|
|
}
|
|
}
|