using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Google.Protobuf.WellKnownTypes; using Newtonsoft.Json; using ServerCore; using ServerBase; using ENTITY_UNIQUE_ID = System.String; using ANCHOR_META_GUID = System.String; using LOCATION_UNIQUE_ID = System.String; using NPC_UNIQUE_ID = System.String; using OWNER_GUID = System.String; namespace ServerCommon; public class NpcLocationInTargetAttrib : AttribBase { [JsonProperty("location_unique_id")] //[PK 참조] public LOCATION_UNIQUE_ID LocationUniqueId { get; set; } = string.Empty; [JsonProperty("anchor_meta_guid")] //[SK 참조] public ANCHOR_META_GUID AnchorMetaGuid { get; set; } = string.Empty; [JsonProperty("npc_type")] public EntityType NpcType { get; set; } = 0; [JsonProperty("npc_unique_id")] //[EntityType.Beacon: UgcNpcMetaGuid] public NPC_UNIQUE_ID NpcUniqueId { get; set; } = string.Empty; [JsonProperty("npc_location")] public NpcLocation NpcLocation { get; set; } = new NpcLocation(); [JsonProperty("owner_entity_type")] public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None; [JsonProperty("owner_guid")] public OWNER_GUID OwnerGuid { get; set; } = string.Empty; public NpcLocationInTargetAttrib() : base(typeof(NpcLocationInTargetAttrib).Name, false) { } } //============================================================================================= // Primary Key // PK(Partition Key) : "npc_location#{LOCATION_UNIQUE_ID}" [LOCATION_UNIQUE_ID.InstanceNumber: MyHomeMetaGuid, RoomId] // SK(Sort Key) : "anchor_meta_guid" // DocType : "NpcLocationInTargetDoc" // NpcLocationInTargetAttrib : {} // ... //============================================================================================= public class NpcLocationInTargetDoc : DynamoDbDocBase { private static string getDocTypeName() { return typeof(NpcLocationInTargetDoc).Name; } private string getPrefixOfPK() { return $"npc_location#"; } private string getPrefixOfSK() { return ""; } public NpcLocationInTargetDoc() : base(getDocTypeName()) { appendAttribWrapperAll(); } public NpcLocationInTargetDoc(LOCATION_UNIQUE_ID locationUniqueId) : base(getDocTypeName()) { setCombinationKeyForPK(locationUniqueId); appendAttribWrapperAll(); fillUpPrimaryKey(onMakePK(), onMakeSK()); } public NpcLocationInTargetDoc(LOCATION_UNIQUE_ID locationUniqueId, ANCHOR_META_GUID anchorMetaGuid) : base(getDocTypeName()) { setCombinationKeyForPK(locationUniqueId); setCombinationKeyForSK(anchorMetaGuid); appendAttribWrapperAll(); fillUpPrimaryKey(onMakePK(), onMakeSK()); } public NpcLocationInTargetDoc( LOCATION_UNIQUE_ID locationUniqueId, ANCHOR_META_GUID anchorMetaGuid , EntityType npcType, NPC_UNIQUE_ID npcUniqueId, NpcLocation npcLocation , OwnerEntityType ownerEntityType, OWNER_GUID ownerGuid ) : base(getDocTypeName()) { setCombinationKeyForPK(locationUniqueId); setCombinationKeyForSK(anchorMetaGuid); appendAttribWrapperAll(); fillUpPrimaryKey(onMakePK(), onMakeSK()); var npc_location_in_target_attrib = getAttrib(); ArgumentNullException.ThrowIfNull(npc_location_in_target_attrib, $"npc_location_in_target_attrib is null !!!"); npc_location_in_target_attrib.LocationUniqueId = locationUniqueId; npc_location_in_target_attrib.AnchorMetaGuid = anchorMetaGuid; npc_location_in_target_attrib.NpcType = npcType; npc_location_in_target_attrib.NpcUniqueId = npcUniqueId; npc_location_in_target_attrib.NpcLocation = npcLocation; npc_location_in_target_attrib.OwnerEntityType = ownerEntityType; npc_location_in_target_attrib.OwnerGuid = ownerGuid; } private void appendAttribWrapperAll() { appendAttribWrapper(new AttribWrapper()); } protected override string onGetPrefixOfPK() { return getPrefixOfPK(); } protected override ServerErrorCode onCheckAndSetSK(string sortKey) { getPrimaryKey().fillUpSK(sortKey); setCombinationKeyForSK(sortKey); return ServerErrorCode.Success; } }