초기커밋
This commit is contained in:
141
GameServer/Contents/Farming/PacketHandler/FarmingNotifyHelper.cs
Normal file
141
GameServer/Contents/Farming/PacketHandler/FarmingNotifyHelper.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using static ClientToGameMessage.Types;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using ANCHOR_META_GUID = System.String;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public static class FarmingNotifyHelper
|
||||
{
|
||||
public static void send_GS2C_NTF_FARMING_ALL_LOAD(this Player player)
|
||||
{
|
||||
var user_create_or_load_action = player.getEntityAction<UserCreateOrLoadAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_create_or_load_action, () => $"user_create_or_load_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var user_loader = user_create_or_load_action.getSimpleEventTriggerType<UserLoader>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_loader, () => $"user_loader is null !!! - {player.toBasicString()}");
|
||||
|
||||
var process_farming_summary_all = user_loader.getProgressFarmingSummaryAll();
|
||||
NullReferenceCheckHelper.throwIfNull(user_create_or_load_action, () => $"process_farming_summary_all is null !!! - {player.toBasicString()}");
|
||||
|
||||
var ntf = new GS2C_NTF_FARMING_ALL_LOAD();
|
||||
ntf.ProgressFarmingSummaries.AddRange(process_farming_summary_all);
|
||||
|
||||
ClientToGame packet = new ClientToGame();
|
||||
packet.Message = new ClientToGameMessage();
|
||||
packet.Message.NtfFarmingAllLoad = ntf;
|
||||
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
|
||||
public static void send_GS2C_NTF_FARMING_START(Player player, FarmingEffect farmingEffect)
|
||||
{
|
||||
var game_zone_action = player.getEntityAction<GameZoneAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(game_zone_action, () => $"game_zone_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var curr_map = game_zone_action.getLinkedToMap();
|
||||
NullReferenceCheckHelper.throwIfNull(curr_map, () => $"curr_map is null !!! - {player.toBasicString()}");
|
||||
|
||||
var faming_effect_action = farmingEffect.getEntityAction<FarmingEffectAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(faming_effect_action, () => $"faming_effect_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var anchor_info = faming_effect_action.getAnchorInfo();
|
||||
|
||||
var ntf = new GS2C_NTF_FARMING_START();
|
||||
ntf.FarmingAnchorMetaId = anchor_info.AnchorGuid;
|
||||
ntf.FarmingSummary = farmingEffect.toFarmingSummary();
|
||||
|
||||
ClientToGame packet = new ClientToGame();
|
||||
packet.Message = new ClientToGameMessage();
|
||||
packet.Message.NtfFarmingStart = ntf;
|
||||
|
||||
curr_map.Broadcast(anchor_info.AnchorPos, packet);
|
||||
}
|
||||
|
||||
public static void send_GS2C_NTF_FARMING_CANCEL(Player player, FarmingEffect farmingEffect)
|
||||
{
|
||||
var game_zone_action = player.getEntityAction<GameZoneAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(game_zone_action, () => $"game_zone_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var curr_map = game_zone_action.getLinkedToMap();
|
||||
NullReferenceCheckHelper.throwIfNull(curr_map, () => $"curr_map is null !!! - {player.toBasicString()}");
|
||||
|
||||
var faming_effect_action = farmingEffect.getEntityAction<FarmingEffectAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(faming_effect_action, () => $"faming_effect_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var anchor_info = faming_effect_action.getAnchorInfo();
|
||||
|
||||
var ntf = new GS2C_NTF_FARMING_CANCEL();
|
||||
ntf.FarmingAnchorMetaId = anchor_info.AnchorGuid;
|
||||
ntf.FarmingSummary = farmingEffect.toFarmingSummary();
|
||||
|
||||
ClientToGame packet = new ClientToGame();
|
||||
packet.Message = new ClientToGameMessage();
|
||||
packet.Message.NtfFarmingCancel = ntf;
|
||||
|
||||
curr_map.Broadcast(anchor_info.AnchorPos, packet, player.getHostId());
|
||||
}
|
||||
|
||||
public static void send_GS2C_NTF_FARMING_END(Map currMap, AnchorInfo anchorInfo, FarmingSummary farmingSummary)
|
||||
{
|
||||
var ntf = new GS2C_NTF_FARMING_END();
|
||||
ntf.FarmingAnchorMetaId = anchorInfo.AnchorGuid;
|
||||
ntf.FarmingSummary = farmingSummary;
|
||||
|
||||
ClientToGame packet = new ClientToGame();
|
||||
packet.Message = new ClientToGameMessage();
|
||||
packet.Message.NtfFarmingEnd = ntf;
|
||||
|
||||
currMap.Broadcast(anchorInfo.AnchorPos, packet);
|
||||
}
|
||||
|
||||
public static void send_GS2MQS_NTF_FARMING_END( GameServerLogic serverLogic
|
||||
, string targetServerName
|
||||
, USER_GUID userGuid
|
||||
, FarmingSummary farmingSummary
|
||||
, bool isApplyDb = true )
|
||||
{
|
||||
var mg_server = serverLogic.getRabbitMqConnector() as RabbitMQ4Game;
|
||||
NullReferenceCheckHelper.throwIfNull(mg_server, () => $"mg_server is null !!!");
|
||||
|
||||
var s2s_ntf_msg = new ServerMessage();
|
||||
var ntf_farming_end = new ServerMessage.Types.GS2MQS_NTF_FARMING_END();
|
||||
s2s_ntf_msg.NtfFarmingEnd = ntf_farming_end;
|
||||
|
||||
ntf_farming_end.UserGuid = userGuid;
|
||||
ntf_farming_end.FarmingSummary = farmingSummary;
|
||||
ntf_farming_end.IsApplyDb = isApplyDb == true ? BoolType.True : BoolType.False;
|
||||
|
||||
mg_server.SendMessage(targetServerName, s2s_ntf_msg);
|
||||
}
|
||||
|
||||
public static void send_GS2C_NTF_FARMING_END(Player player, FarmingSummary farmingSummary)
|
||||
{
|
||||
var ntf = new GS2C_NTF_FARMING_END();
|
||||
ntf.FarmingAnchorMetaId = farmingSummary.FarmingAnchorMetaId;
|
||||
ntf.FarmingSummary = farmingSummary;
|
||||
|
||||
ClientToGame packet = new ClientToGame();
|
||||
packet.Message = new ClientToGameMessage();
|
||||
packet.Message.NtfFarmingEnd = ntf;
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, packet))
|
||||
{
|
||||
Log.getLogger().error($"Failed to onSendPacket() !!! : {packet.toBasicString()} - {player.toBasicString()}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user