Skip to content

Commit

Permalink
Add SFX for sit when receiving SIT_REPLY or CHAIR_REPLY packet (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat authored Nov 5, 2024
1 parent 795c324 commit caad8e7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 14 deletions.
2 changes: 2 additions & 0 deletions EOBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public void JunkItem(int id, int amountRemoved)
}

public void NotifyFrozen() { }

public void NotifySit() { }
}

[AutoMappedType]
Expand Down
4 changes: 4 additions & 0 deletions EOLib/Domain/Notifiers/IMainCharacterEventNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface IMainCharacterEventNotifier
void JunkItem(int id, int amountRemoved);

void NotifyFrozen();

void NotifySit();
}

[AutoMappedType]
Expand All @@ -32,5 +34,7 @@ public void DropItem(int id, int amountDropped) { }
public void JunkItem(int id, int amountTaken) { }

public void NotifyFrozen() { }

public void NotifySit() { }
}
}
21 changes: 17 additions & 4 deletions EOLib/PacketHandlers/Chair/ChairReplyHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using AutomaticTypeMapper;
using System.Collections;
using System.Collections.Generic;
using AutomaticTypeMapper;
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using EOLib.Domain.Map;
using EOLib.Domain.Notifiers;
using EOLib.PacketHandlers.Sit;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
Expand All @@ -14,18 +17,28 @@ namespace EOLib.PacketHandlers.Chair
[AutoMappedType]
public class ChairReplyHandler : PlayerSitHandlerBase<ChairReplyServerPacket>
{
private readonly IEnumerable<IMainCharacterEventNotifier> _mainCharacterEventNotifiers;

public override PacketFamily Family => PacketFamily.Chair;

public override PacketAction Action => PacketAction.Reply;

public ChairReplyHandler(IPlayerInfoProvider playerInfoProvider,
ICharacterRepository characterRepository,
ICurrentMapStateRepository currentMapStateRepository)
: base(playerInfoProvider, characterRepository, currentMapStateRepository) { }
ICharacterRepository characterRepository,
ICurrentMapStateRepository currentMapStateRepository,
IEnumerable<IMainCharacterEventNotifier> mainCharacterEventNotifiers)
: base(playerInfoProvider, characterRepository, currentMapStateRepository)
{
_mainCharacterEventNotifiers = mainCharacterEventNotifiers;
}

public override bool HandlePacket(ChairReplyServerPacket packet)
{
Handle(packet.PlayerId, packet.Coords.X, packet.Coords.Y, (EODirection)packet.Direction);

foreach (var notifier in _mainCharacterEventNotifiers)
notifier.NotifySit();

return true;
}
}
Expand Down
20 changes: 16 additions & 4 deletions EOLib/PacketHandlers/Sit/SitReplyHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using AutomaticTypeMapper;
using System.Collections.Generic;
using AutomaticTypeMapper;
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using EOLib.Domain.Map;
using EOLib.Domain.Notifiers;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;

Expand All @@ -13,18 +15,28 @@ namespace EOLib.PacketHandlers.Sit
[AutoMappedType]
public class SitReplyHandler : PlayerSitHandlerBase<SitReplyServerPacket>
{
private readonly IEnumerable<IMainCharacterEventNotifier> _mainCharacterEventNotifiers;

public override PacketFamily Family => PacketFamily.Sit;

public override PacketAction Action => PacketAction.Reply;

public SitReplyHandler(IPlayerInfoProvider playerInfoProvider,
ICharacterRepository characterRepository,
ICurrentMapStateRepository currentMapStateRepository)
: base(playerInfoProvider, characterRepository, currentMapStateRepository) { }
ICharacterRepository characterRepository,
ICurrentMapStateRepository currentMapStateRepository,
IEnumerable<IMainCharacterEventNotifier> mainCharacterEventNotifiers)
: base(playerInfoProvider, characterRepository, currentMapStateRepository)
{
_mainCharacterEventNotifiers = mainCharacterEventNotifiers;
}

public override bool HandlePacket(SitReplyServerPacket packet)
{
Handle(packet.PlayerId, packet.Coords.X, packet.Coords.Y, (EODirection)packet.Direction);

foreach (var notifier in _mainCharacterEventNotifiers)
notifier.NotifySit();

return true;
}
}
Expand Down
1 change: 1 addition & 0 deletions EndlessClient/Audio/SoundEffectID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum SoundEffectID
UnknownWarpSound,
PrivateMessageTargetNotFound = 12,
HudStatusBarClick,
Sit = HudStatusBarClick,
AdminAnnounceReceived,
MeleeWeaponAttack,
MemberLeftParty = 16,
Expand Down
2 changes: 0 additions & 2 deletions EndlessClient/GameExecution/EndlessGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;



#if DEBUG
using System.Diagnostics;
using MonoGame.Extended.BitmapFonts;
Expand Down
7 changes: 3 additions & 4 deletions EndlessClient/Subscribers/MainCharacterEventSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ public void JunkItem(int id, int amountRemoved)
$" {amountRemoved} {rec.Name}");
}

public void NotifyFrozen()
{
_sfxPlayer.PlaySfx(SoundEffectID.PlayerFrozen);
}
public void NotifyFrozen() => _sfxPlayer.PlaySfx(SoundEffectID.PlayerFrozen);

public void NotifySit() => _sfxPlayer.PlaySfx(SoundEffectID.Sit);
}
}

0 comments on commit caad8e7

Please sign in to comment.