초기커밋
This commit is contained in:
133
GameServer/Entity/Item/Owner/Myhome/MyhomeItem.cs
Normal file
133
GameServer/Entity/Item/Owner/Myhome/MyhomeItem.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
GameServer/Entity/Item/Owner/Myhome/MyhomeItemAction.cs
Normal file
19
GameServer/Entity/Item/Owner/Myhome/MyhomeItemAction.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class MyhomeItemAction : ItemAction
|
||||
{
|
||||
public MyhomeItemAction(MyhomeItem owner)
|
||||
: base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user