using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; using Newtonsoft.Json; using ServerCore; using ServerBase; using ServerControlCenter; 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; namespace ServerCommon { public class UserItemAttribute : ItemAttributeBase { public UserItemAttribute(ItemBase owner, EntityBase entityOfOwnerEntityType) : base(owner, entityOfOwnerEntityType) { } public override IEntityAttributeTransactor onNewEntityAttributeTransactor() { var owner = getOwner() as ItemBase; NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!"); return new UserItemAttributeTransactor(owner); } public override DynamoDbDocBase onCreateDocBase() { var owner = getOwner() as ItemBase; NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!"); var parent = owner.getRootParent(); NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}"); var user_attribute = parent.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {parent.toBasicString()}"); var user_guid = user_attribute.UserGuid; return new ItemDoc(OwnerEntityType.User, user_guid, ItemGuid); } public override EntityAttributeBase onCloned() { var owner = getOwner() as ItemBase; NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!"); var parent = owner.getRootParent(); NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}"); var entity_of_owner_entity_type = getEntityOfOwnerEntityType(); NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!! - {parent.toBasicString()}"); var cloned = new UserItemAttribute(owner, entity_of_owner_entity_type); 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 ItemDoc makeDocBase() { var owner = getOwner() as ItemBase; NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!"); var parent = owner.getRootParent(); NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}"); var user_attribute = parent.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {parent.toBasicString()}"); var to_copy_doc = new ItemDoc(OwnerEntityType.User, user_attribute.UserGuid, ItemGuid); var to_copy_doc_item_attrib = to_copy_doc.getAttrib(); NullReferenceCheckHelper.throwIfNull(to_copy_doc_item_attrib, () => $"to_copy_doc_item_attrib is null !!! - {parent.toBasicString()}"); to_copy_doc_item_attrib.ItemGuid = ItemGuid; to_copy_doc_item_attrib.ItemMetaId = ItemMetaId; to_copy_doc_item_attrib.ItemStackCount = ItemStackCount; to_copy_doc_item_attrib.Level = Level; to_copy_doc_item_attrib.Attributes = Attributes.Select(x => x).ToList(); to_copy_doc_item_attrib.EquipedIvenType = EquipedIvenType; to_copy_doc_item_attrib.EquipedPos = EquipedPos; return to_copy_doc; } } public class UserItemAttributeTransactor : ItemAttributeBaseTransactor { public UserItemAttributeTransactor(ItemBase owner) : base(owner) { } } }