초기커밋
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
165
GameServer/Entity/Item/Owner/User/UserItem.cs
Normal file
165
GameServer/Entity/Item/Owner/User/UserItem.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
GameServer/Entity/Item/Owner/User/UserItemAction.cs
Normal file
20
GameServer/Entity/Item/Owner/User/UserItemAction.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class UserItemAction : ItemAction
|
||||
{
|
||||
public UserItemAction(UserItem owner)
|
||||
: base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user