Skip to content

Commit

Permalink
Show item name when pinging an item
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jul 19, 2024
1 parent 2efb40c commit 796b8cb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
19 changes: 15 additions & 4 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ public void Ping()

PingFactory.EPingType pingType = PingFactory.EPingType.Point;
object userData = null;
string localeId = null;

//ConsoleScreen.Log(statement: $"{hit.collider.GetFullPath()}: {LayerMask.LayerToName(hitLayer)}/{hitGameObject.name}");

Expand All @@ -880,6 +881,7 @@ public void Ping()
{
pingType = PingFactory.EPingType.LootItem;
userData = lootItem;
localeId = lootItem.Item.ShortName;
}
else if (hitGameObject.TryGetComponent(out Door door))
{
Expand Down Expand Up @@ -908,7 +910,8 @@ public void Ping()
PingLocation = hitPoint,
PingType = pingType,
PingColor = pingColor,
Nickname = Profile.Nickname
Nickname = Profile.Nickname,
LocaleId = string.IsNullOrEmpty(localeId) ? string.Empty : localeId
};

PacketSender.Writer.Reset();
Expand All @@ -929,7 +932,7 @@ public void Ping()
}
}

public void ReceivePing(Vector3 location, PingFactory.EPingType pingType, Color pingColor, string nickname)
public void ReceivePing(Vector3 location, PingFactory.EPingType pingType, Color pingColor, string nickname, string localeId)
{
GameObject prefab = PingFactory.AbstractPing.pingBundle.LoadAsset<GameObject>("BasePingPrefab");
GameObject pingGameObject = Instantiate(prefab);
Expand All @@ -938,8 +941,16 @@ public void ReceivePing(Vector3 location, PingFactory.EPingType pingType, Color
{
abstractPing.Initialize(ref location, null, pingColor);
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.QuestSubTrackComplete);
NotificationManagerClass.DisplayMessageNotification($"Received a ping from '{nickname}'",
ENotificationDurationType.Default, ENotificationIconType.Friend);
if (string.IsNullOrEmpty(localeId))
{
NotificationManagerClass.DisplayMessageNotification($"Received a ping from '{nickname}'",
ENotificationDurationType.Default, ENotificationIconType.Friend);
}
else
{
NotificationManagerClass.DisplayMessageNotification($"'{nickname}' has pinged item '{localeId.Localized()}'",
ENotificationDurationType.Default, ENotificationIconType.Friend);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Networking/FikaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private void OnGenericPacketReceived(GenericPacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer pingPlayerToApply))
{
pingPlayerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname);
pingPlayerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname, packet.LocaleId);
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Networking/FikaServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ private void OnGenericPacketReceived(GenericPacket packet, NetPeer peer)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply))
{
playerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname);
playerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname, packet.LocaleId);
}
}
else if (packet.PacketType == EPackageType.LoadBot)
Expand Down
3 changes: 3 additions & 0 deletions Fika.Core/Networking/Packets/GameWorld/GenericPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct GenericPacket(EPackageType packageType) : INetSerializable
public PingFactory.EPingType PingType;
public Color PingColor = Color.white;
public string Nickname;
public string LocaleId;
public int BotNetId;
public long DepartureTime;
public string ExfilName;
Expand All @@ -36,6 +37,7 @@ public void Deserialize(NetDataReader reader)
PingType = (PingFactory.EPingType)reader.GetByte();
PingColor = reader.GetColor();
Nickname = reader.GetString();
LocaleId = reader.GetString();
break;
case EPackageType.TrainSync:
DepartureTime = reader.GetLong();
Expand Down Expand Up @@ -67,6 +69,7 @@ public void Serialize(NetDataWriter writer)
writer.Put((byte)PingType);
writer.Put(PingColor);
writer.Put(Nickname);
writer.Put(LocaleId);
break;
case EPackageType.TrainSync:
writer.Put(DepartureTime);
Expand Down

0 comments on commit 796b8cb

Please sign in to comment.