Avatar swap, fix invisible weapons
This commit is contained in:
parent
ac277d019a
commit
a762ec8241
7 changed files with 37 additions and 15 deletions
|
@ -9,6 +9,19 @@ namespace NahidaImpact.Gameserver.Controllers;
|
|||
[NetController]
|
||||
internal class AvatarController : ControllerBase
|
||||
{
|
||||
[NetCommand(CmdType.ChangeAvatarReq)]
|
||||
public async ValueTask<IResult> OnChangeAvatarReq(SceneManager sceneManager)
|
||||
{
|
||||
ChangeAvatarReq request = Packet!.DecodeBody<ChangeAvatarReq>();
|
||||
|
||||
await sceneManager.ReplaceCurrentAvatarAsync(request.Guid);
|
||||
|
||||
return Response(CmdType.ChangeAvatarRsp, new ChangeAvatarRsp
|
||||
{
|
||||
CurGuid = request.Guid
|
||||
});
|
||||
}
|
||||
|
||||
[NetCommand(CmdType.SetUpAvatarTeamReq)]
|
||||
public async ValueTask<IResult> OnSetUpAvatarTeamReq(NetSession session, SceneManager sceneManager)
|
||||
{
|
||||
|
|
|
@ -9,9 +9,6 @@ namespace NahidaImpact.Gameserver.Controllers;
|
|||
[NetController]
|
||||
internal class SceneController : ControllerBase
|
||||
{
|
||||
// TODO: Scene management, Entity management!!!
|
||||
public const uint WeaponEntityId = 100663300;
|
||||
|
||||
[NetCommand(CmdType.GetScenePointReq)]
|
||||
public ValueTask<IResult> OnGetScenePointReq(SceneManager sceneManager, Player player)
|
||||
{
|
||||
|
@ -37,7 +34,7 @@ internal class SceneController : ControllerBase
|
|||
SceneId = sceneManager.CurrentSceneId
|
||||
};
|
||||
|
||||
for (uint i = 1; i <= 20; i++)
|
||||
for (uint i = 1; i <= 100; i++)
|
||||
{
|
||||
rsp.AreaIdList.Add(i);
|
||||
}
|
||||
|
|
|
@ -5,14 +5,13 @@ using NahidaImpact.Protocol;
|
|||
namespace NahidaImpact.Gameserver.Game.Avatar;
|
||||
internal class GameAvatar
|
||||
{
|
||||
public const ulong WeaponGuid = 2281337;
|
||||
|
||||
public ulong Guid { get; set; }
|
||||
|
||||
public uint AvatarId { get; set; }
|
||||
public uint SkillDepotId { get; set; }
|
||||
public uint WearingFlycloakId { get; set; }
|
||||
public uint BornTime { get; set; }
|
||||
public ulong WeaponGuid { get; set; }
|
||||
|
||||
public uint WeaponId { get; set; } // TODO: Weapon class!
|
||||
|
||||
|
|
|
@ -12,11 +12,13 @@ internal class AvatarEntity : SceneEntity
|
|||
public override ProtEntityType EntityType => ProtEntityType.Avatar;
|
||||
|
||||
public uint Uid { get; }
|
||||
public uint WeaponEntityId { get; }
|
||||
public GameAvatar GameAvatar { get; }
|
||||
|
||||
public AvatarEntity(GameAvatar gameAvatar, uint uid, uint entityId) : base(entityId)
|
||||
public AvatarEntity(GameAvatar gameAvatar, uint uid, uint entityId, uint weaponEntityId) : base(entityId)
|
||||
{
|
||||
Uid = uid;
|
||||
WeaponEntityId = ((uint)ProtEntityType.Weapon << 24) + weaponEntityId; // temporary solution, need real weapon entity object.
|
||||
GameAvatar = gameAvatar;
|
||||
Properties = gameAvatar.Properties;
|
||||
FightProperties = gameAvatar.FightProperties;
|
||||
|
@ -65,7 +67,7 @@ internal class AvatarEntity : SceneEntity
|
|||
SkillDepotId = GameAvatar.SkillDepotId,
|
||||
Weapon = new SceneWeaponInfo
|
||||
{
|
||||
EntityId = SceneController.WeaponEntityId,
|
||||
EntityId = WeaponEntityId,
|
||||
GadgetId = 50000000 + GameAvatar.WeaponId,
|
||||
ItemId = GameAvatar.WeaponId,
|
||||
Guid = GameAvatar.WeaponGuid,
|
||||
|
|
|
@ -7,6 +7,6 @@ internal class EntityFactory
|
|||
|
||||
public AvatarEntity CreateAvatar(GameAvatar gameAvatar, uint belongUid)
|
||||
{
|
||||
return new(gameAvatar, belongUid, ++_entityIdSeed);
|
||||
return new(gameAvatar, belongUid, ++_entityIdSeed, ++_entityIdSeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ internal class Player(ExcelTableCollection excelTables)
|
|||
WeaponId = avatarExcel.InitialWeapon,
|
||||
BornTime = currentTimestamp,
|
||||
Guid = NextGuid(),
|
||||
WearingFlycloakId = 140001
|
||||
WearingFlycloakId = 140001,
|
||||
WeaponGuid = NextGuid()
|
||||
};
|
||||
|
||||
avatar.InitDefaultProps(avatarExcel);
|
||||
|
|
|
@ -60,13 +60,23 @@ internal class SceneManager(NetSession session, Player player, EntityManager ent
|
|||
_enterState = SceneEnterState.Complete;
|
||||
}
|
||||
|
||||
public async ValueTask ReplaceCurrentAvatarAsync(ulong replaceToGuid)
|
||||
{
|
||||
// TODO: add logic checks.
|
||||
|
||||
AvatarEntity avatar = _teamAvatars.Find(a => a.GameAvatar.Guid == replaceToGuid)
|
||||
?? throw new ArgumentException($"ReplaceCurrentAvatar: avatar with guid {replaceToGuid} not in team!");
|
||||
|
||||
await _entityManager.SpawnEntityAsync(avatar, VisionType.Replace);
|
||||
}
|
||||
|
||||
public async ValueTask ChangeTeamAvatarsAsync(ulong[] guidList)
|
||||
{
|
||||
_teamAvatars.Clear();
|
||||
|
||||
foreach (ulong guid in guidList)
|
||||
{
|
||||
GameAvatar gameAvatar = _player.Avatars.Find(avatar => avatar.Guid == guid)!; // currently only first one
|
||||
GameAvatar gameAvatar = _player.Avatars.Find(avatar => avatar.Guid == guid)!;
|
||||
|
||||
AvatarEntity avatarEntity = _entityFactory.CreateAvatar(gameAvatar, _player.Uid);
|
||||
avatarEntity.SetPosition(2336.789f, 249.98896f, -751.3081f);
|
||||
|
@ -152,9 +162,9 @@ internal class SceneManager(NetSession session, Player player, EntityManager ent
|
|||
sceneTeamUpdate.SceneTeamAvatarList.Add(new SceneTeamAvatar
|
||||
{
|
||||
SceneEntityInfo = avatar.AsInfo(),
|
||||
WeaponEntityId = SceneController.WeaponEntityId,
|
||||
WeaponEntityId = avatar.WeaponEntityId,
|
||||
PlayerUid = _player.Uid,
|
||||
WeaponGuid = GameAvatar.WeaponGuid,
|
||||
WeaponGuid = avatar.GameAvatar.WeaponGuid,
|
||||
EntityId = avatar.EntityId,
|
||||
AvatarGuid = avatar.GameAvatar.Guid,
|
||||
AbilityControlBlock = avatar.BuildAbilityControlBlock(_binData),
|
||||
|
@ -191,8 +201,8 @@ internal class SceneManager(NetSession session, Player player, EntityManager ent
|
|||
{
|
||||
AvatarGuid = avatar.GameAvatar.Guid,
|
||||
AvatarEntityId = avatar.EntityId,
|
||||
WeaponEntityId = SceneController.WeaponEntityId,
|
||||
WeaponGuid = GameAvatar.WeaponGuid
|
||||
WeaponEntityId = avatar.WeaponEntityId,
|
||||
WeaponGuid = avatar.GameAvatar.WeaponGuid
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue