Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,18 @@ private void PerformSkill(ActionType actionType, SkillTriggerStyle triggerStyle,

if (GetActionRequestForTarget(hitTransform, actionType, triggerStyle, out ActionRequestData playerAction))
{
//Don't trigger our move logic for another 500ms. This protects us from moving just because we clicked on them to target them.
//Don't trigger our move logic for a while. This protects us from moving just because we clicked on them to target them.
m_LastSentMove = Time.time + k_TargetMoveTimeout;

ActionInputEvent?.Invoke(playerAction);
m_NetworkCharacter.RecvDoActionServerRPC(playerAction);
}
else if(actionType != ActionType.GeneralTarget )
{
// clicked on nothing... perform a "miss" attack on the spot they clicked on
// clicked on nothing... perform an "untargeted" attack on the spot they clicked on.
// (Different Actions will deal with this differently. For some, like archer arrows, this will fire an arrow
// in the desired direction. For others, like mage's bolts, this will fire a "miss" projectile at the spot clicked on.)

var data = new ActionRequestData();
PopulateSkillRequest(k_CachedHit[0].point, actionType, ref data);

Expand Down
10 changes: 10 additions & 0 deletions Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class ActionPlayer
{
private ServerCharacter m_Parent;

private ServerCharacterMovement m_Movement;

private List<Action> m_Queue;

private List<Action> m_NonBlockingActions;
Expand All @@ -30,6 +32,7 @@ public class ActionPlayer
public ActionPlayer(ServerCharacter parent)
{
m_Parent = parent;
m_Movement = parent.GetComponent<ServerCharacterMovement>();
m_Queue = new List<Action>();
m_NonBlockingActions = new List<Action>();
m_LastUsedTimestamps = new Dictionary<ActionType, float>();
Expand Down Expand Up @@ -134,6 +137,13 @@ private void StartAction()
return; // ... so it's important not to try to do anything more here
}

// if this Action is interruptible, that means movement should interrupt it... character needs to be stationary for this!
// So stop any movement that's already happening before we begin
if (m_Queue[0].Description.ActionInterruptible && !m_Movement.IsPerformingForcedMovement())
{
m_Movement.CancelMove();
}

// remember that we successfully used this Action!
m_LastUsedTimestamps[m_Queue[0].Description.ActionTypeEnum] = Time.time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public override bool Start()
{
m_Parent.NetState.RecvDoActionClientRPC(Data);

// not allowed to walk while going stealthy!
var movement = m_Parent.GetComponent<ServerCharacterMovement>();
if (!movement.IsPerformingForcedMovement())
{
movement.CancelMove();
}
return true;
}

Expand Down
25 changes: 14 additions & 11 deletions Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,18 @@ private void OnClientMoveRequest(Vector3 targetPosition)
{
if (NetState.NetworkLifeState.Value == LifeState.Alive && !m_Movement.IsPerformingForcedMovement())
{
ClearActions(false);
// if we're currently playing an interruptible action, interrupt it!
if (m_ActionPlayer.GetActiveActionInfo(out ActionRequestData data))
{
if (GameDataSource.Instance.ActionDataByType.TryGetValue(data.ActionTypeEnum, out ActionDescription description))
{
if (description.ActionInterruptible)
{
m_ActionPlayer.ClearActions(false);
}
}
}

m_ActionPlayer.CancelRunningActionsByLogic(ActionLogic.Target, true); //clear target on move.
m_Movement.SetMovementTarget(targetPosition);
}
Expand All @@ -118,19 +129,11 @@ private void OnLifeStateChanged(LifeState prevLifeState, LifeState lifeState)
{
if (lifeState != LifeState.Alive)
{
ClearActions(true);
m_ActionPlayer.ClearActions(true);
m_Movement.CancelMove();
}
}

/// <summary>
/// Clear all active Actions.
/// </summary>
public void ClearActions(bool alsoClearNonBlockingActions)
{
m_ActionPlayer.ClearActions(alsoClearNonBlockingActions);
}

private void OnActionPlayRequest(ActionRequestData data)
{
if (!GameDataSource.Instance.ActionDataByType[data.ActionTypeEnum].IsFriendly)
Expand Down Expand Up @@ -185,7 +188,7 @@ public void ReceiveHP(ServerCharacter inflicter, int HP)
//that's handled by a separate function.
if (NetState.HitPoints <= 0)
{
ClearActions(false);
m_ActionPlayer.ClearActions(false);

if (IsNpc)
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/BossRoom/Scripts/Shared/Data/ActionDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ActionDescription : ScriptableObject
[Tooltip("Prefab to spawn that will manage this action's input")]
public BaseActionInput ActionInput;

[Tooltip("Is this Action interruptible by other action plays. Generally, actions with short exec times should not be interruptible in this way.")]
[Tooltip("Is this Action interruptible by other action-plays or by movement? (Implicitly stops movement when action starts.) Generally, actions with short exec times should not be interruptible in this way.")]
public bool ActionInterruptible;

[System.Serializable]
Expand Down