Skip to content

Commit

Permalink
Add weapon slash rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Dec 18, 2023
1 parent 8d7188c commit cb22a81
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 84 deletions.
3 changes: 3 additions & 0 deletions EndlessClient/Rendering/Character/CharacterTextures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CharacterTextures : ICharacterTextures
public ISpriteSheet Shield { get; private set; }
public ISpriteSheet Weapon { get; private set; }
public ISpriteSheet WeaponExtra { get; private set; }
public ISpriteSheet WeaponSlash{ get; private set; }

public ISpriteSheet Hair { get; private set; }
public ISpriteSheet Skin { get; private set; }
Expand All @@ -38,6 +39,8 @@ public void Refresh(CharacterRenderProperties characterRenderProperties)
Weapon = weaponTextures[0];
WeaponExtra = weaponTextures[1];

WeaponSlash = _characterSpriteCalculator.GetWeaponSlash(characterRenderProperties);

Hair = _characterSpriteCalculator.GetHairTexture(characterRenderProperties);
Skin = _characterSpriteCalculator.GetSkinTexture(characterRenderProperties);
Emote = _characterSpriteCalculator.GetEmoteTexture(characterRenderProperties);
Expand Down
1 change: 1 addition & 0 deletions EndlessClient/Rendering/Character/ICharacterTextures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface ICharacterTextures
ISpriteSheet Shield { get; }
ISpriteSheet Weapon { get; }
ISpriteSheet WeaponExtra { get; }
ISpriteSheet WeaponSlash { get; }

ISpriteSheet Hair { get; }
ISpriteSheet Skin { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public IEnumerable<ICharacterPropertyRenderer> BuildList(ICharacterTextures text
{
LayerDepth = BaseLayer * (hatMaskType == HatMaskType.FaceMask ? 11 : 10)
};

yield return new WeaponSlashRenderer(renderProperties, textures.WeaponSlash) { LayerDepth = BaseLayer * 14 };
}

private bool IsShieldBehindCharacter(CharacterRenderProperties renderProperties)
Expand Down
46 changes: 46 additions & 0 deletions EndlessClient/Rendering/CharacterProperties/WeaponSlashRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using EndlessClient.Rendering.Metadata.Models;
using EndlessClient.Rendering.Sprites;
using EOLib;
using EOLib.Domain.Character;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace EndlessClient.Rendering.CharacterProperties
{
public class WeaponSlashRenderer : BaseCharacterPropertyRenderer
{
private readonly ISpriteSheet _slashSheet;

public override bool CanRender => _slashSheet.HasTexture && _renderProperties.WeaponGraphic != 0 && _renderProperties.RenderAttackFrame == 2;

protected override bool ShouldFlip => false;

public WeaponSlashRenderer(CharacterRenderProperties renderProperties,
ISpriteSheet slashSheet)
: base(renderProperties)
{
_slashSheet = slashSheet;
}

public override void Render(SpriteBatch spriteBatch, Rectangle parentCharacterDrawArea, WeaponMetadata weaponMetadata)
{
if (weaponMetadata.Slash == null || weaponMetadata.Ranged)
return;

var offsets = GetOffsets(parentCharacterDrawArea) - new Vector2(0, _renderProperties.Gender);
Render(spriteBatch, _slashSheet, parentCharacterDrawArea.Location.ToVector2() + offsets, 96);
}

private Vector2 GetOffsets(Rectangle parentCharacterDrawArea)
{
return _renderProperties.Direction switch
{
EODirection.Down => new Vector2(-30, 4),
EODirection.Left => new Vector2(-34, -9),
EODirection.Up => new Vector2(-6, -9),
EODirection.Right => new Vector2(-10, 4),
_ => Vector2.Zero
};
}
}
}
150 changes: 75 additions & 75 deletions EndlessClient/Rendering/Metadata/WeaponMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,81 +17,81 @@ public WeaponMetadataProvider(IGFXMetadataLoader metadataLoader)
{
_metadata = new Dictionary<int, WeaponMetadata>
{
{ 0, new WeaponMetadata( null, new[] { SoundEffectID.PunchAttack }, false) }, // fist
{ 1, new WeaponMetadata( 3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // wood axe
{ 2, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // sai
{ 3, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // dragon blade
{ 4, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // dagger
{ 5, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // spear
{ 6, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // saber
{ 7, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // staff
{ 8, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // book
{ 9, new WeaponMetadata( 3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // mace
{ 10, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // spirit star
{ 11, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // throw axe
{ 12, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // dark katana
{ 13, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // short sword
{ 14, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // broadsword
{ 15, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // broom
{ 16, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ninchackus
{ 17, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ancient star
{ 18, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // battle axe
{ 19, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ancient sword
{ 20, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // luna staff
{ 21, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lance
{ 22, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // aura staff
{ 23, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // forest staff
{ 24, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // normal sword
{ 25, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // jewel staff
{ 26, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // thor's hammer
{ 27, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // light katana
{ 28, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // polearm
{ 29, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // sickle
{ 30, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // trident
{ 31, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // warlock sword
{ 32, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // whip
{ 33, new WeaponMetadata( 5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ultima
{ 34, new WeaponMetadata( 5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ice blade
{ 35, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // gold defender
{ 36, new WeaponMetadata( 4, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lotus sword
{ 37, new WeaponMetadata( 4, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // cristal sword
{ 38, new WeaponMetadata( 5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // killing edge
{ 39, new WeaponMetadata( 7, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // dark blade
{ 40, new WeaponMetadata( 7, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // reaper scyth
{ 41, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // crescent staff
{ 42, new WeaponMetadata( 0, new[] { SoundEffectID.AttackBow }, true) }, // bow
{ 43, new WeaponMetadata( 0, new[] { SoundEffectID.AttackBow }, true) }, // xbow
{ 44, new WeaponMetadata( 8, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // reaper
{ 45, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // hockey stick
{ 46, new WeaponMetadata( 5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // twin blades
{ 47, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lefor mace
{ 48, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // cava staff
{ 49, new WeaponMetadata( 0, new[] { SoundEffectID.Harp1,SoundEffectID.Harp2,SoundEffectID.Harp3}, true) }, // harp
{ 50, new WeaponMetadata( 0, new[] { SoundEffectID.Guitar1,SoundEffectID.Guitar2, SoundEffectID.Guitar3 }, true) }, // guitar
{ 51, new WeaponMetadata( 5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // battle spear
{ 52, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // flail
{ 53, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // war axe
{ 54, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // gastro
{ 55, new WeaponMetadata( 7, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // ablo staff
{ 56, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // fluon sword
{ 57, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // rapier
{ 58, new WeaponMetadata( 0, new[] { SoundEffectID.Gun }, true) }, // gun
{ 59, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // knob staff
{ 60, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // fladdat staff
{ 61, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // gabrasto
{ 62, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // battle spear 2
{ 63, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lens of truth
{ 64, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // chopper
{ 65, new WeaponMetadata( 3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // adger
{ 66, new WeaponMetadata( 1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // chains
{ 67, new WeaponMetadata( 2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // mitova
{ 68, new WeaponMetadata( 3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // merhawk
{ 69, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // kontra
{ 70, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // jack spear
{ 71, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // bazar staff
{ 72, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // saw blade
{ 73, new WeaponMetadata( 0, new[] { SoundEffectID.AttackBow }, true) }, // scav bow
{ 74, new WeaponMetadata( 0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // fan
{ 0, new WeaponMetadata(null, new[] { SoundEffectID.PunchAttack }, false) }, // fist
{ 1, new WeaponMetadata(3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // wood axe
{ 2, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // sai
{ 3, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // dragon blade
{ 4, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // dagger
{ 5, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // spear
{ 6, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // saber
{ 7, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // staff
{ 8, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // book
{ 9, new WeaponMetadata(3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // mace
{ 10, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // spirit star
{ 11, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // throw axe
{ 12, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // dark katana
{ 13, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // short sword
{ 14, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // broadsword
{ 15, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // broom
{ 16, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ninchackus
{ 17, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ancient star
{ 18, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // battle axe
{ 19, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ancient sword
{ 20, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // luna staff
{ 21, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lance
{ 22, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // aura staff
{ 23, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // forest staff
{ 24, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // normal sword
{ 25, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // jewel staff
{ 26, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // thor's hammer
{ 27, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // light katana
{ 28, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // polearm
{ 29, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // sickle
{ 30, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // trident
{ 31, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // warlock sword
{ 32, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // whip
{ 33, new WeaponMetadata(5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ultima
{ 34, new WeaponMetadata(5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // ice blade
{ 35, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // gold defender
{ 36, new WeaponMetadata(4, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lotus sword
{ 37, new WeaponMetadata(4, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // cristal sword
{ 38, new WeaponMetadata(5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // killing edge
{ 39, new WeaponMetadata(7, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // dark blade
{ 40, new WeaponMetadata(7, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // reaper scyth
{ 41, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // crescent staff
{ 42, new WeaponMetadata(0, new[] { SoundEffectID.AttackBow }, true) }, // bow
{ 43, new WeaponMetadata(0, new[] { SoundEffectID.AttackBow }, true) }, // xbow
{ 44, new WeaponMetadata(8, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // reaper
{ 45, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // hockey stick
{ 46, new WeaponMetadata(5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // twin blades
{ 47, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lefor mace
{ 48, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // cava staff
{ 49, new WeaponMetadata(0, new[] { SoundEffectID.Harp1,SoundEffectID.Harp2,SoundEffectID.Harp3}, true) }, // harp
{ 50, new WeaponMetadata(0, new[] { SoundEffectID.Guitar1,SoundEffectID.Guitar2, SoundEffectID.Guitar3 }, true) }, // guitar
{ 51, new WeaponMetadata(5, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // battle spear
{ 52, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // flail
{ 53, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // war axe
{ 54, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // gastro
{ 55, new WeaponMetadata(7, new[] { SoundEffectID.AlternateMeleeAttack }, false) }, // ablo staff
{ 56, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // fluon sword
{ 57, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // rapier
{ 58, new WeaponMetadata(0, new[] { SoundEffectID.Gun }, true) }, // gun
{ 59, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // knob staff
{ 60, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // fladdat staff
{ 61, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // gabrasto
{ 62, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // battle spear 2
{ 63, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // lens of truth
{ 64, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // chopper
{ 65, new WeaponMetadata(3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // adger
{ 66, new WeaponMetadata(1, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // chains
{ 67, new WeaponMetadata(2, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // mitova
{ 68, new WeaponMetadata(3, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // merhawk
{ 69, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // kontra
{ 70, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // jack spear
{ 71, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // bazar staff
{ 72, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // saw blade
{ 73, new WeaponMetadata(0, new[] { SoundEffectID.AttackBow }, true) }, // scav bow
{ 74, new WeaponMetadata(0, new[] { SoundEffectID.MeleeWeaponAttack }, false) }, // fan
};
_metadataLoader = metadataLoader;
}
Expand Down
Loading

0 comments on commit cb22a81

Please sign in to comment.