Skip to content

Commit

Permalink
Add MessageBalloon method to IFieldUser
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 27, 2023
1 parent af89acc commit 04b5047
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Edelstein.Protocol.Gameplay.Game.Conversations.Speakers;
using Edelstein.Protocol.Gameplay.Game.Conversations.Speakers.Facades;
using Edelstein.Protocol.Gameplay.Game.Objects.User;
using Edelstein.Protocol.Utilities.Spatial;

namespace Edelstein.Common.Gameplay.Game.Conversations.Speakers;

Expand Down Expand Up @@ -161,7 +162,7 @@ public void IncMoney(int amount)
}

public void TransferField(int fieldID, string portal = "")
=> _user.StageUser.Context.Managers.Field.Retrieve(fieldID).Result?.Enter(_user, portal);
=> _user.StageUser.Context.Managers.Field.Retrieve(fieldID).Result?.Enter(_user, portal).Wait();

public void SetDirectionMode(bool enable, int delay = 0)
=> _user.SetDirectionMode(enable, delay).Wait();
Expand All @@ -170,17 +171,20 @@ public void SetStandAloneMode(bool enable)
=> _user.SetStandAloneMode(enable).Wait();

public void Message(string message)
=> _user.Message(message);
=> _user.Message(message).Wait();

public void MessageBalloon(string message, short? width = null, short? duration = null, IPoint2D? position = null)
=> _user.MessageBalloon(message, width, duration, position).Wait();

public void EffectPlayPortalSE()
=> _user.Effect(new PlayPortalSEEffect(), isRemote: false);
=> _user.Effect(new PlayPortalSEEffect(), isRemote: false).Wait();

public void EffectReserved(string path)
=> _user.Effect(new ReservedEffect(path), isRemote: false);
=> _user.Effect(new ReservedEffect(path), isRemote: false).Wait();

public void EffectAvatarOriented(string path)
=> _user.Effect(new AvatarOrientedEffect(path), isRemote: false);
=> _user.Effect(new AvatarOrientedEffect(path), isRemote: false).Wait();

public void EffectFieldScreen(string path)
=> _user.EffectField(new ScreenFieldEffect(path));
=> _user.EffectField(new ScreenFieldEffect(path)).Wait();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Edelstein.Protocol.Gameplay.Models.Inventories.Modify;
using Edelstein.Protocol.Network;
using Edelstein.Protocol.Utilities.Packets;
using Edelstein.Protocol.Utilities.Spatial;
using Edelstein.Protocol.Utilities.Tickers;

namespace Edelstein.Common.Gameplay.Game.Objects.User;
Expand Down Expand Up @@ -196,6 +197,21 @@ public Task Message(IPacketWritable writable)
return Dispatch(packet.Build());
}

public Task MessageBalloon(string message, short? width = null, short? duration = null, IPoint2D? position = null)
{
var packet = new PacketWriter(PacketSendOperations.UserBalloonMsg);
packet.WriteString(message);
packet.WriteShort((short)(width ?? message.Length * 5));
packet.WriteShort(duration ?? 5);
packet.WriteBool(position == null);
if (position != null)
{
packet.WriteInt(position.X);
packet.WriteInt(position.Y);
}
return Dispatch(packet.Build());
}

public async Task Effect(IPacketWritable writable, bool isLocal = true, bool isRemote = true)
{
var localPacket = new PacketWriter(PacketSendOperations.UserEffectLocal)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Edelstein.Protocol.Gameplay.Game.Conversations.Speakers.Facades;
using Edelstein.Protocol.Utilities.Spatial;

namespace Edelstein.Protocol.Gameplay.Game.Conversations.Speakers;

Expand Down Expand Up @@ -49,6 +50,7 @@ public interface IConversationSpeakerUser : IConversationSpeaker
void SetStandAloneMode(bool enable);

void Message(string message);
void MessageBalloon(string message, short? width = null, short? duration = null, IPoint2D? position = null);

void EffectPlayPortalSE();
void EffectReserved(string path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Edelstein.Protocol.Gameplay.Models.Inventories.Modify;
using Edelstein.Protocol.Services.Social;
using Edelstein.Protocol.Utilities.Packets;
using Edelstein.Protocol.Utilities.Spatial;

namespace Edelstein.Protocol.Gameplay.Game.Objects.User;

Expand Down Expand Up @@ -39,6 +40,8 @@ public interface IFieldUser :

Task Message(string message);
Task Message(IPacketWritable writable);
Task MessageBalloon(string message, short? width = null, short? duration = null, IPoint2D? position = null);

Task Effect(IPacketWritable writable, bool isLocal = true, bool isRemote = true);
Task EffectField(IPacketWritable writable);

Expand Down

0 comments on commit 04b5047

Please sign in to comment.