초기커밋
This commit is contained in:
89
ServerCommon/Entity/Attribute/UgcNpcItemAttribute.cs
Normal file
89
ServerCommon/Entity/Attribute/UgcNpcItemAttribute.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using UGC_NPC_META_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class UgcNpcItemAttribute : ItemAttributeBase
|
||||
{
|
||||
|
||||
public UgcNpcItemAttribute(ItemBase owner, EntityBase ownerEntity)
|
||||
: base(owner, ownerEntity)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
||||
|
||||
return new UgcNpcItemAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override ItemDoc onCreateDocBase()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - { owner.toBasicStringWithMaster()}");
|
||||
|
||||
var ugc_npc_attribute = root_parent.getEntityAttribute<UgcNpcAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugc_npc_attribute, () => $"ugc_npc_attribute is null !!! - {owner.toBasicString()}, {owner.toBasicStringWithMaster()}");
|
||||
|
||||
var ugc_npc_meta_guid = ugc_npc_attribute.UgcNpcMetaGuid;
|
||||
|
||||
return new ItemDoc(OwnerEntityType.UgcNpc, ugc_npc_meta_guid, ItemGuid);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var item_base = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(item_base, () => $"item_base is null !!!");
|
||||
var root_parent = item_base.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {item_base.toBasicStringWithMaster()}");
|
||||
|
||||
var parent = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {item_base.toBasicStringWithMaster()}");
|
||||
|
||||
var cloned = new UgcNpcItemAttribute(item_base, parent);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.ItemGuid = ItemGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.ItemStackCount = ItemStackCount;
|
||||
cloned.Level = Level;
|
||||
cloned.Attributes = Attributes.Select(x => x).ToList();
|
||||
cloned.EquipedIvenType = EquipedIvenType;
|
||||
cloned.EquipedPos = EquipedPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
}
|
||||
|
||||
public class UgcNpcItemAttributeTransactor : ItemAttributeBaseTransactor<UgcNpcItemAttribute>
|
||||
{
|
||||
public UgcNpcItemAttributeTransactor(ItemBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user