초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,244 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using ServerCore; using ServerBase;
using ServerControlCenter;
using META_ID = System.UInt32;
using USER_GUID = System.String;
using Amazon.S3.Model;
namespace ServerCommon
{
public class MinimapMarkerAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
{
[JsonProperty]
public META_ID WorldMetaId { get; set; } = 0;
[JsonProperty]
public Vector3 MarkerPos { get; set; } = new();
public MinimapMarkerAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
: base(owner, entityOfOwnerEntityType)
{
}
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
{
return new MinimapMarkerAttributeTransactor(getOwner());
}
public override void onClear()
{
WorldMetaId = 0;
MarkerPos = new();
getAttributeState().reset();
}
public override EntityAttributeBase onCloned()
{
var entity_type = getEntityOfOwnerEntityType();
NullReferenceCheckHelper.throwIfNull(entity_type, () => "Entity Type is null");
var cloned = new MinimapMarkerAttribute(getOwner(), entity_type);
cloned.deepCopyFromBase(this);
cloned.WorldMetaId = WorldMetaId;
cloned.MarkerPos = MarkerPos;
return cloned;
}
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
{
var result = new Result();
var owner = getOwner();
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
USER_GUID user_guid = user_attribute.UserGuid;
//=====================================================================================
// Attribute => try pending Doc
//=====================================================================================
var try_pending_doc = getTryPendingDocBase() as MinimapMarkerDoc;
if (null == try_pending_doc)
{
var to_copy_doc = new MinimapMarkerDoc(user_guid, WorldMetaId);
var origin_doc = getOriginDocBase<MinimapMarkerAttribute>();
if (null != origin_doc)
{
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
}
try_pending_doc = to_copy_doc;
setTryPendingDocBase(try_pending_doc);
}
var to_copy_doc_attrib = try_pending_doc.getAttrib<MinimapMarkerAttrib>();
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
to_copy_doc_attrib.WorldMetaId = WorldMetaId;
to_copy_doc_attrib.MarkerPos = MarkerPos;
if (false == isForQuery)
{
return (result, try_pending_doc);
}
//=====================================================================================
// Doc QueryType 반영
//=====================================================================================
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
if (result.isFail())
{
return (result, to_query_doc);
}
return (result, to_query_doc);
}
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
{
var err_msg = string.Empty;
var to_cast_string = typeof(MinimapMarkerDoc).Name;
var minimap_marker_doc_base = docBase as MinimapMarkerDoc;
if (null == minimap_marker_doc_base)
{
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, minimap_marker_doc_base is null :{to_cast_string}";
Log.getLogger().error(err_msg);
return false;
}
//=====================================================================================
// New Doc => Origin Doc
//=====================================================================================
syncOriginDocBaseWithNewDoc<MinimapMarkerAttribute>(minimap_marker_doc_base);
//=====================================================================================
// Doc => Attribute
//=====================================================================================
var doc_attrib = minimap_marker_doc_base.getAttrib<MinimapMarkerAttrib>();
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => "doc_attrib is null !!!");
WorldMetaId = doc_attrib.WorldMetaId;
MarkerPos = doc_attrib.MarkerPos;
return true;
}
public Result onMerge(EntityAttributeBase otherEntityAttribute)
{
var owner = getOwner();
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
var result = new Result();
var err_msg = string.Empty;
if (null == otherEntityAttribute)
{
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
//=====================================================================================
// OtherAttribute => Attribute
//=====================================================================================
var minimap_marker_attribute = otherEntityAttribute as MinimapMarkerAttribute;
if (null == minimap_marker_attribute)
{
err_msg = $"Failed to cast MinimapMarkerAttribute !!!, minimap_marker_attribute is null";
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
WorldMetaId = minimap_marker_attribute.WorldMetaId;
MarkerPos = minimap_marker_attribute.MarkerPos;
//=====================================================================================
// Attribute Try Pending Doc => Origin Doc
//=====================================================================================
var try_pending_doc = minimap_marker_attribute.getTryPendingDocBase() as MinimapMarkerDoc;
if (null != try_pending_doc)
{
minimap_marker_attribute.resetTryPendingDocBase();
syncOriginDocBaseWithNewDoc<MinimapMarkerAttribute>(try_pending_doc);
}
var origin_doc_base = getOriginDocBase<MinimapMarkerAttribute>();
if (null == origin_doc_base)
{
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
return result;
}
var minimap_marker_attrib = origin_doc_base.getAttrib<MinimapMarkerAttrib>();
NullReferenceCheckHelper.throwIfNull(minimap_marker_attrib, () => $"minimap_marker_attrib is null !!! - {owner.toBasicString()}");
minimap_marker_attrib.WorldMetaId = WorldMetaId;
minimap_marker_attrib.MarkerPos = MarkerPos;
return result;
}
}
public class MinimapMarkerAttributeTransactor : EntityAttributeTransactorBase<MinimapMarkerAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
{
public MinimapMarkerAttributeTransactor(EntityBase owner)
: base(owner)
{
}
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
{
var err_msg = string.Empty;
var to_cast_string = typeof(MinimapMarkerAttribute).Name;
var copy_from_minimap_marker_attribute = entityAttributeBase as MinimapMarkerAttribute;
if (null == copy_from_minimap_marker_attribute)
{
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_minimap_marker_attribute is null :{to_cast_string}";
Log.getLogger().error(err_msg);
return false;
}
var copy_to_minimap_marker_attribute = getClonedEntityAttribute() as MinimapMarkerAttribute;
if (null == copy_to_minimap_marker_attribute)
{
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_minimap_marker_attribute is null :{to_cast_string}";
Log.getLogger().error(err_msg);
return false;
}
copy_to_minimap_marker_attribute.WorldMetaId = copy_from_minimap_marker_attribute.WorldMetaId;
copy_to_minimap_marker_attribute.MarkerPos = copy_from_minimap_marker_attribute.MarkerPos;
return true;
}
}
}