Compare commits
2 commits
32b7c987bf
...
d6d7ca6e76
Author | SHA1 | Date | |
---|---|---|---|
d6d7ca6e76 | |||
e20c69f465 |
7 changed files with 97 additions and 17 deletions
|
@ -1,7 +1,6 @@
|
|||
using System.Collections.Immutable;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using GameServer.Controllers.Attributes;
|
||||
using GameServer.Network;
|
||||
using GameServer.Systems.Entity;
|
||||
|
@ -33,6 +32,45 @@ internal class CombatManager
|
|||
_creatureController = creatureController;
|
||||
}
|
||||
|
||||
[CombatRequest(CombatRequestData.MessageOneofCase.RTimeStopRequest)]
|
||||
public CombatResponseData OnRTimeStopRequest(CombatRequestContext context) => new()
|
||||
{
|
||||
CombatCommon = context.Request.CombatCommon,
|
||||
RTimeStopResponse = new()
|
||||
};
|
||||
|
||||
[CombatRequest(CombatRequestData.MessageOneofCase.ActivateBuffRequest)]
|
||||
public CombatResponseData OnActivateBuffRequest(CombatRequestContext context) => new()
|
||||
{
|
||||
CombatCommon = context.Request.CombatCommon,
|
||||
ActivateBuffResponse = new()
|
||||
};
|
||||
|
||||
[CombatRequest(CombatRequestData.MessageOneofCase.UseSkillRequest)]
|
||||
public CombatResponseData OnUseSkillRequest(CombatRequestContext context) => new()
|
||||
{
|
||||
CombatCommon = context.Request.CombatCommon,
|
||||
UseSkillResponse = new()
|
||||
{
|
||||
SkillSingleId = context.Request.UseSkillRequest.SkillSingleId,
|
||||
UseSkillInfo = context.Request.UseSkillRequest.UseSkillInfo
|
||||
}
|
||||
};
|
||||
|
||||
[CombatRequest(CombatRequestData.MessageOneofCase.ApplyGameplayEffectRequest)]
|
||||
public CombatResponseData OnApplyGameplayEffectRequest(CombatRequestContext context) => new()
|
||||
{
|
||||
CombatCommon = context.Request.CombatCommon,
|
||||
ApplyGameplayEffectResponse = new ApplyGameplayEffectResponse()
|
||||
};
|
||||
|
||||
[CombatRequest(CombatRequestData.MessageOneofCase.RemoveGameplayEffectRequest)]
|
||||
public CombatResponseData OnRemoveGameplayEffectRequest(CombatRequestContext context) => new()
|
||||
{
|
||||
CombatCommon = context.Request.CombatCommon,
|
||||
RemoveGameplayEffectResponse = new RemoveGameplayEffectResponse()
|
||||
};
|
||||
|
||||
[CombatRequest(CombatRequestData.MessageOneofCase.CreateBulletRequest)]
|
||||
public CombatResponseData OnCreateBulletRequest(CombatRequestContext context)
|
||||
{
|
||||
|
@ -209,12 +247,18 @@ internal class CombatManager
|
|||
if (entity.ComponentSystem.TryGet(out EntityFsmComponent? fsmComponent))
|
||||
{
|
||||
DFsm? dfsm = fsmComponent.Fsms.FirstOrDefault(fsm => fsm.FsmId == request.FsmId);
|
||||
dfsm ??= new()
|
||||
|
||||
if (dfsm == null)
|
||||
{
|
||||
FsmId = request.FsmId,
|
||||
Status = 1,
|
||||
Flag = (int)EFsmStateFlag.Confirmed
|
||||
};
|
||||
dfsm = new DFsm
|
||||
{
|
||||
FsmId = request.FsmId,
|
||||
Status = 1,
|
||||
Flag = (int)EFsmStateFlag.Confirmed
|
||||
};
|
||||
|
||||
fsmComponent.Fsms.Add(dfsm);
|
||||
}
|
||||
|
||||
dfsm.CurrentState = request.State;
|
||||
context.Notifies.Add(new CombatNotifyData
|
||||
|
|
|
@ -1,18 +1,44 @@
|
|||
using GameServer.Controllers.Attributes;
|
||||
using GameServer.Controllers.Combat;
|
||||
using GameServer.Models;
|
||||
using GameServer.Network;
|
||||
using GameServer.Network.Messages;
|
||||
using GameServer.Systems.Entity;
|
||||
using GameServer.Systems.Event;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Controllers;
|
||||
internal class CombatMessageController : Controller
|
||||
{
|
||||
public CombatMessageController(PlayerSession session) : base(session)
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public CombatMessageController(PlayerSession session, ILogger<CombatMessageController> logger) : base(session)
|
||||
{
|
||||
// CombatMessageController.
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[NetEvent(MessageId.CombatSendPackRequest)] // TODO: CombatSendPackRequest is important
|
||||
[NetEvent(MessageId.MovePackagePush)]
|
||||
public async Task OnMovePackagePush(MovePackagePush push, EntitySystem entitySystem, EventSystem eventSystem, ModelManager modelManager)
|
||||
{
|
||||
foreach (MovingEntityData movingEntityData in push.MovingEntities)
|
||||
{
|
||||
EntityBase? entity = entitySystem.Get<EntityBase>(movingEntityData.EntityId);
|
||||
if (entity == null)
|
||||
{
|
||||
_logger.LogWarning("OnMovePackagePush: moving entity not found! Id: {entityId}", movingEntityData.EntityId);
|
||||
continue;
|
||||
}
|
||||
|
||||
MoveReplaySample lastMoveReplay = movingEntityData.MoveInfos.Last();
|
||||
entity.Pos.MergeFrom(lastMoveReplay.Location);
|
||||
entity.Rot.MergeFrom(lastMoveReplay.Rotation);
|
||||
|
||||
if (entity.Id == modelManager.Creature.PlayerEntityId)
|
||||
await eventSystem.Emit(GameEventType.PlayerPositionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
[NetEvent(MessageId.CombatSendPackRequest)]
|
||||
public async Task<RpcResult> OnCombatSendPackRequest(CombatSendPackRequest request, CombatManager combatManager)
|
||||
{
|
||||
CombatReceivePackNotify combatPackNotify = new();
|
||||
|
|
|
@ -130,6 +130,12 @@ internal class CreatureController : Controller
|
|||
await UpdateAiHate();
|
||||
}
|
||||
|
||||
[GameEvent(GameEventType.PlayerPositionChanged)]
|
||||
public void OnPlayerPositionChanged()
|
||||
{
|
||||
_modelManager.Player.Position.MergeFrom(GetPlayerEntity()!.Pos);
|
||||
}
|
||||
|
||||
[GameEvent(GameEventType.VisionSkillChanged)]
|
||||
public async Task OnVisionSkillChanged()
|
||||
{
|
||||
|
@ -174,6 +180,9 @@ internal class CreatureController : Controller
|
|||
_modelManager.Creature.PlayerEntityId = newEntity.Id;
|
||||
newEntity.IsCurrentRole = true;
|
||||
|
||||
newEntity.Pos.MergeFrom(prevEntity.Pos);
|
||||
newEntity.Rot.MergeFrom(prevEntity.Rot);
|
||||
|
||||
await UpdateAiHate();
|
||||
}
|
||||
|
||||
|
@ -288,8 +297,9 @@ internal class CreatureController : Controller
|
|||
PlayerEntity concomitant = _entityFactory.CreatePlayer(roleId, 0);
|
||||
_entitySystem.Create(concomitant);
|
||||
|
||||
EntityConcomitantsComponent concomitants = entity.ComponentSystem.Get<EntityConcomitantsComponent>();
|
||||
EntityConcomitantsComponent concomitants = entity.ComponentSystem.Create<EntityConcomitantsComponent>();
|
||||
concomitants.CustomEntityIds.Clear();
|
||||
concomitants.VisionEntityId = concomitant.Id;
|
||||
concomitants.CustomEntityIds.Add(concomitant.Id);
|
||||
|
||||
EntitySummonerComponent summoner = concomitant.ComponentSystem.Create<EntitySummonerComponent>();
|
||||
|
@ -297,6 +307,7 @@ internal class CreatureController : Controller
|
|||
summoner.SummonConfigId = summonConfigId;
|
||||
summoner.SummonType = ESummonType.ConcomitantCustom;
|
||||
summoner.PlayerId = _modelManager.Player.Id;
|
||||
|
||||
concomitant.InitProps(_configManager.GetConfig<BasePropertyConfig>(roleId)!);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ internal class EntitySummonerComponent : EntityComponentBase
|
|||
Type = (int)SummonType,
|
||||
SummonerId = SummonerId,
|
||||
PlayerId = PlayerId,
|
||||
SummonSkillId = SummonSkillId
|
||||
SummonSkillId = SummonSkillId,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ internal abstract class EntityBase
|
|||
|
||||
public EntityState State { get; protected set; }
|
||||
|
||||
public bool IsConcomitant => ComponentSystem.TryGet<EntitySummonerComponent>(out _);
|
||||
|
||||
public EntityBase(long id)
|
||||
{
|
||||
Id = id;
|
||||
|
|
|
@ -37,10 +37,6 @@ internal class PlayerEntity : EntityBase
|
|||
{
|
||||
base.OnCreate();
|
||||
|
||||
// Should be created immediately
|
||||
EntityConcomitantsComponent concomitantsComponent = ComponentSystem.Create<EntityConcomitantsComponent>();
|
||||
concomitantsComponent.CustomEntityIds.Add(Id);
|
||||
|
||||
EntityVisionSkillComponent visionSkillComponent = ComponentSystem.Create<EntityVisionSkillComponent>();
|
||||
visionSkillComponent.SetExploreTool(1001);
|
||||
|
||||
|
@ -82,7 +78,7 @@ internal class PlayerEntity : EntityBase
|
|||
public override EEntityType Type => EEntityType.Player;
|
||||
public override EntityConfigType ConfigType => EntityConfigType.Character;
|
||||
|
||||
public override bool IsVisible => IsCurrentRole;
|
||||
public override bool IsVisible => IsCurrentRole || IsConcomitant;
|
||||
|
||||
public override EntityPb Pb
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ internal enum GameEventType
|
|||
PushDataDone,
|
||||
|
||||
// Actions
|
||||
PlayerPositionChanged,
|
||||
FormationUpdated,
|
||||
VisionSkillChanged,
|
||||
|
||||
|
|
Loading…
Reference in a new issue