초기커밋
This commit is contained in:
39
GameServer/Contents/OwnedLand/Action/OwnedLandAction.cs
Normal file
39
GameServer/Contents/OwnedLand/Action/OwnedLandAction.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class OwnedLandAction : EntityActionBase
|
||||
{
|
||||
public OwnedLandAction(OwnedLand owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void DeleteOwnedLand()
|
||||
{
|
||||
var owned_land = getOwner() as OwnedLand;
|
||||
NullReferenceCheckHelper.throwIfNull(owned_land, () => $"owned_land is null !!!");
|
||||
|
||||
var owned_land_attribute = owned_land.getEntityAttribute<OwnedLandAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(owned_land_attribute, () => $"owned_land_attribute is null !!!");
|
||||
|
||||
owned_land_attribute.deleteEntityAttribute();
|
||||
}
|
||||
}
|
||||
}
|
||||
101
GameServer/Contents/OwnedLand/Action/OwnedLandAgentAction.cs
Normal file
101
GameServer/Contents/OwnedLand/Action/OwnedLandAgentAction.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class OwnedLandAgentAction : EntityActionBase
|
||||
{
|
||||
ConcurrentDictionary<int, OwnedLand> m_owned_lands = new();
|
||||
|
||||
public OwnedLandAgentAction(Player owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_owned_lands.Clear();
|
||||
}
|
||||
|
||||
public bool tryGetOwnedLand(int landMetaId, [MaybeNullWhen(false)] out OwnedLand ownedLand)
|
||||
{
|
||||
return m_owned_lands.TryGetValue(landMetaId, out ownedLand);
|
||||
}
|
||||
|
||||
public List<OwnedLand> getOwnedLands()
|
||||
{
|
||||
return m_owned_lands.Values.ToList();
|
||||
}
|
||||
|
||||
public List<int> getOwnedLandMetaIds()
|
||||
{
|
||||
var land_meta_ids = new List<int>();
|
||||
|
||||
foreach (var owned_land in m_owned_lands.Values)
|
||||
{
|
||||
var land_meta_id = owned_land.getLandMetaId();
|
||||
|
||||
land_meta_ids.Add(land_meta_id);
|
||||
}
|
||||
|
||||
return land_meta_ids;
|
||||
}
|
||||
|
||||
public bool isOwnedLand(int landMetaId)
|
||||
{
|
||||
return m_owned_lands.ContainsKey(landMetaId);
|
||||
}
|
||||
|
||||
public void addOwnedLand(int landMetaId, OwnedLand ownedLand)
|
||||
{
|
||||
m_owned_lands[landMetaId] = ownedLand;
|
||||
}
|
||||
|
||||
public void removeOwnedLand(int landMetaId)
|
||||
{
|
||||
m_owned_lands.TryRemove(landMetaId, out _);
|
||||
}
|
||||
|
||||
public async Task<Result> tryAddOwnedLandFromDoc(OwnedLandDoc ownedLandDoc)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var player = getOwner() as Player;
|
||||
ArgumentNullException.ThrowIfNull(player);
|
||||
|
||||
var owned_land = new OwnedLand(player);
|
||||
await owned_land.onInit();
|
||||
|
||||
var owned_land_attribute = owned_land.getEntityAttribute<OwnedLandAttribute>();
|
||||
ArgumentNullException.ThrowIfNull(owned_land_attribute);
|
||||
|
||||
if (!owned_land_attribute.copyEntityAttributeFromDoc(ownedLandDoc))
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!! to:{owned_land_attribute.getTypeName()}, from:{ownedLandDoc.getTypeName()} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.DynamoDbDocCopyToEntityAttributeFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!m_owned_lands.TryAdd((int)owned_land_attribute.LandMetaId, owned_land))
|
||||
{
|
||||
err_msg = $"Failed to TryAdd() !!! : {owned_land_attribute.toBasicString()} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.OwnedLandDocLoadDuplicatedOwnedLand, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user