초기커밋
This commit is contained in:
160
GameServer/Entity/Item/Owner/UgcNpc/UgcNpcItem.cs
Normal file
160
GameServer/Entity/Item/Owner/UgcNpc/UgcNpcItem.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
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 UgcNpcItem : Item
|
||||
{
|
||||
public UgcNpcItem(UgcNpc owner)
|
||||
: base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
var direct_parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(direct_parent, () => $"direct_parent is null !!!");
|
||||
|
||||
addEntityAttribute(new UgcNpcItemAttribute(this, direct_parent));
|
||||
|
||||
addEntityAction(new UgcNpcItemAction(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<UgcNpcItemAction>() 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();
|
||||
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
||||
|
||||
TAttribute? to_cast_entity_attribute;
|
||||
|
||||
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
||||
{
|
||||
to_cast_entity_attribute = base.getOriginEntityAttribute<UgcNpcItemAttribute>() 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();
|
||||
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
||||
|
||||
TAttribute? to_cast_entity_attribute;
|
||||
|
||||
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
||||
{
|
||||
to_cast_entity_attribute = base.getEntityAttributeWithReadOnly<UgcNpcItemAttribute>() 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();
|
||||
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
||||
|
||||
TAttribute? to_cast_entity_attribute;
|
||||
|
||||
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
||||
{
|
||||
to_cast_entity_attribute = base.getEntityAttributeWithCloneOnly<UgcNpcItemAttribute>() 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();
|
||||
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
||||
|
||||
TAttribute? to_cast_entity_attribute;
|
||||
|
||||
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
||||
{
|
||||
to_cast_entity_attribute = base.getClonedEntityAttribute<UgcNpcItemAttribute>() 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();
|
||||
ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!");
|
||||
|
||||
TAttribute? to_cast_entity_attribute;
|
||||
|
||||
if (typeof(TAttribute) == typeof(ItemAttributeBase))
|
||||
{
|
||||
to_cast_entity_attribute = base.getEntityAttribute<UgcNpcItemAttribute>() 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
GameServer/Entity/Item/Owner/UgcNpc/UgcNpcItemAction.cs
Normal file
21
GameServer/Entity/Item/Owner/UgcNpc/UgcNpcItemAction.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class UgcNpcItemAction : ItemAction
|
||||
{
|
||||
public UgcNpcItemAction(UgcNpcItem owner)
|
||||
: base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user