Upload from upload_mods.ps1

This commit is contained in:
Nathaniel Cosford
2025-06-04 15:20:40 +09:30
commit 6bfadb86e5
25 changed files with 1947 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
using UnityEngine;
public class TrackedBehaviourBase : MonoBehaviour
{
protected uint explId;
protected bool isServer;
protected object key = null;
protected bool syncOnConnect = false;
protected bool syncOnInit = false;
protected bool track = false;
protected bool handleClientInfo = false;
protected NetSyncHelper helper = null;
protected virtual void Awake()
{
explId = CustomExplosionManager.LastInitializedComponent.CurrentExplosionParams._explId;
if (track)
{
if (key == null)
{
Log.Error("TrackedBehaviourBase: key is not initialized before addRef!");
return;
}
addRef();
}
bool flag = NetSyncHelper.TryGetValue(explId, out helper);
isServer = SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer;
if (flag)
{
if (syncOnConnect)
{
if (isServer)
helper.ClientConnected += OnClientConnected;
else
helper.ConnectedToServer += OnConnectedToServer;
}
if (syncOnInit)
{
if (isServer)
helper.ExplosionServerInit += OnExplosionInitServer;
else
helper.ExplosionClientInit += OnExplosionInitClient;
}
}else
Log.Error("NetSyncHelper not initialized: explId: " + explId);
if (handleClientInfo)
CustomExplosionManager.HandleClientInfo += OnHandleClientInfo;
}
protected virtual void OnDestroy()
{
if (helper != null)
{
if (syncOnConnect)
{
if (isServer)
helper.ClientConnected -= OnClientConnected;
else
helper.ConnectedToServer -= OnConnectedToServer;
}
if (syncOnInit)
{
if (isServer)
helper.ExplosionServerInit -= OnExplosionInitServer;
else
helper.ExplosionClientInit -= OnExplosionInitClient;
}
}
if (handleClientInfo)
CustomExplosionManager.HandleClientInfo -= OnHandleClientInfo;
if (track)
removeRef();
}
protected virtual void addRef()
{
}
protected virtual void removeRef()
{
}
protected virtual void OnClientConnected(PooledBinaryWriter _bw)
{
}
protected virtual void OnConnectedToServer(PooledBinaryReader _br)
{
}
protected virtual void OnExplosionInitServer(PooledBinaryWriter _bw)
{
}
protected virtual void OnExplosionInitClient(PooledBinaryReader _br)
{
}
protected virtual void OnHandleClientInfo(ClientInfo info)
{
}
}