-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly implement CHEST_CLOSE and DOOR_CLOSE packets (#406)
* Remove JammedDoor tilespec type (not officially defined) * Implement locked/broken chest/door server packets (CHEST_CLOSE and DOOR_CLOSE)
- Loading branch information
1 parent
3e05b5a
commit d6542dc
Showing
16 changed files
with
179 additions
and
12 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
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
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,16 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.IO.Map; | ||
|
||
namespace EOLib.Domain.Notifiers | ||
{ | ||
public interface IDoorEventNotifier | ||
{ | ||
void NotifyDoorLocked(ChestKey key); | ||
} | ||
|
||
[AutoMappedType] | ||
public class NoOpDoorEventNotifier : IDoorEventNotifier | ||
{ | ||
public void NotifyDoorLocked(ChestKey key) { } | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Generic; | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Login; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.IO.Map; | ||
using EOLib.Net.Handlers; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net.Server; | ||
|
||
namespace EOLib.PacketHandlers.Door | ||
{ | ||
/// <summary> | ||
/// Sent when a door is locked | ||
/// </summary> | ||
[AutoMappedType] | ||
public class DoorCloseHandler : InGameOnlyPacketHandler<DoorCloseServerPacket> | ||
{ | ||
private readonly IEnumerable<IDoorEventNotifier> _doorEventNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Door; | ||
|
||
public override PacketAction Action => PacketAction.Close; | ||
|
||
public DoorCloseHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<IDoorEventNotifier> doorEventNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_doorEventNotifiers = doorEventNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(DoorCloseServerPacket packet) | ||
{ | ||
foreach (var notifier in _doorEventNotifiers) | ||
notifier.NotifyDoorLocked((ChestKey)packet.Key); | ||
|
||
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
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,58 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Audio; | ||
using EndlessClient.Dialogs; | ||
using EndlessClient.Dialogs.Factories; | ||
using EndlessClient.HUD; | ||
using EOLib.Domain.Map; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.IO.Map; | ||
using EOLib.Localization; | ||
|
||
namespace EndlessClient.Subscribers | ||
{ | ||
[AutoMappedType] | ||
public class ChestEventSubscriber : IChestEventNotifier | ||
{ | ||
private readonly IEOMessageBoxFactory _messageBoxFactory; | ||
private readonly IActiveDialogRepository _activeDialogRepository; | ||
private readonly ISfxPlayer _sfxPlayer; | ||
private readonly IUnlockChestValidator _unlockChestValidator; | ||
private readonly IStatusLabelSetter _statusLabelSetter; | ||
|
||
public ChestEventSubscriber(IEOMessageBoxFactory messageBoxFactory, | ||
IActiveDialogRepository activeDialogRepository, | ||
IUnlockChestValidator unlockChestValidator, | ||
IStatusLabelSetter statusLabelSetter, | ||
ISfxPlayer sfxPlayer) | ||
{ | ||
_messageBoxFactory = messageBoxFactory; | ||
_activeDialogRepository = activeDialogRepository; | ||
_unlockChestValidator = unlockChestValidator; | ||
_statusLabelSetter = statusLabelSetter; | ||
_sfxPlayer = sfxPlayer; | ||
} | ||
|
||
public void NotifyChestBroken() | ||
{ | ||
_activeDialogRepository.ChestDialog.MatchSome(x => x.Close()); | ||
|
||
var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.CHEST_BROKEN); | ||
dlg.ShowDialog(); | ||
|
||
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_THE_CHEST_SEEMS_BROKEN); | ||
} | ||
|
||
public void NotifyChestLocked(ChestKey key) | ||
{ | ||
_activeDialogRepository.ChestDialog.MatchSome(x => x.Close()); | ||
|
||
var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.CHEST_LOCKED); | ||
dlg.ShowDialog(); | ||
|
||
var requiredKey = _unlockChestValidator.GetRequiredKeyName(key); | ||
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_THE_CHEST_IS_LOCKED_EXCLAMATION, requiredKey.Match(x => $" - {x}", () => string.Empty)); | ||
|
||
_sfxPlayer.PlaySfx(SoundEffectID.DoorOrChestLocked); | ||
} | ||
} | ||
} |
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,39 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Audio; | ||
using EndlessClient.Dialogs.Factories; | ||
using EndlessClient.HUD; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.IO.Map; | ||
using EOLib.Localization; | ||
|
||
namespace EndlessClient.Subscribers | ||
{ | ||
[AutoMappedType] | ||
public class DoorEventSubscriber : IDoorEventNotifier | ||
{ | ||
private readonly IEOMessageBoxFactory _messageBoxFactory; | ||
private readonly ISfxPlayer _sfxPlayer; | ||
private readonly IStatusLabelSetter _statusLabelSetter; | ||
|
||
public DoorEventSubscriber(IEOMessageBoxFactory messageBoxFactory, | ||
IStatusLabelSetter statusLabelSetter, | ||
ISfxPlayer sfxPlayer) | ||
{ | ||
_messageBoxFactory = messageBoxFactory; | ||
_statusLabelSetter = statusLabelSetter; | ||
_sfxPlayer = sfxPlayer; | ||
} | ||
|
||
public void NotifyDoorLocked(ChestKey key) | ||
{ | ||
var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.DOOR_LOCKED); | ||
dlg.ShowDialog(); | ||
|
||
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, | ||
EOResourceID.STATUS_LABEL_THE_DOOR_IS_LOCKED_EXCLAMATION, | ||
$" - {key}"); | ||
|
||
_sfxPlayer.PlaySfx(SoundEffectID.DoorOrChestLocked); | ||
} | ||
} | ||
} |
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,11 @@ | ||
using EOLib.IO.Map; | ||
|
||
namespace EndlessClient.Subscribers | ||
{ | ||
public interface IChestEventSubscriber | ||
{ | ||
void NotifyChestBroken(); | ||
|
||
void NotifyChestLocked(ChestKey key); | ||
} | ||
} |