196 lines
7.0 KiB
C#
196 lines
7.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
using SESSION_ID = System.Int32;
|
|
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 UGC_NPC_META_GUID = System.String;
|
|
using ITEM_GUID = System.String;
|
|
using ANCHOR_META_GUID = System.String;
|
|
using LOCATED_INSTANCE_GUID = System.String;
|
|
|
|
|
|
|
|
namespace ServerCommon
|
|
{
|
|
public class UgcNpcAttrib : AttribBase
|
|
{
|
|
[JsonProperty("ugc_npc_meta_guid")]
|
|
public UGC_NPC_META_GUID UgcNpcMetaGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("owner_guid")]
|
|
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("owner_entity_type")]
|
|
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
|
|
|
[JsonProperty("nickname")]
|
|
public string Nickname { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("title")]
|
|
public string Title { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("greeting")]
|
|
public string Greeting { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("introduction")]
|
|
public string Introduction { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("Description")]
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("WorldScenario")]
|
|
public string WorldScenario { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("default_social_action_meta_id")]
|
|
public META_ID DefaultSocialActionMetaId { get; set; } = 0;
|
|
|
|
[JsonProperty("habit_social_action_meta_ids")]
|
|
public List<META_ID> HabitSocialActionMetaIds { get; set; } = new List<META_ID>();
|
|
|
|
[JsonProperty("dialogue_social_action_meta_ids")]
|
|
public List<META_ID> DialogueSocialActionMetaIds { get; set; } = new List<META_ID>() { 110054 };
|
|
|
|
[JsonProperty("body_item_meta_id")]
|
|
public META_ID BodyItemMetaId { get; set; } = 0;
|
|
|
|
[JsonProperty("hash_tag_meta_ids")]
|
|
public List<META_ID> HashTagMetaIds { get; set; } = new List<META_ID>();
|
|
|
|
[JsonProperty("language_type")]
|
|
public LanguageType LanguageType { get; set; } = LanguageType.None;
|
|
|
|
[JsonProperty("state")]
|
|
public EntityStateType State { get; set; } = EntityStateType.None;
|
|
|
|
[JsonProperty("anchor_meta_guid")]
|
|
public ANCHOR_META_GUID AnchorMetaGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("meat_id_of_entity_state_type")]
|
|
public META_ID MetaIdOfEntityStateType { get; set; } = 0;
|
|
|
|
[JsonProperty("located_instance_guid")]
|
|
public LOCATED_INSTANCE_GUID LocatedInstanceGuid { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("located_instance_meta_id")]
|
|
public META_ID LocatedInstanceMetaId { get; set; } = 0;
|
|
|
|
[JsonProperty("is_registered_ai_chat_server")]
|
|
public bool IsRegisteredAiChatServer { get; set; } = false;
|
|
|
|
public UgcNpcAttrib()
|
|
: base(typeof(UgcNpcAttrib).Name, false)
|
|
{ }
|
|
}
|
|
|
|
//=============================================================================================
|
|
// Primary Key
|
|
// PK(Partition Key) : "ugc_npc#owner_guid" [owner_guid : user_guid]
|
|
// SK(Sort Key) : "ugc_npc_meta_guid"
|
|
// DocType : UgcNpcDoc
|
|
// UgcNpcAttrib : {}
|
|
// ...
|
|
//=============================================================================================
|
|
public class UgcNpcDoc : DynamoDbDocBase
|
|
{
|
|
private static string getDocTypeName() { return typeof(UgcNpcDoc).Name; }
|
|
private static string getPrefixOfPK() { return "ugc_npc#"; }
|
|
private static string getPrefixOfSK() { return ""; }
|
|
|
|
public UgcNpcDoc()
|
|
: base(getDocTypeName())
|
|
{
|
|
appendAttribWrapperAll();
|
|
}
|
|
|
|
public UgcNpcDoc(OwnerEntityType ownerEntityType, string ownerGuid, string ugcNpcMetaGuid)
|
|
: base(getDocTypeName())
|
|
{
|
|
setCombinationKeyForPK(ownerGuid);
|
|
setCombinationKeyForSK(ugcNpcMetaGuid);
|
|
|
|
appendAttribWrapperAll();
|
|
|
|
fillUpPrimaryKey(onMakePK(), onMakeSK());
|
|
|
|
var doc_ugc_npc_attrib = getAttrib<UgcNpcAttrib>();
|
|
NullReferenceCheckHelper.throwIfNull(doc_ugc_npc_attrib, () => $"doc_ugc_npc_attrib is null !!!");
|
|
|
|
doc_ugc_npc_attrib.OwnerEntityType = ownerEntityType;
|
|
doc_ugc_npc_attrib.OwnerGuid = ownerGuid;
|
|
doc_ugc_npc_attrib.UgcNpcMetaGuid = ugcNpcMetaGuid;
|
|
}
|
|
|
|
private void appendAttribWrapperAll()
|
|
{
|
|
appendAttribWrapper(new AttribWrapper<UgcNpcAttrib>());
|
|
}
|
|
|
|
protected override string onGetPrefixOfPK()
|
|
{
|
|
return getPrefixOfPK();
|
|
}
|
|
|
|
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
|
|
{
|
|
getPrimaryKey().fillUpSK(sortKey);
|
|
setCombinationKeyForSK(sortKey);
|
|
|
|
return ServerErrorCode.Success;
|
|
}
|
|
|
|
public static async Task<(Result result, UgcNpcAttrib? attrib)> findUgcNpc(string ownerGuid, string ugqNpcMetaGuid)
|
|
{
|
|
var result = new Result();
|
|
var ugc_npc_docs = new List<UgcNpcDoc>();
|
|
|
|
(result, var make_primary_key) = await DynamoDBDocBaseHelper.makePrimaryKey<UgcNpcDoc>(ownerGuid);
|
|
if (result.isFail())
|
|
{
|
|
return (result, null);
|
|
}
|
|
NullReferenceCheckHelper.throwIfNull(make_primary_key, () => $"make_primary_key is null !!! - ownerGuid:{ownerGuid}, ugqNpcMetaGuid:{ugqNpcMetaGuid}");
|
|
|
|
var server_logic = ServerLogicApp.getServerLogicApp();
|
|
var dynamo_db_client = server_logic.getDynamoDbClient();
|
|
|
|
var query_config = dynamo_db_client.makeQueryConfigForReadByPKSK(make_primary_key.PK, ugqNpcMetaGuid);
|
|
|
|
(result, ugc_npc_docs) = await dynamo_db_client.simpleQueryDocTypesWithQueryOperationConfig<UgcNpcDoc>(query_config);
|
|
if (result.isFail())
|
|
{
|
|
var err_msg = $"Failed to simpleQueryDocTypesWithQueryOperationConfig() !!! : {result.toBasicString()} - ownerGuid:{ownerGuid}, ugqNpcMetaGuid:{ugqNpcMetaGuid}";
|
|
Log.getLogger().error(err_msg);
|
|
return (result, null);
|
|
}
|
|
if (0 >= ugc_npc_docs.Count)
|
|
{
|
|
var err_msg = $"ugc npc info not exist !!! ownerGuid:{ownerGuid}, ugqNpcMetaGuid:{ugqNpcMetaGuid}";
|
|
result.setFail(ServerErrorCode.UgcNpcNotFound, err_msg);
|
|
return (result, null);
|
|
}
|
|
|
|
var ugc_npc_attrib = ugc_npc_docs[0].getAttrib<UgcNpcAttrib>();
|
|
NullReferenceCheckHelper.throwIfNull(ugc_npc_attrib, () => $"ugc_npc_attrib is null !!! - ownerGuid:{ownerGuid}, ugqNpcMetaGuid:{ugqNpcMetaGuid}");
|
|
|
|
return (result, ugc_npc_attrib);
|
|
}
|
|
}
|
|
}
|
|
|