96 lines
3.2 KiB
C#
96 lines
3.2 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
|
|
{
|
|
internal class SocialActionAction : EntityActionBase
|
|
{
|
|
public SocialActionAction(SocialAction owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
public override async Task<Result> onInit()
|
|
{
|
|
await Task.CompletedTask;
|
|
|
|
var result = new Result();
|
|
|
|
return result;
|
|
}
|
|
|
|
public override void onClear()
|
|
{
|
|
return;
|
|
}
|
|
|
|
public Result tryEquipSocialAction(UInt16 equipPos)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var owner = getOwner();
|
|
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
|
var parent = owner.getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!! - {parent.toBasicString()}");
|
|
|
|
if (equipPos > ServerCommon.Constant.MAX_SOCIAL_ACTION_SLOT)
|
|
{
|
|
err_msg = $"Out of Range SocailActionSlot !!! : socialActionSlot:{equipPos} - {parent.toBasicString()}";
|
|
result.setFail(ServerErrorCode.SocialActionSlotOutOfRange, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
|
|
return result;
|
|
}
|
|
|
|
var users_social_action_attribute = getOwner().getEntityAttribute<UserSocialActionAttribute>();
|
|
ArgumentNullException.ThrowIfNull(users_social_action_attribute, $"users_social_action_attribute is null !!! - {parent.toBasicString()}");
|
|
|
|
users_social_action_attribute.EquipedPos = equipPos;
|
|
users_social_action_attribute.modifiedEntityAttribute();
|
|
|
|
return result;
|
|
}
|
|
|
|
public void unequipSocialAction()
|
|
{
|
|
var owner = getOwner();
|
|
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
|
var parent = owner.getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!! - {parent.toBasicString()}");
|
|
|
|
var users_social_action_attribute = owner.getEntityAttribute<UserSocialActionAttribute>();
|
|
ArgumentNullException.ThrowIfNull(users_social_action_attribute, $"users_social_action_attribute is null !!! - {parent.toBasicString()}");
|
|
|
|
users_social_action_attribute.EquipedPos = 0;
|
|
users_social_action_attribute.modifiedEntityAttribute();
|
|
}
|
|
|
|
public bool isSocialActionOnSlot()
|
|
{
|
|
var owner = getOwner();
|
|
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
|
var parent = owner.getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!! - {parent.toBasicString()}");
|
|
|
|
var users_social_action_attribute = owner.getEntityAttribute<UserSocialActionAttribute>();
|
|
ArgumentNullException.ThrowIfNull(users_social_action_attribute, $"users_social_action_attribute is null !!! - {parent.toBasicString()}");
|
|
|
|
if (users_social_action_attribute.EquipedPos == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|