Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for bard music. Player can click to play harp/guitar note…
…s, and notes played by other players will be played.
- Loading branch information
1 parent
bfb045f
commit aafaa13
Showing
13 changed files
with
237 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ public enum Emote | |
/// <summary> | ||
/// 0 key | ||
/// </summary> | ||
Playful = 14 | ||
Playful = 14, | ||
MusicNotes = 15, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.IO; | ||
using EOLib.IO.Repositories; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
using Optional.Collections; | ||
using System; | ||
|
||
namespace EOLib.Domain.Jukebox | ||
{ | ||
[AutoMappedType] | ||
public class JukeboxActions : IJukeboxActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
private readonly ICharacterProvider _characterProvider; | ||
private readonly IEIFFileProvider _eifFileProvider; | ||
|
||
public JukeboxActions(IPacketSendService packetSendService, | ||
ICharacterProvider characterProvider, | ||
IEIFFileProvider eifFileProvider) | ||
{ | ||
_packetSendService = packetSendService; | ||
_characterProvider = characterProvider; | ||
_eifFileProvider = eifFileProvider; | ||
} | ||
|
||
public void PlayNote(int noteIndex) | ||
{ | ||
if (noteIndex < 0 || noteIndex >= 36) | ||
throw new ArgumentOutOfRangeException(nameof(noteIndex)); | ||
|
||
var weapon = _characterProvider.MainCharacter.RenderProperties.WeaponGraphic; | ||
_eifFileProvider.EIFFile.SingleOrNone(x => x.Type == ItemType.Weapon && x.DollGraphic == weapon) | ||
.MatchSome(rec => | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.JukeBox, PacketAction.Use) | ||
.AddChar((byte)rec.DollGraphic) // todo: determine what GameServer expects; eoserv sends DollGraphic as a response in Character::PlayBard | ||
.AddChar((byte)(noteIndex + 1)) | ||
.Build(); | ||
_packetSendService.SendPacket(packet); | ||
}); | ||
} | ||
} | ||
|
||
public interface IJukeboxActions | ||
{ | ||
void PlayNote(int noteIndex); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Login; | ||
using EOLib.Domain.Map; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.PacketHandlers.Jukebox | ||
{ | ||
[AutoMappedType] | ||
public class JukeboxMessageHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterRepository _characterRepository; | ||
private readonly ICurrentMapStateRepository _currentMapStateRepository; | ||
private readonly IEnumerable<IMainCharacterEventNotifier> _mainCharacterEventNotifiers; | ||
private readonly IEnumerable<IOtherCharacterAnimationNotifier> _otherCharacterAnimationNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.JukeBox; | ||
|
||
public override PacketAction Action => PacketAction.Message; | ||
|
||
public JukeboxMessageHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICurrentMapStateRepository currentMapStateRepository, | ||
IEnumerable<IOtherCharacterAnimationNotifier> otherCharacterAnimationNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_currentMapStateRepository = currentMapStateRepository; | ||
_otherCharacterAnimationNotifiers = otherCharacterAnimationNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var playerId = packet.ReadShort(); | ||
var direction = (EODirection)packet.ReadChar(); | ||
var instrument = packet.ReadChar(); | ||
var note = packet.ReadChar(); | ||
|
||
if (_currentMapStateRepository.Characters.ContainsKey(playerId)) | ||
{ | ||
var c = _currentMapStateRepository.Characters[playerId]; | ||
|
||
if (c.RenderProperties.WeaponGraphic == instrument) | ||
{ | ||
c = c.WithRenderProperties(c.RenderProperties.WithDirection(direction)); | ||
_currentMapStateRepository.Characters[playerId] = c; | ||
|
||
foreach (var notifier in _otherCharacterAnimationNotifiers) | ||
notifier.StartOtherCharacterAttackAnimation(playerId, note - 1); | ||
} | ||
} | ||
else | ||
{ | ||
_currentMapStateRepository.UnknownPlayerIDs.Add(playerId); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.