166 lines
6.0 KiB
C#
166 lines
6.0 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 UserItem : Item
|
|
{
|
|
public UserItem(Player player)
|
|
: base(player)
|
|
{
|
|
|
|
}
|
|
|
|
public override async Task<Result> onInit()
|
|
{
|
|
var direct_parent = getDirectParent();
|
|
NullReferenceCheckHelper.throwIfNull(direct_parent, () => $"direct_parent is null !!!");
|
|
|
|
addEntityAttribute(new UserItemAttribute(this, direct_parent));
|
|
|
|
addEntityAction(new UserItemAction(this));
|
|
addEntityAction(new ItemUseAction(this));
|
|
|
|
|
|
|
|
|
|
|
|
return await base.onInit();
|
|
}
|
|
|
|
public override TAction getEntityAction<TAction>()
|
|
{
|
|
var parent = getRootParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
|
|
TAction? to_cast_entity_atcion;
|
|
|
|
if (typeof(TAction) == typeof(ItemAction))
|
|
{
|
|
to_cast_entity_atcion = base.getEntityAction<UserItemAction>() as TAction;
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_atcion, () => $"to_cast_entity_atcion is null !!!");
|
|
|
|
return to_cast_entity_atcion;
|
|
}
|
|
|
|
to_cast_entity_atcion = base.getEntityAction<TAction>();
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_atcion, () => $"to_cast_entity_atcion is null !!!");
|
|
|
|
return to_cast_entity_atcion;
|
|
}
|
|
|
|
public override TAttribute getOriginEntityAttribute<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
|
|
TAttribute? to_cast_entity_attribute;
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
to_cast_entity_attribute = base.getOriginEntityAttribute<UserItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
to_cast_entity_attribute = base.getOriginEntityAttribute<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
public override TAttribute getEntityAttributeWithReadOnly<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
|
|
TAttribute? to_cast_entity_attribute;
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
to_cast_entity_attribute = base.getEntityAttributeWithReadOnly<UserItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
to_cast_entity_attribute = base.getEntityAttributeWithReadOnly<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
public override TAttribute getEntityAttributeWithCloneOnly<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
|
|
TAttribute? to_cast_entity_attribute;
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
to_cast_entity_attribute = base.getEntityAttributeWithCloneOnly<UserItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
to_cast_entity_attribute = base.getEntityAttributeWithCloneOnly<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
public override TAttribute getClonedEntityAttribute<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
|
|
TAttribute? to_cast_entity_attribute;
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
to_cast_entity_attribute = base.getClonedEntityAttribute<UserItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
to_cast_entity_attribute = base.getClonedEntityAttribute<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
public override TAttribute getEntityAttribute<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
|
|
TAttribute? to_cast_entity_attribute;
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
to_cast_entity_attribute = base.getEntityAttribute<UserItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
|
|
to_cast_entity_attribute = base.getEntityAttribute<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(to_cast_entity_attribute, () => $"to_cast_entity_attribute is null !!!");
|
|
|
|
return to_cast_entity_attribute;
|
|
}
|
|
}
|
|
}
|