173 lines
6.6 KiB
C#
173 lines
6.6 KiB
C#
using ServerCommon;
|
|
using static ClientToGameRes.Types;
|
|
|
|
using USER_GUID = System.String;
|
|
using META_ID = System.UInt32;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using ServerCore; using ServerBase;
|
|
|
|
namespace GameServer
|
|
{
|
|
public static class BuffNotifyHelper
|
|
{
|
|
public static bool send_S2C_NTF_START_BUFF(Player player, BuffAttribute.BuffInfo? buffAttributeInfo)
|
|
{
|
|
if (buffAttributeInfo == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var noti_packet = makeNotiStartBuffPacket(buffAttributeInfo, player.getUserGuid());
|
|
|
|
var game_zone_action = player.getEntityAction<GameZoneAction>();
|
|
NullReferenceCheckHelper.throwIfNull(game_zone_action, () => $"game_zone_action is null !!!");
|
|
|
|
game_zone_action.broadcast(player, noti_packet);
|
|
|
|
QuestManager.It.QuestCheck(player, new QuestBuff(EQuestEventTargetType.BUFF, EQuestEventNameType.USED, (int)buffAttributeInfo.BuffMetaID)).Wait();
|
|
return true;
|
|
}
|
|
|
|
public static ClientToGame makeAckStartBuffPacket()
|
|
{
|
|
var ack_packet = new ClientToGame();
|
|
ack_packet.Response = new ClientToGameRes();
|
|
ack_packet.Response.ErrorCode = ServerErrorCode.Success;
|
|
ack_packet.Response.StartBuffRes = new StartBuffRes();
|
|
|
|
return ack_packet;
|
|
}
|
|
|
|
public static ClientToGame makeNotiStartBuffPacket(BuffAttribute.BuffInfo buffAttributeInfo, USER_GUID user_Guid)
|
|
{
|
|
var noti_packet = new ClientToGame();
|
|
noti_packet.Message = new();
|
|
noti_packet.Message.StartBuffNoti = new();
|
|
noti_packet.Message.StartBuffNoti.ActorGuid = user_Guid;
|
|
noti_packet.Message.StartBuffNoti.Buf = new();
|
|
noti_packet.Message.StartBuffNoti.Buf.BuffId = (int)buffAttributeInfo.BuffMetaID;
|
|
noti_packet.Message.StartBuffNoti.Buf.BuffStartTime = buffAttributeInfo.BuffStartTime.ToTimestamp();
|
|
|
|
return noti_packet;
|
|
}
|
|
|
|
//이 패킷으로 stop모두 처리해도 되지 않을까
|
|
public static bool send_S2C_NTF_DELETE_BUFF(Player player, BuffAttribute.BuffInfo? buffAttributeInfo)
|
|
{
|
|
if(buffAttributeInfo == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var noti_packet = makeNotiDeleteBuffPacket(buffAttributeInfo, player.getUserGuid());
|
|
|
|
var game_zone_action = player.getEntityAction<GameZoneAction>();
|
|
NullReferenceCheckHelper.throwIfNull(game_zone_action, () => $"game_zone_action is null !!!");
|
|
|
|
game_zone_action.broadcast(player, noti_packet);
|
|
|
|
return true;
|
|
}
|
|
|
|
public static ClientToGame makeAckDeleteBuffPacket()
|
|
{
|
|
var ack_packet = new ClientToGame();
|
|
ack_packet.Response = new ClientToGameRes();
|
|
ack_packet.Response.ErrorCode = ServerErrorCode.Success;
|
|
ack_packet.Response.StopBuffRes = new StopBuffRes();
|
|
|
|
return ack_packet;
|
|
}
|
|
|
|
public static ClientToGame makeNotiDeleteBuffPacket(BuffAttribute.BuffInfo buffInfo, USER_GUID user_Guid)
|
|
{
|
|
var noti_packet = new ClientToGame();
|
|
noti_packet.Message = new();
|
|
noti_packet.Message.StopBuffNoti = new();
|
|
|
|
noti_packet.Message.StopBuffNoti.ActorGuid = user_Guid;
|
|
|
|
noti_packet.Message.StopBuffNoti.Buf = new();
|
|
noti_packet.Message.StopBuffNoti.Buf.BuffId = (int)buffInfo.BuffMetaID;
|
|
noti_packet.Message.StopBuffNoti.Buf.BuffStartTime = buffInfo.BuffStartTime.ToTimestamp();
|
|
|
|
return noti_packet;
|
|
}
|
|
|
|
|
|
public static bool send_S2C_NTF_DELETE_BUFF_LIST(Player player, List<BuffAttribute.BuffInfo>? buffAttributeInfo)
|
|
{
|
|
if (buffAttributeInfo == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var noti_packet = new ClientToGame();
|
|
noti_packet.Message = new ();
|
|
noti_packet.Message.DelBuffListNoti = new ();
|
|
|
|
foreach (var buff_attribute in buffAttributeInfo)
|
|
{
|
|
var buff_info = new Buff();
|
|
buff_info.BuffId = (int)buff_attribute.BuffMetaID;
|
|
buff_info.BuffStartTime = buff_attribute.BuffStartTime.ToTimestamp();
|
|
noti_packet.Message.DelBuffListNoti.DelBuffList.Add(buff_info);
|
|
}
|
|
|
|
if (false == GameServerApp.getServerLogic().onSendPacket(player, noti_packet))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public static bool send_S2C_NTF_USE_EQUIPED_BUFF(Player player, USER_GUID user_guid, META_ID buff_meta_id, int client_buff_step, int client_buff_random_state, Int64 client_buff_action_start_time)
|
|
{
|
|
var noti_packet = new ClientToGame();
|
|
noti_packet.Message = new();
|
|
noti_packet.Message.UseEquipedBuffNoti = new();
|
|
|
|
noti_packet.Message.UseEquipedBuffNoti.ActorGuid = user_guid;
|
|
noti_packet.Message.UseEquipedBuffNoti.EquipedBuffId = (int)buff_meta_id;
|
|
noti_packet.Message.UseEquipedBuffNoti.EquipedBuffStep = client_buff_step;
|
|
noti_packet.Message.UseEquipedBuffNoti.EquipedBuffRandomState = client_buff_random_state;
|
|
noti_packet.Message.UseEquipedBuffNoti.ActionStartTime = client_buff_action_start_time;
|
|
|
|
if (false == GameServerApp.getServerLogic().onSendPacket(player, noti_packet))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var game_zone_action = player.getEntityAction<GameZoneAction>();
|
|
NullReferenceCheckHelper.throwIfNull(game_zone_action, () => $"game_zone_action is null !!!");
|
|
|
|
game_zone_action.broadcast(player, noti_packet);
|
|
|
|
return true;
|
|
}
|
|
|
|
public static bool send_S2C_NTF_LOGIN_BUFF(this Player player)
|
|
{
|
|
var buffAttribute = player.getEntityAttribute<BuffAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(buffAttribute, () => $"buffAttribute is null !!!");
|
|
|
|
var noti_packet = new ClientToGame();
|
|
noti_packet.Message = new();
|
|
noti_packet.Message.LoginBuffNoti = new();
|
|
noti_packet.Message.LoginBuffNoti.BuffInfo = new();
|
|
if(buffAttribute != null)
|
|
{
|
|
noti_packet.Message.LoginBuffNoti.BuffInfo.Buff.AddRange(buffAttribute.toBuffData4Client());
|
|
}
|
|
|
|
if (false == GameServerApp.getServerLogic().onSendPacket(player, noti_packet))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|