Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert non-CM spawn items in MP to be one-time sync'd spew pickup #203

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GameMod/GameMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<Compile Include="MPErrorSmoothingFix.cs" />
<Compile Include="MPFixGhostProjectiles.cs" />
<Compile Include="MPHUDMessage.cs" />
<Compile Include="MPItemSpawns.cs" />
<Compile Include="MPLongPwd.cs" />
<Compile Include="MPMatchPresets.cs" />
<Compile Include="MPMatchTimeLimits.cs" />
Expand Down
34 changes: 34 additions & 0 deletions GameMod/MPItemSpawns.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using HarmonyLib;
using Overload;
using UnityEngine;

namespace GameMod
{

/// <summary>
/// Issue 200
/// In multiplayer, non-CM item spawns cause unexpected behavior due to being unsync'd (e.g. Ascent health orbs). Destroy these items and respawn as single-use sync'd spew.
/// </summary>
[HarmonyPatch(typeof(UpdateDynamicManager), "AddItem")]
public class UpdateDynamicManager_AddItem
{
static bool Prefix(Item item)
{
if (GameplayManager.IsMultiplayerActive)
{
if (item.netId.Value <= 0)
{
UnityEngine.Object.Destroy(item.c_go);
if (GameplayManager.IsDedicatedServer())
{
Item.Spew(item.c_go, item.c_transform.position, default(Vector3), -1, item.m_super);
}
return false;
}
}

return true;
}
}

}