Skip to content

Commit

Permalink
fix enemies desync in cyber grind
Browse files Browse the repository at this point in the history
  • Loading branch information
xzxADIxzx committed Mar 8, 2024
1 parent 39c4900 commit bb332da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Jaket/Content/Enemies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ public static bool SyncDamage(EnemyIdentifier enemyId, float damage, bool explod
/// <summary> Synchronizes the death of the enemy. </summary>
public static void SyncDeath(EnemyIdentifier enemyId)
{
if (LobbyController.Lobby == null || enemyId.dead || !LobbyController.IsOwner) return;
if (LobbyController.Lobby == null || enemyId.dead) return;

if (enemyId.TryGetComponent<Enemy>(out var enemy))
{
Networking.Send(PacketType.KillEntity, w => w.Id(enemy.Id), size: 8);
if (LobbyController.IsOwner)
Networking.Send(PacketType.KillEntity, w => w.Id(enemy.Id), (data, size) => Events.Post2(() => Networking.Redirect(data, size)), 8);

Tools.Destroy(enemy);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Jaket/Net/Endpoints/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public override void Load()

// after respawn, Leviathan or hand may be absent, so it must be returned if possible
// sometimes players disappear for some unknown reason, and sometimes I destroy them myself
if (entities[id] == null && (type == EntityType.Hand || type == EntityType.Leviathan || type == EntityType.Minotaur_Chase || type == EntityType.Player))
entities[id] = Entities.Get(id, type);
if (entities[id] == null) entities[id] = Entities.Get(id, type);

entities[id]?.Read(r);
});
Expand Down

0 comments on commit bb332da

Please sign in to comment.