-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from Kaioru/feat/quests
Implement basic quest handling
- Loading branch information
Showing
106 changed files
with
2,446 additions
and
328 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
13 changes: 8 additions & 5 deletions
13
src/common/Edelstein.Common.Gameplay.Game/Conversations/FallbackConversation.cs
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 |
---|---|---|
@@ -1,17 +1,20 @@ | ||
using Edelstein.Protocol.Gameplay.Game.Conversations; | ||
using Edelstein.Protocol.Gameplay.Game.Conversations.Speakers; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.User; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Conversations; | ||
|
||
public class FallbackConversation : IConversation | ||
{ | ||
private readonly string _name; | ||
private readonly IFieldUser _user; | ||
|
||
public FallbackConversation(string name) => _name = name; | ||
|
||
public Task Start(IConversationContext ctx, IConversationSpeaker self, IConversationSpeaker target) | ||
public FallbackConversation(string name, IFieldUser user) | ||
{ | ||
self.Say($"The scripted conversation '{_name}' is not available"); | ||
return Task.CompletedTask; | ||
_name = name; | ||
_user = user; | ||
} | ||
|
||
public Task Start(IConversationContext ctx, IConversationSpeaker self, IConversationSpeaker target) | ||
=> _user.Message($"The scripted conversation '{_name}' is not available"); | ||
} |
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
92 changes: 92 additions & 0 deletions
92
src/common/Edelstein.Common.Gameplay.Game/GameStageUserExtensions.cs
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,92 @@ | ||
using Edelstein.Common.Gameplay.Packets; | ||
using Edelstein.Common.Gameplay.Social; | ||
using Edelstein.Common.Utilities.Packets; | ||
using Edelstein.Protocol.Gameplay.Game; | ||
using Edelstein.Protocol.Services.Social.Contracts; | ||
|
||
namespace Edelstein.Common.Gameplay.Game; | ||
|
||
public static class GameStageUserExtensions | ||
{ | ||
public static Task DispatchInitFuncKeys(this IGameStageUser user) | ||
{ | ||
var p = new PacketWriter(PacketSendOperations.FuncKeyMappedInit); | ||
|
||
p.WriteBool(user.Character?.FuncKeys.Records.Count == 0); | ||
if (user.Character?.FuncKeys.Records.Count > 0) | ||
{ | ||
for (byte i = 0; i < 90; i++) | ||
{ | ||
if (user.Character.FuncKeys.Records.TryGetValue(i, out var value)) | ||
{ | ||
p.WriteByte(value.Type); | ||
p.WriteInt(value.Action); | ||
} | ||
else | ||
{ | ||
p.WriteByte(0); | ||
p.WriteInt(0); | ||
} | ||
} | ||
} | ||
|
||
return user.Dispatch(p.Build()); | ||
} | ||
|
||
public static Task DispatchInitQuickSlotKeys(this IGameStageUser user) | ||
{ | ||
var p = new PacketWriter(PacketSendOperations.QuickslotMappedInit); | ||
|
||
p.WriteBool(user.Character?.QuickslotKeys.Records.Count > 0); | ||
if (user.Character?.QuickslotKeys.Records.Count > 0) | ||
for (byte i = 0; i < 8; i++) | ||
p.WriteInt(user.Character.QuickslotKeys.Records.TryGetValue(i, out var value) | ||
? value | ||
: 0 | ||
); | ||
return user.Dispatch(p.Build()); | ||
} | ||
|
||
public async static Task DispatchInitFriends(this IGameStageUser user) | ||
{ | ||
if (user.Friends != null) | ||
{ | ||
var p = new PacketWriter(PacketSendOperations.FriendResult); | ||
|
||
p.WriteByte((byte)FriendResultOperations.LoadFriend_Done); | ||
p.WriteByte((byte)user.Friends.Records.Count); | ||
foreach (var record in user.Friends.Records.Values) | ||
p.WriteFriendInfo(record); | ||
foreach (var _ in user.Friends.Records.Values) | ||
p.WriteInt(0); | ||
await user.Dispatch(p.Build()); | ||
} | ||
} | ||
|
||
public async static Task DispatchInitParty(this IGameStageUser user) | ||
{ | ||
if (user.Party != null) | ||
{ | ||
var p = new PacketWriter(PacketSendOperations.PartyResult); | ||
p.WriteByte((byte)PartyResultOperations.LoadPartyDone); | ||
p.WriteInt(user.Party.ID); | ||
p.WritePartyInfo(user.Party); | ||
await user.Dispatch(p.Build()); | ||
} | ||
} | ||
|
||
public async static Task DispatchInitQuestTime(this IGameStageUser user) | ||
{ | ||
var records = await user.Context.Managers.QuestTime.RetrieveAll(); | ||
var p = new PacketWriter(PacketSendOperations.SetQuestTime); | ||
|
||
p.WriteByte((byte)records.Count); | ||
foreach (var record in records) | ||
{ | ||
p.WriteInt(record.ID); | ||
p.WriteDateTime(record.DateStart); | ||
p.WriteDateTime(record.DateEnd); | ||
} | ||
await user.Dispatch(p.Build()); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/common/Edelstein.Common.Gameplay.Game/Handlers/UserPortalScriptRequestHandler.cs
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,25 @@ | ||
using Edelstein.Common.Gameplay.Packets; | ||
using Edelstein.Common.Utilities.Packets; | ||
using Edelstein.Protocol.Gameplay.Game.Contracts; | ||
using Edelstein.Protocol.Gameplay.Game.Objects.User; | ||
using Edelstein.Protocol.Utilities.Packets; | ||
using Edelstein.Protocol.Utilities.Pipelines; | ||
|
||
namespace Edelstein.Common.Gameplay.Game.Handlers; | ||
|
||
public class UserPortalScriptRequestHandler : AbstractPipedFieldHandler<FieldOnPacketUserPortalScriptRequest> | ||
{ | ||
|
||
public UserPortalScriptRequestHandler(IPipeline<FieldOnPacketUserPortalScriptRequest> pipeline) : base(pipeline) | ||
{ | ||
} | ||
|
||
public override short Operation => (short)PacketRecvOperations.UserPortalScriptRequest; | ||
|
||
protected override FieldOnPacketUserPortalScriptRequest? Serialize(IFieldUser user, IPacketReader reader) | ||
=> new( | ||
user, | ||
reader.Skip(1).ReadString(), | ||
reader.ReadPoint2D() | ||
); | ||
} |
Oops, something went wrong.