초기커밋
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class MinimapMarkerAgentAction : EntityActionBase
|
||||
{
|
||||
ConcurrentDictionary<int, MinimapMarker> m_minimap_markers = new();
|
||||
|
||||
public MinimapMarkerAgentAction(Player owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_minimap_markers.Clear();
|
||||
}
|
||||
|
||||
public List<MinimapMarker> getMinimapMarkers()
|
||||
{
|
||||
return m_minimap_markers.Select(x => x.Value).ToList();
|
||||
}
|
||||
|
||||
public async Task<Result> tryAddMinimapMarkerFromDoc(MinimapMarkerDoc minimapMarkerDoc)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => "player is null !!!");
|
||||
|
||||
MinimapMarker minimap_marker = new(player);
|
||||
await minimap_marker.onInit();
|
||||
|
||||
var minimap_marker_attribute = minimap_marker.getEntityAttribute<MinimapMarkerAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(minimap_marker_attribute, () => $"minimap_marker_attribute is null !!! - {player.toBasicString()}");
|
||||
|
||||
if (!minimap_marker_attribute.copyEntityAttributeFromDoc(minimapMarkerDoc))
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!! to:{minimap_marker_attribute.getTypeName()}, from:{minimapMarkerDoc.getTypeName()} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.DynamoDbDocCopyToEntityAttributeFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!m_minimap_markers.TryAdd((int)minimap_marker_attribute.WorldMetaId, minimap_marker))
|
||||
{
|
||||
err_msg = $"Failed to TryAdd() !!! : {minimap_marker.toBasicString()} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.MinimapMarkerDocLoadDuplicatedMinimapMarker, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Result> tryRegisterMinimapMarker(int worldMetaId, Vector3 markerPos)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => "player is null !!!");
|
||||
|
||||
if (!MetaData.Instance._WorldMetaTable.TryGetValue(worldMetaId, out var worldMetaData))
|
||||
{
|
||||
err_msg = $"Failed to TryGetValue() !!! : worldMetaId:{worldMetaId} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.WorldMetaDataNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (m_minimap_markers.TryGetValue(worldMetaId, out var minimap_marker))
|
||||
{
|
||||
var minimap_marker_action = minimap_marker.getEntityAction<MinimapMarkerAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(minimap_marker_action, () => $"minimap_marker_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
// 위치 변경
|
||||
minimap_marker_action.changeMarkerPos(markerPos);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 신규 생성
|
||||
minimap_marker = new(player);
|
||||
await minimap_marker.onInit();
|
||||
|
||||
var minimap_marker_attribute = minimap_marker.getEntityAttribute<MinimapMarkerAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(minimap_marker_attribute, () => $"minimap_marker_attribute is null !!! - {player.toBasicString()}");
|
||||
|
||||
minimap_marker_attribute.WorldMetaId = (uint)worldMetaId;
|
||||
minimap_marker_attribute.MarkerPos = markerPos;
|
||||
minimap_marker_attribute.newEntityAttribute();
|
||||
|
||||
m_minimap_markers[(int)minimap_marker_attribute.WorldMetaId] = minimap_marker;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result tryDeregisterMinimapMarker(int worldMetaId)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (!MetaData.Instance._WorldMetaTable.TryGetValue(worldMetaId, out var worldMetaData))
|
||||
{
|
||||
err_msg = $"Failed to TryGetValue() !!! : worldMetaId:{worldMetaId} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.WorldMetaDataNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!m_minimap_markers.ContainsKey(worldMetaId))
|
||||
{
|
||||
err_msg = $"Failed to ContainsKey() !!! : worldMetaId:{worldMetaId} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.WorldMetaDataNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!m_minimap_markers.TryRemove(worldMetaId, out var minimap_marker))
|
||||
{
|
||||
err_msg = $"Failed to TryRemove() !!! : worldMetaId:{worldMetaId} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.WorldMetaDataNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var minimap_marker_attribute = minimap_marker.getEntityAttribute<MinimapMarkerAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(minimap_marker_attribute, () => $"minimap_marker_attribute is null !!! - {getOwner().toBasicString()}");
|
||||
|
||||
minimap_marker_attribute.deleteEntityAttribute();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user