Files
caliverse_server/ServerCommon/Doc/OwnerContents/AppearanceCustomizeDoc.cs
2025-05-01 07:20:41 +09:00

135 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Newtonsoft.Json;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
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 ITEM_GUID = System.String;
namespace ServerCommon;
public class AppearanceCustomizeAttrib : AttribBase
{
[JsonProperty("basic_style")]
public Int32 BasicStyle { get; set; } = 0;
[JsonProperty("body_style")]
public Int32 BodyShape { get; set; } = 0;
[JsonProperty("hair_style")]
public Int32 HairStyle { get; set; } = 0;
[JsonProperty("custom_values")]
public List<Int32> CustomValues { get; set; } = new();
[JsonProperty("owner_entity_type")]
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
[JsonProperty("owner_guid")]
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
public AppearanceCustomizeAttrib()
: base(typeof(AppearanceCustomizeAttrib).Name)
{ }
}
//=============================================================================================
// Primary Key
// PK(Partition Key) : "appearance_customize#owner_guid" [owner_guid : user_guid, ugc_npc_meta_guid]
// SK(Sort Key) : ""
// DocType : ItemDoc
// ItemAttrib : {}
// ...
//=============================================================================================
public class AppearanceCustomizeDoc : DynamoDbDocBase, ICopyDocFromEntityAttribute
{
private static string getPrefixOfPK() { return "appearance_customize#"; }
private static string getPrefixOfSK() { return ""; }
public AppearanceCustomizeDoc()
: base(typeof(AppearanceCustomizeDoc).Name)
{
appendAttribWrapperAll();
}
public AppearanceCustomizeDoc(OwnerEntityType ownerEntityType, string ownerGuid)
: base(typeof(AppearanceCustomizeDoc).Name)
{
setCombinationKeyForPK(ownerGuid);
appendAttribWrapperAll();
fillUpPrimaryKey(onMakePK(), onMakeSK());
var doc_appearance_customize_attrib = getAttrib<AppearanceCustomizeAttrib>();
NullReferenceCheckHelper.throwIfNull(doc_appearance_customize_attrib, () => $"doc_appearance_customize_attrib is null !!! - ownerGuid:{ownerGuid}, ownerEntityType:{ownerEntityType}");
doc_appearance_customize_attrib.OwnerEntityType = ownerEntityType;
doc_appearance_customize_attrib.OwnerGuid = ownerGuid;
}
private void appendAttribWrapperAll()
{
appendAttribWrapper(new AttribWrapper<AppearanceCustomizeAttrib>());
}
protected override string onGetPrefixOfPK()
{
return getPrefixOfPK();
}
protected override string onGetPrefixOfSK()
{
return getPrefixOfSK();
}
protected override ServerErrorCode onCheckAndSetSK(string sortKey)
{
getPrimaryKey().fillUpSK(sortKey);
setCombinationKeyForSK(sortKey);
return ServerErrorCode.Success;
}
// override ICopyDocFromEntityAttribute
public bool copyDocFromEntityAttribute(EntityAttributeBase entityAttributeBase)
{
NullReferenceCheckHelper.throwIfNull(entityAttributeBase, () => $"entityAttributeBase is null !!! - {toBasicString()}");
var appearance_customize_attribute = entityAttributeBase as AppearanceCustomizeAttribute;
if (null == appearance_customize_attribute)
{
return false;
}
var to_copy_doc_appearance_customize_attrib = getAttrib<AppearanceCustomizeAttrib>();
NullReferenceCheckHelper.throwIfNull(to_copy_doc_appearance_customize_attrib, () => $"to_copy_doc_appearance_customize_attrib is null !!! - {toBasicString()}");
to_copy_doc_appearance_customize_attrib.BasicStyle = appearance_customize_attribute.BasicStyle;
to_copy_doc_appearance_customize_attrib.BodyShape = appearance_customize_attribute.BodyShape;
to_copy_doc_appearance_customize_attrib.HairStyle = appearance_customize_attribute.HairStyle;
to_copy_doc_appearance_customize_attrib.CustomValues = appearance_customize_attribute.CustomValues.ToList();
return true;
}
}