Files
caliverse_server/GameServer/Contents/OwnedBuilding/Helper/OwnedBuildingNotifyHelper.cs
2025-05-01 07:20:41 +09:00

55 lines
2.3 KiB
C#

using ServerCommon;
using ServerCore; using ServerBase;
using static ClientToGameMessage.Types;
namespace GameServer
{
internal static class OwnedBuildingNotifyHelper
{
public static bool send_S2C_NTF_OWNED_BUILDING_INFOS(this Player player)
{
var owned_building_agent_action = player.getEntityAction<OwnedBuildingAgentAction>();
ArgumentNullException.ThrowIfNull(owned_building_agent_action, $"building_agent_action is null !!!");
var ntf_packet = new ClientToGame();
ntf_packet.Message = new ClientToGameMessage();
ntf_packet.Message.NtfOwnedBuildingInfos = new GS2C_NTF_OWNED_BUILDING_INFOS();
var owned_buildings = owned_building_agent_action.getOwnedBuildings();
foreach (var owned_building in owned_buildings)
{
var owned_building_attribute = owned_building.getEntityAttribute<OwnedBuildingAttribute>();
NullReferenceCheckHelper.throwIfNull(owned_building_attribute, () => $"owned_building_attribute is null !!! - {player.toBasicString()}");
ntf_packet.Message.NtfOwnedBuildingInfos.OwnedBuildingInfos.Add((int)owned_building_attribute.BuildingMetaId);
}
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
{
return false;
}
return true;
}
public static bool send_S2C_NTF_OWNED_BUILDING_INFOS(this Player player, OwnedBuilding ownedBuilding)
{
var owned_building_attribute = ownedBuilding.getEntityAttribute<OwnedBuildingAttribute>();
NullReferenceCheckHelper.throwIfNull(owned_building_attribute, () => $"owned_building_attribute is null !!! - {player.toBasicString()}");
var ntf_packet = new ClientToGame();
ntf_packet.Message = new ClientToGameMessage();
ntf_packet.Message.NtfOwnedBuildingInfos = new GS2C_NTF_OWNED_BUILDING_INFOS();
ntf_packet.Message.NtfOwnedBuildingInfos.OwnedBuildingInfos.Add((int)owned_building_attribute.BuildingMetaId);
if (false == GameServerApp.getServerLogic().onSendPacket(player, ntf_packet))
{
return false;
}
return true;
}
}
}