79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
namespace ServerCommon
|
|
{
|
|
public class MyhomeItemAttribute : ItemAttributeBase
|
|
{
|
|
public MyhomeItemAttribute(ItemBase owner, EntityBase ownerEntity)
|
|
: base(owner, ownerEntity)
|
|
{
|
|
}
|
|
|
|
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
|
{
|
|
var owner = getOwner() as ItemBase;
|
|
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
|
|
|
return new MyhomeItemAttributeTransactor(owner);
|
|
}
|
|
|
|
public override ItemDoc onCreateDocBase()
|
|
{
|
|
var owner = getOwner();
|
|
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
|
var direct_parent = owner.getDirectParent();
|
|
ArgumentNullException.ThrowIfNull(direct_parent, $"direct_parent is null !!! - {owner.toBasicString()}");
|
|
|
|
var root_parent = owner.getRootParent();
|
|
ArgumentNullException.ThrowIfNull(root_parent, $"root_parent is null !!! - {owner.toBasicString()}");
|
|
|
|
var myhome_attribute = direct_parent.getEntityAttribute<MyhomeAttribute>();
|
|
ArgumentNullException.ThrowIfNull(myhome_attribute, $"myhome_attribute is null !!! - {direct_parent.toBasicString()}, {root_parent?.toBasicString()}");
|
|
|
|
var myhome_guid = myhome_attribute.MyhomeGuid;
|
|
|
|
return new ItemDoc(OwnerEntityType.Myhome, myhome_guid, ItemGuid);
|
|
}
|
|
|
|
public override EntityAttributeBase onCloned()
|
|
{
|
|
var owner = getOwner() as ItemBase;
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
|
var direct_parent = owner.getDirectParent();
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(direct_parent, () => $"direct_parent is null !!!");
|
|
var owner_entity = getEntityOfOwnerEntityType();
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(owner_entity, () => $"owner_entity is null !!!");
|
|
|
|
var cloned = new MyhomeItemAttribute(owner, owner_entity);
|
|
|
|
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 MyhomeItemAttributeTransactor : ItemAttributeBaseTransactor<MyhomeItemAttribute>
|
|
{
|
|
public MyhomeItemAttributeTransactor(ItemBase owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
}
|
|
}
|