Skip to content

Commit

Permalink
Ensure spell cast shout stops when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Apr 18, 2022
1 parent b48ed13 commit e57aadb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void Face(EODirection direction)
if (!_hudControlProvider.IsInGame)
return;

CancelSpellPrep();
Animator.MainCharacterFace(direction);
}

Expand All @@ -60,6 +61,7 @@ public void StartWalking()
if (!_hudControlProvider.IsInGame)
return;

CancelSpellPrep();
Animator.StartMainCharacterWalkAnimation(Option.None<MapCoordinate>());
ShowWaterSplashiesIfNeeded(CharacterActionState.Walking, _characterRepository.MainCharacter.ID);
}
Expand All @@ -69,6 +71,7 @@ public void StartAttacking()
if (!_hudControlProvider.IsInGame)
return;

CancelSpellPrep();
Animator.StartMainCharacterAttackAnimation();
ShowWaterSplashiesIfNeeded(CharacterActionState.Attacking, _characterRepository.MainCharacter.ID);
}
Expand Down Expand Up @@ -237,6 +240,12 @@ private void ShowWaterSplashiesIfNeeded(CharacterActionState action, int charact
});
}

private void CancelSpellPrep()
{
Animator.MainCharacterCancelSpellPrep();
_characterRendererProvider.MainCharacterRenderer.MatchSome(r => r.StopShout());
}

private ICharacterAnimator Animator => _hudControlProvider.GetComponent<ICharacterAnimator>(HudControlIdentifier.CharacterAnimator);
}

Expand Down
6 changes: 0 additions & 6 deletions EndlessClient/Rendering/Character/CharacterAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public override void Update(GameTime gameTime)

public void MainCharacterFace(EODirection direction)
{
MainCharacterCancelSpellPrep();

if (_otherPlayerStartWalkingTimes.ContainsKey(_characterRepository.MainCharacter.ID))
{
_queuedDirections[_characterRepository.MainCharacter.ID] = direction;
Expand All @@ -102,8 +100,6 @@ public void MainCharacterFace(EODirection direction)

public void StartMainCharacterWalkAnimation(Option<MapCoordinate> targetCoordinate)
{
MainCharacterCancelSpellPrep();

_walkPath.Clear();
targetCoordinate.MatchSome(tc =>
{
Expand Down Expand Up @@ -135,8 +131,6 @@ public void StartMainCharacterWalkAnimation(Option<MapCoordinate> targetCoordina

public void StartMainCharacterAttackAnimation()
{
MainCharacterCancelSpellPrep();

if (_otherPlayerStartAttackingTimes.ContainsKey(_characterRepository.MainCharacter.ID))
{
_otherPlayerStartAttackingTimes[_characterRepository.MainCharacter.ID].Replay = true;
Expand Down
14 changes: 7 additions & 7 deletions EndlessClient/Rendering/Character/CharacterRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,7 @@ private void UpdateNameLabel(GameTime gameTime)

if (_spellCastTime.HasValue && (DateTime.Now - _spellCastTime.Value).TotalMilliseconds >= 600)
{
_nameLabel.Visible = false;
_nameLabel.Text = _character.Name;
_nameLabel.ForeColor = Color.White;
_nameLabel.BlinkRate = null;
_shoutName = string.Empty;
_spellCastTime = null;
StopShout();
}

_nameLabel.DrawPosition = GetNameLabelPosition();
Expand Down Expand Up @@ -461,9 +456,14 @@ public void ShoutSpellCast()
}

// Called when the shout (spell prep time) should be cancelled without casting
public void StopShoutingSpell()
public void StopShout()
{
_nameLabel.Visible = false;
_nameLabel.Text = _character.Name;
_nameLabel.ForeColor = Color.White;
_nameLabel.BlinkRate = null;
_shoutName = string.Empty;
_spellCastTime = null;
}

public void ShowDamageCounter(int damage, int percentHealth, bool isHeal)
Expand Down
2 changes: 2 additions & 0 deletions EndlessClient/Rendering/Character/ISpellCaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ public interface ISpellCaster
void ShoutSpellPrep(string spellName);

void ShoutSpellCast();

void StopShout();
}
}
2 changes: 2 additions & 0 deletions EndlessClient/Rendering/Map/MapChangedActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ private void StopAllAnimations()

private void ClearCharacterRenderersAndCache()
{
_characterRendererRepository.MainCharacterRenderer.MatchSome(x => x.StopShout());

foreach (var characterRenderer in _characterRendererRepository.CharacterRenderers)
characterRenderer.Value.Dispose();
_characterRendererRepository.CharacterRenderers.Clear();
Expand Down

0 comments on commit e57aadb

Please sign in to comment.