초기커밋
This commit is contained in:
177
GameServer/Entity/Npc/UgcNpc/UgcNpc.cs
Normal file
177
GameServer/Entity/Npc/UgcNpc/UgcNpc.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_META_ID = System.UInt32;
|
||||
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 MASTER_GUID = System.String;
|
||||
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using Amazon.S3.Model;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class UgcNpc : EntityBase, IMergeWithInventory
|
||||
{
|
||||
public UgcNpc(MASTER_GUID masterGuid)
|
||||
: base(EntityType.UgcNpc, masterGuid)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
addEntityAttribute(new UgcNpcAttribute(this));
|
||||
addEntityAttribute(new AppearanceCustomizeAttribute(this));
|
||||
addEntityAttribute(new BeaconShopProfileAttribute(this));
|
||||
|
||||
addEntityAction(new UgcNpcAction(this));
|
||||
|
||||
addEntityAction(new UgcNpcEditAction(this));
|
||||
|
||||
addEntityAction(new AbilityAction(this));
|
||||
|
||||
addEntityAction(new UgcNpcInventoryAction(this));
|
||||
addEntityAction(new ItemClothAction(this));
|
||||
addEntityAction(new ItemTattooAction(this));
|
||||
|
||||
addEntityAction(new BeaconAppearanceCustomizeAction(this));
|
||||
|
||||
addEntityAction(new CustomDefinedUiAction(this));
|
||||
|
||||
// 현재 GameZoneAction은 Player를 위한 로직으로 작성되어 있다.
|
||||
// 추후 인던 관련 설계가 리펙토링되면 GameZoneAction 역시 계층화 되어야 한다. - kangms
|
||||
addEntityAction(new GameZoneAction(this));
|
||||
|
||||
addEntityAction(new FarmingAction(this));
|
||||
addEntityAction(new UgcNpcBeaconShopAction(this));
|
||||
|
||||
return await base.onInit();
|
||||
}
|
||||
|
||||
public async Task<Result> onMerge(List<ReservedSlotOnInven> reservedSlotOnInvens, TransactionRunner transactionRunner)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var ugc_inventory_action = getEntityAction<UgcNpcInventoryAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugc_inventory_action, () => $"ugc_inventory_action is null !!! - {toBasicStringWithMaster()}");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(transactionRunner, () => $"transactionRunner is null !!! - {toBasicStringWithMaster()}");
|
||||
|
||||
result = await ugc_inventory_action.onMergeInventory(reservedSlotOnInvens, transactionRunner);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override EntityBase? onGetMasterEntity()
|
||||
{
|
||||
if(false == hasMasterGuid())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var master_guid = getMasterGuid();
|
||||
|
||||
var server_logc = GameServerApp.getServerLogic();
|
||||
var player_manager = server_logc.getPlayerManager();
|
||||
|
||||
if(false == player_manager.tryGetUserByPrimaryKey(master_guid, out var found_player))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return found_player;
|
||||
}
|
||||
|
||||
public override TAction getEntityAction<TAction>()
|
||||
{
|
||||
TAction? to_cast_entity_atcion;
|
||||
|
||||
if (typeof(TAction) == typeof(InventoryActionBase))
|
||||
{
|
||||
to_cast_entity_atcion = base.getEntityAction<UgcNpcInventoryAction>() as TAction;
|
||||
NullReferenceCheckHelper.throwIfNull(to_cast_entity_atcion, () => $"to_cast_action is null !!!");
|
||||
|
||||
return to_cast_entity_atcion;
|
||||
}
|
||||
|
||||
to_cast_entity_atcion = base.getEntityAction<TAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_cast_entity_atcion, () => $"to_cast_entity_atcion is null !!!");
|
||||
|
||||
return to_cast_entity_atcion;
|
||||
}
|
||||
|
||||
public override Type onGetAvailableItemAttributeType()
|
||||
{
|
||||
return typeof(UgcNpcItemAttribute);
|
||||
}
|
||||
|
||||
public override OWNER_GUID onGetGuidOfOwnerEntityType()
|
||||
{
|
||||
return getMasterGuid();
|
||||
}
|
||||
|
||||
public override OwnerEntityType onGetOwnerEntityType()
|
||||
{
|
||||
return OwnerEntityType.User;
|
||||
}
|
||||
|
||||
public override string onGetDbGuid()
|
||||
{
|
||||
return getUgcNpcMetaGuid();
|
||||
}
|
||||
|
||||
public UGC_NPC_META_GUID getUgcNpcMetaGuid()
|
||||
{
|
||||
return getEntityAttributeWithReadOnly<UgcNpcAttribute>()?.UgcNpcMetaGuid ?? string.Empty;
|
||||
}
|
||||
|
||||
public override string toStateString()
|
||||
{
|
||||
return $"beaconState:{getEntityAttributeWithReadOnly<UgcNpcAttribute>()?.State}"
|
||||
+ $", metaIdOfEntityStateType:{getOriginEntityAttribute<UgcNpcAttribute>()?.MetaIdOfEntityStateType}"
|
||||
+ $", locatedInstanceGuid:{getOriginEntityAttribute<UgcNpcAttribute>()?.LocatedInstanceGuid}"
|
||||
+ $", LocatedInstanceMetaId:{getOriginEntityAttribute<UgcNpcAttribute>()?.LocatedInstanceMetaId}";
|
||||
}
|
||||
|
||||
public override string toSummaryString()
|
||||
{
|
||||
return $"beaconState:{getOriginEntityAttribute<UgcNpcAttribute>()?.State}"
|
||||
+ $", anchorMetaGuid:{getOriginEntityAttribute<UgcNpcAttribute>()?.AnchorMetaGuid}"
|
||||
+ $", metaIdOfEntityStateType:{getOriginEntityAttribute<UgcNpcAttribute>()?.MetaIdOfEntityStateType}"
|
||||
+ $", locatedInstanceGuid:{getOriginEntityAttribute<UgcNpcAttribute>()?.LocatedInstanceGuid}"
|
||||
+ $", LocatedInstanceMetaId:{getOriginEntityAttribute<UgcNpcAttribute>()?.LocatedInstanceMetaId}"
|
||||
+ $", MasterGuid:{getMasterGuid()}, SummonedCount:{getSummenedEntityGuids().Count}";
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"beaconNickname:{getOriginEntityAttribute<UgcNpcAttribute>()?.Nickname}"
|
||||
+ $", ugcNpcMetaGuid:{getOriginEntityAttribute<UgcNpcAttribute>()?.UgcNpcMetaGuid}"
|
||||
+ $", ownerGuid:{getOriginEntityAttribute<UgcNpcAttribute>()?.OwnerGuid}"
|
||||
+ $", ownerEntityType:{getOriginEntityAttribute<UgcNpcAttribute>()?.OwnerEntityType}"
|
||||
+ $", {base.toBasicString()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user