Skip to content

Commit

Permalink
Fix emote display when sitting
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed May 4, 2023
1 parent 4414a6b commit f447949
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
Expand Up @@ -87,8 +87,10 @@ public static CharacterRenderProperties WithNextEmoteFrame(this CharacterRenderP
{
var props = rp.ToBuilder();
props.EmoteFrame = (props.EmoteFrame + 1) % CharacterRenderProperties.MAX_NUMBER_OF_EMOTE_FRAMES;

var resetAction = props.SitState == SitState.Standing ? CharacterActionState.Standing : CharacterActionState.Sitting;
props.CurrentAction = props.EmoteFrame == 0
? CharacterActionState.Standing
? resetAction
: props.CurrentAction == CharacterActionState.Attacking // when using an instrument keep the current state as "Attacking"
? CharacterActionState.Attacking
: CharacterActionState.Emote;
Expand Down
2 changes: 1 addition & 1 deletion EndlessClient/Controllers/NumPadController.cs
Expand Up @@ -23,7 +23,7 @@ public class NumPadController : INumPadController

public void Emote(Emote whichEmote)
{
if (!_characterProvider.MainCharacter.RenderProperties.IsActing(CharacterActionState.Standing))
if (!_characterProvider.MainCharacter.RenderProperties.IsActing(CharacterActionState.Standing, CharacterActionState.Sitting))
return;

_characterActions.Emote(whichEmote);
Expand Down
3 changes: 2 additions & 1 deletion EndlessClient/Rendering/Character/CharacterAnimator.cs
Expand Up @@ -254,6 +254,7 @@ public bool Emote(int characterID, Emote whichEmote)
else
{
_currentMapStateRepository.UnknownPlayerIDs.Add(characterID);
return false;
}

_startEmoteTimes[characterID] = startEmoteTime;
Expand Down Expand Up @@ -536,7 +537,7 @@ private void AnimateCharacterEmotes()
var nextFrameRenderProperties = renderProperties.WithNextEmoteFrame();
pair.UpdateActionStartTime();
if (nextFrameRenderProperties.IsActing(CharacterActionState.Standing))
if (nextFrameRenderProperties.IsActing(CharacterActionState.Standing, CharacterActionState.Sitting))
playersDoneEmoting.Add(pair.UniqueID);
var nextFrameCharacter = currentCharacter.WithRenderProperties(nextFrameRenderProperties);
Expand Down
8 changes: 6 additions & 2 deletions EndlessClient/Rendering/CharacterProperties/FaceRenderer.cs
Expand Up @@ -35,8 +35,12 @@ public override void Render(SpriteBatch spriteBatch, Rectangle parentCharacterDr
return;

var skinLoc = _skinRenderLocationCalculator.CalculateDrawLocationOfCharacterSkin(_skinSheet.SourceRectangle, parentCharacterDrawArea);
var facePos = new Vector2(skinLoc.X + (_renderProperties.IsFacing(EODirection.Down) ? 2 : 3),
skinLoc.Y + (_renderProperties.Gender == 0 ? 2 : 0));

var adjustX = _renderProperties.IsFacing(EODirection.Down)
? _renderProperties.SitState == SitState.Standing ? 2 : 8
: 3;

var facePos = new Vector2(skinLoc.X + adjustX, skinLoc.Y + (_renderProperties.Gender == 0 ? 2 : 0));

Render(spriteBatch, _faceSheet, facePos);
}
Expand Down
Expand Up @@ -23,7 +23,8 @@ public class WeaponRenderer : BaseCharacterPropertyRenderer

public override void Render(SpriteBatch spriteBatch, Rectangle parentCharacterDrawArea)
{
if (_renderProperties.IsActing(CharacterActionState.Sitting, CharacterActionState.SpellCast))
if (_renderProperties.IsActing(CharacterActionState.Sitting, CharacterActionState.SpellCast) ||
(_renderProperties.CurrentAction == CharacterActionState.Emote && _renderProperties.SitState != SitState.Standing))
return;

var offsets = GetOffsets(parentCharacterDrawArea);
Expand Down
16 changes: 12 additions & 4 deletions EndlessClient/Rendering/Sprites/CharacterSpriteCalculator.cs
Expand Up @@ -31,7 +31,11 @@ public ISpriteSheet GetBootsTexture(CharacterRenderProperties characterRenderPro
return new EmptySpriteSheet();

var type = BootsSpriteType.Standing;
switch (characterRenderProperties.CurrentAction)
var currentAction = characterRenderProperties.CurrentAction;
if (currentAction == CharacterActionState.Emote && characterRenderProperties.SitState != SitState.Standing)
currentAction = CharacterActionState.Sitting;

switch (currentAction)
{
case CharacterActionState.Walking:
switch (characterRenderProperties.RenderWalkFrame)
Expand Down Expand Up @@ -71,7 +75,11 @@ public ISpriteSheet GetArmorTexture(CharacterRenderProperties characterRenderPro
return new EmptySpriteSheet();

var type = ArmorShieldSpriteType.Standing;
switch (characterRenderProperties.CurrentAction)
var currentAction = characterRenderProperties.CurrentAction;
if (currentAction == CharacterActionState.Emote && characterRenderProperties.SitState != SitState.Standing)
currentAction = CharacterActionState.Sitting;

switch (currentAction)
{
case CharacterActionState.Walking:
switch (characterRenderProperties.RenderWalkFrame)
Expand Down Expand Up @@ -172,7 +180,7 @@ public ISpriteSheet GetShieldTexture(CharacterRenderProperties characterRenderPr
{
type = ArmorShieldSpriteType.SpellCast;
}
else if(characterRenderProperties.CurrentAction == CharacterActionState.Sitting)
else if(characterRenderProperties.SitState != SitState.Standing)
{
return new EmptySpriteSheet();
}
Expand Down Expand Up @@ -298,7 +306,7 @@ public ISpriteSheet GetSkinTexture(CharacterRenderProperties characterRenderProp
{
gfxNum = 4;
}
else if (characterRenderProperties.CurrentAction == CharacterActionState.Sitting)
else if (characterRenderProperties.SitState != SitState.Standing)
{
if (characterRenderProperties.SitState == SitState.Floor) gfxNum = 6;
else if (characterRenderProperties.SitState == SitState.Chair) gfxNum = 5;
Expand Down

0 comments on commit f447949

Please sign in to comment.