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 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() { var parent = getRootParent(); ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!"); if (typeof(TAction) == typeof(ItemAction)) { var item_action = base.getEntityAction() as TAction; NullReferenceCheckHelper.throwIfNull(item_action, () => $"item_action is null !!!"); return item_action; } var action = base.getEntityAction(); NullReferenceCheckHelper.throwIfNull(action, () => $"action is null !!!"); return action; } public override TAttribute getOriginEntityAttribute() { var parent = getRootParent(); ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!"); if (typeof(TAttribute) == typeof(ItemAttributeBase)) { var item_attrib = base.getOriginEntityAttribute() as TAttribute; NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!"); return item_attrib; } var attrib = base.getOriginEntityAttribute(); NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!"); return attrib; } public override TAttribute getEntityAttributeWithReadOnly() { var parent = getRootParent(); ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!"); if (typeof(TAttribute) == typeof(ItemAttributeBase)) { var item_attrib = base.getEntityAttributeWithReadOnly() as TAttribute; NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!"); return item_attrib; } var attrib = base.getEntityAttributeWithReadOnly(); NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!"); return attrib; } public override TAttribute getEntityAttributeWithCloneOnly() { var parent = getRootParent(); ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!"); if (typeof(TAttribute) == typeof(ItemAttributeBase)) { var item_attrib = base.getEntityAttributeWithCloneOnly() as TAttribute; NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!"); return item_attrib; } var attrib = base.getEntityAttributeWithCloneOnly(); NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!"); return attrib; } public override TAttribute getClonedEntityAttribute() { var parent = getRootParent(); ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!"); if (typeof(TAttribute) == typeof(ItemAttributeBase)) { var item_attrib = base.getClonedEntityAttribute() as TAttribute; NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!"); return item_attrib; } var attrib = base.getClonedEntityAttribute(); NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!"); return attrib; } public override TAttribute getEntityAttribute() { var parent = getRootParent(); ArgumentNullException.ThrowIfNull(parent, $"parent is null !!!"); if (typeof(TAttribute) == typeof(ItemAttributeBase)) { var item_attrib = base.getEntityAttribute() as TAttribute; NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!!"); return item_attrib; } var attrib = base.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(attrib, () => $"attrib is null !!!"); return attrib; } } }