134 lines
5.0 KiB
C#
134 lines
5.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 MyhomeItem : Item
|
|
{
|
|
public MyhomeItem(Myhome owner)
|
|
: base(owner)
|
|
{ }
|
|
|
|
public override async Task<Result> onInit()
|
|
{
|
|
var parent = getDirectParent();
|
|
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
|
addEntityAttribute(new MyhomeItemAttribute(this, parent));
|
|
|
|
addEntityAction(new MyhomeItemAction(this));
|
|
|
|
return await base.onInit();
|
|
}
|
|
|
|
public override TAction getEntityAction<TAction>()
|
|
{
|
|
var parent = getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
|
|
|
if (typeof(TAction) == typeof(ItemAction))
|
|
{
|
|
var item_action = base.getEntityAction<MyhomeItemAction>() as TAction;
|
|
NullReferenceCheckHelper.throwIfNull(item_action, () => $"item_action is null !!!");
|
|
return item_action;
|
|
}
|
|
|
|
var action = base.getEntityAction<TAction>();
|
|
NullReferenceCheckHelper.throwIfNull(action, () => $"action is null !!!");
|
|
return action;
|
|
}
|
|
|
|
public override TAttribute getOriginEntityAttribute<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
var item_attrib = base.getOriginEntityAttribute<MyhomeItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!");
|
|
return item_attrib;
|
|
}
|
|
|
|
var attrib = base.getOriginEntityAttribute<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
|
|
return attrib;
|
|
}
|
|
|
|
public override TAttribute getEntityAttributeWithReadOnly<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
var item_attrib = base.getEntityAttributeWithReadOnly<MyhomeItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!");
|
|
return item_attrib;
|
|
}
|
|
|
|
var attrib = base.getEntityAttributeWithReadOnly<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
|
|
return attrib;
|
|
}
|
|
|
|
public override TAttribute getEntityAttributeWithCloneOnly<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
var item_attrib = base.getEntityAttributeWithCloneOnly<MyhomeItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!");
|
|
return item_attrib;
|
|
}
|
|
|
|
var attrib = base.getEntityAttributeWithCloneOnly<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
|
|
return attrib;
|
|
}
|
|
|
|
public override TAttribute getClonedEntityAttribute<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
var item_attrib = base.getClonedEntityAttribute<MyhomeItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!");
|
|
return item_attrib;
|
|
}
|
|
|
|
var attrib = base.getClonedEntityAttribute<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
|
|
return attrib;
|
|
}
|
|
|
|
public override TAttribute getEntityAttribute<TAttribute>()
|
|
{
|
|
var parent = getRootParent();
|
|
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
|
|
|
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
|
{
|
|
var item_attrib = base.getEntityAttribute<MyhomeItemAttribute>() as TAttribute;
|
|
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!");
|
|
return item_attrib;
|
|
}
|
|
|
|
var attrib = base.getEntityAttribute<TAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!");
|
|
return attrib;
|
|
}
|
|
}
|
|
}
|