73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
using ServerCommon;
|
|
|
|
|
|
namespace GameServer
|
|
{
|
|
public class UserSocialActionExecutorAction : SocialActionLoadAction
|
|
{
|
|
private Int32 m_playing_social_action_meta_id = 0;
|
|
private DateTime m_playing_social_action_start_time = default;
|
|
|
|
public UserSocialActionExecutorAction(Player owner)
|
|
: base(owner)
|
|
{
|
|
|
|
}
|
|
public (Result, ClientToGameRes.Types.UseSocialActionRes) tryUseSocialAction(int socialActionMetaId)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var owner = getOwner();
|
|
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
|
|
|
var res = new ClientToGameRes.Types.UseSocialActionRes();
|
|
|
|
if (!tryGetSocialAction(socialActionMetaId, out var social_action))
|
|
{
|
|
err_msg = $"Failed to tryGetSocialAction() !!! : socialActionMetaId:{socialActionMetaId} : {this.getTypeName()} - {owner.toBasicString()}";
|
|
result.setFail(ServerErrorCode.SocialActionNotFound, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
|
|
return (result, res);
|
|
}
|
|
|
|
var social_action_action = social_action.getEntityAction<SocialActionAction>();
|
|
NullReferenceCheckHelper.throwIfNull(social_action_action, () => $"social_action_action is null !!! - {owner.toBasicString()}");
|
|
|
|
if (!social_action_action.isSocialActionOnSlot())
|
|
{
|
|
err_msg = $"SocialAction is not on slot !!! : {social_action.toBasicString()} : {this.getTypeName()} - {owner.toBasicString()}";
|
|
result.setFail(ServerErrorCode.SocialActionNotOnSlot, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
|
|
return (result, res);
|
|
}
|
|
|
|
m_playing_social_action_meta_id = socialActionMetaId;
|
|
m_playing_social_action_start_time = DateTime.UtcNow;
|
|
|
|
res.SocialActionId = m_playing_social_action_meta_id;
|
|
|
|
return (result, res);
|
|
}
|
|
|
|
public void stopSocialAction()
|
|
{
|
|
m_playing_social_action_meta_id = 0;
|
|
m_playing_social_action_start_time = default;
|
|
}
|
|
|
|
public int getPlayingSocialActionMetaId() => m_playing_social_action_meta_id;
|
|
public DateTime getPlayingSocialActionStartTime() => m_playing_social_action_start_time;
|
|
}
|
|
}
|