Skip to content

Commit

Permalink
Update logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 19, 2024
1 parent 70d8431 commit 51685da
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions Fika.Core/Coop/Components/CoopHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ private ObservedCoopPlayer SpawnObservedPlayer(Profile profile, Vector3 position

Logger.LogDebug($"CreateLocalPlayer::{profile.Info.Nickname}::Spawned.");

SetWeaponInHandsOfNewPlayer(otherPlayer, () => { });
SetWeaponInHandsOfNewPlayer(otherPlayer);

return otherPlayer;
}
Expand Down Expand Up @@ -559,13 +559,13 @@ private IEnumerator AddClientToBotEnemies(BotsController botController, LocalPla
/// <summary>
/// Attempts to set up the New Player with the current weapon after spawning
/// </summary>
/// <param name="person">The player to set the item on</param>
public void SetWeaponInHandsOfNewPlayer(Player person, Action successCallback)
/// <param name="player">The player to set the item on</param>
public void SetWeaponInHandsOfNewPlayer(Player player)
{
EquipmentClass equipment = person.Profile.Inventory.Equipment;
EquipmentClass equipment = player.Profile.Inventory.Equipment;
if (equipment == null)
{
Logger.LogError($"SetWeaponInHandsOfNewPlayer: {person.Profile.ProfileId} has no Equipment!");
Logger.LogError($"SetWeaponInHandsOfNewPlayer: {player.Profile.Nickname}, {player.Profile.ProfileId} has no Equipment!");
}
Item item = null;

Expand All @@ -591,24 +591,14 @@ public void SetWeaponInHandsOfNewPlayer(Player person, Action successCallback)

if (item == null)
{
Logger.LogError($"SetWeaponInHandsOfNewPlayer:Unable to find any weapon for {person.Profile.ProfileId}");
Logger.LogError($"SetWeaponInHandsOfNewPlayer: Unable to find any weapon for {player.Profile.Nickname}, {player.Profile.ProfileId}");
}

person.SetItemInHands(item, (IResult) =>
player.SetItemInHands(item, (IResult) =>
{
if (IResult.Failed == true)
{
Logger.LogError($"SetWeaponInHandsOfNewPlayer:Unable to set item {item} in hands for {person.Profile.ProfileId}");
}

if (IResult.Succeed == true)
{
successCallback?.Invoke();
}

if (person.TryGetItemInHands<Item>() != null)
{
successCallback?.Invoke();
Logger.LogError($"SetWeaponInHandsOfNewPlayer: Unable to set item {item} in hands for {player.Profile.Nickname}, {player.Profile.ProfileId}");
}
});
}
Expand Down

0 comments on commit 51685da

Please sign in to comment.