Skip to content

Commit

Permalink
Merge pull request #245 from project-fika/fix-locale-errors
Browse files Browse the repository at this point in the history
Fix locale errors
  • Loading branch information
Lacyway authored Dec 18, 2024
2 parents 8d4d47e + e405385 commit 55a7a20
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 101 deletions.
13 changes: 9 additions & 4 deletions Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,10 @@ private void SyncTransitControllers()
/// This task ensures that all players are joined and loaded before continuing
/// </summary>
/// <returns></returns>
private async Task WaitForOtherPlayers()
private async Task WaitForOtherPlayersToLoad()
{
#if DEBUG
Logger.LogWarning("Starting " + nameof(WaitForOtherPlayers));
Logger.LogWarning("Starting " + nameof(WaitForOtherPlayersToLoad));
#endif
if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
Expand Down Expand Up @@ -955,7 +955,7 @@ private GameObject CreateStartButton()
if (isServer)
{
RaidStarted = true;
FikaBackendUtils.HostExpectedNumberOfPlayers = Singleton<FikaServer>.Instance.NetServer.ConnectedPeersCount;
FikaBackendUtils.HostExpectedNumberOfPlayers = Singleton<FikaServer>.Instance.NetServer.ConnectedPeersCount + 1;
return;
}

Expand Down Expand Up @@ -1410,6 +1410,11 @@ private async Task WaitForHostToStart()
Destroy(startButton);
}

InformationPacket continuePacket = new()
{
AmountOfPeers = server.NetServer.ConnectedPeersCount + 1
};
server.SendDataToAll(ref continuePacket, DeliveryMethod.ReliableOrdered);
SetStatusModel status = new(FikaBackendUtils.GroupId, LobbyEntry.ELobbyStatus.IN_GAME);
await FikaRequestHandler.UpdateSetStatus(status);
return;
Expand Down Expand Up @@ -1523,7 +1528,7 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I
DynamicAI = gameObject.AddComponent<FikaDynamicAI>();
}

await WaitForOtherPlayers();
await WaitForOtherPlayersToLoad();

SetMatchmakerStatus(LocaleUtils.UI_FINISHING_RAID_INIT.Localized());
Logger.LogInfo("All players are loaded, continuing...");
Expand Down
13 changes: 12 additions & 1 deletion Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public bool WaitingForCallback
}

protected string lastWeaponId;
private bool shouldSendSideEffect;

public ClientMovementContext ClientMovementContext
{
Expand Down Expand Up @@ -1344,6 +1345,10 @@ public virtual void HandleDamagePacket(ref DamagePacket packet)
if (item != null)
{
damageInfo.Weapon = item;
(damageInfo.Player.iPlayer as CoopPlayer).shouldSendSideEffect = true;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogWarning("Found weapon for knife damage: " + item.Name.Localized());
#endif
}
}

Expand All @@ -1354,13 +1359,19 @@ public virtual void HandleDamagePacket(ref DamagePacket packet)

public override void OnSideEffectApplied(SideEffectComponent sideEffect)
{
if (!shouldSendSideEffect)
{
return;
}

SideEffectPacket packet = new()
{
ItemId = sideEffect.Item.Id,
Value = sideEffect.Value
};

PacketSender.SendPacket(ref packet);
PacketSender.SendPacket(ref packet, true);
shouldSendSideEffect = false;
}

public void HandleArmorDamagePacket(ref ArmorDamagePacket packet)
Expand Down
5 changes: 0 additions & 5 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,11 +1112,6 @@ public void InitObservedPlayer(bool isDedicatedHost)
}
}

public override void OnSideEffectApplied(SideEffectComponent sideEffect)
{
// Do nothing
}

private IEnumerator CreateHealthBar()
{
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;
Expand Down
191 changes: 102 additions & 89 deletions Fika.Core/FikaPlugin.cs

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion Fika.Core/Networking/FikaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public async void Init()

private void OnSideEffectPacketReceived(SideEffectPacket packet)
{
#if DEBUG
logger.LogWarning("OnSideEffectPacketReceived: Received");
#endif
GameWorld gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
Expand All @@ -231,7 +234,9 @@ private void OnSideEffectPacketReceived(SideEffectPacket packet)
{
sideEffectComponent.Value = packet.Value;
item.RaiseRefreshEvent(false, false);
return;
}
logger.LogError("OnSideEffectPacketReceived: SideEffectComponent was not found!");
}

private void OnCorpsePositionPacketReceived(CorpsePositionPacket packet)
Expand Down Expand Up @@ -1086,11 +1091,14 @@ private void OnInformationPacketReceived(InformationPacket packet)
if (coopGame != null)
{
coopGame.RaidStarted = packet.RaidStarted;
FikaBackendUtils.HostExpectedNumberOfPlayers = packet.ReadyPlayers;
}
ReadyClients = packet.ReadyPlayers;
HostReady = packet.HostReady;
HostLoaded = packet.HostLoaded;
if (packet.AmountOfPeers > 0)
{
FikaBackendUtils.HostExpectedNumberOfPlayers = packet.AmountOfPeers;
}

if (packet.HostReady)
{
Expand Down
8 changes: 8 additions & 0 deletions Fika.Core/Networking/FikaServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ public async Task Init()

private void OnSideEffectPacketReceived(SideEffectPacket packet, NetPeer peer)
{
#if DEBUG
logger.LogWarning("OnSideEffectPacketReceived: Received");
#endif
SendDataToAll(ref packet, DeliveryMethod.ReliableOrdered, peer);

GameWorld gameWorld = Singleton<GameWorld>.Instance;
Expand All @@ -316,9 +319,14 @@ private void OnSideEffectPacketReceived(SideEffectPacket packet, NetPeer peer)
Item item = gstruct2.Value;
if (item.TryGetItemComponent(out SideEffectComponent sideEffectComponent))
{
#if DEBUG
logger.LogInfo("Setting value to: " + packet.Value + ", original: " + sideEffectComponent.Value);
#endif
sideEffectComponent.Value = packet.Value;
item.RaiseRefreshEvent(false, false);
return;
}
logger.LogError("OnSideEffectPacketReceived: SideEffectComponent was not found!");
}

private void OnLoadingProfilePacketReceived(LoadingProfilePacket packet, NetPeer peer)
Expand Down
3 changes: 3 additions & 0 deletions Fika.Core/Networking/Packets/Backend/InformationPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public struct InformationPacket : INetSerializable
public bool RaidStarted;
public bool RequestStart;
public int ReadyPlayers;
public int AmountOfPeers;
public bool HostReady;
public bool HostLoaded;
public DateTime GameTime;
Expand All @@ -20,6 +21,7 @@ public void Deserialize(NetDataReader reader)
RaidStarted = reader.GetBool();
RequestStart = reader.GetBool();
ReadyPlayers = reader.GetInt();
AmountOfPeers = reader.GetInt();
HostReady = reader.GetBool();
if (HostReady)
{
Expand All @@ -34,6 +36,7 @@ public void Serialize(NetDataWriter writer)
writer.Put(RaidStarted);
writer.Put(RequestStart);
writer.Put(ReadyPlayers);
writer.Put(AmountOfPeers);
writer.Put(HostReady);
if (HostReady)
{
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/UI/Patches/MenuTaskBar_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void Postfix(Dictionary<EMenuType, AnimatedToggle> ____toggleButto
{
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.ButtonBottomBarClick);
string installDir = Environment.CurrentDirectory;
string fikaDir = Path.Combine(installDir, @"\user\fika");
string fikaDir = installDir + @"\user\fika";

if (!string.IsNullOrEmpty(installDir))
{
Expand Down

0 comments on commit 55a7a20

Please sign in to comment.