Files
caliverse_server/ServerCommon/Entity/Attribute/UgcNpcItemAttribute.cs
2025-05-01 07:23:28 +09:00

90 lines
3.0 KiB
C#

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.EquipedInvenType = EquipedInvenType;
cloned.EquipedPos = EquipedPos;
return cloned;
}
}
public class UgcNpcItemAttributeTransactor : ItemAttributeBaseTransactor<UgcNpcItemAttribute>
{
public UgcNpcItemAttributeTransactor(ItemBase owner)
: base(owner)
{
}
}
}