changes
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
@@ -12,13 +13,25 @@ namespace BoneSync.Data
|
||||
{
|
||||
internal static class SyncLogger
|
||||
{
|
||||
private static string GetCleanCaller(string className, string methodName)
|
||||
{
|
||||
if (className.Contains("BoneSync"))
|
||||
className = className.Replace("BoneSync.", "");
|
||||
if (methodName.Contains("BoneSync"))
|
||||
methodName = methodName.Replace("BoneSync.", "");
|
||||
return $"{className}.{methodName}";
|
||||
}
|
||||
public static void Msg(string message, ConsoleColor color = ConsoleColor.White, int frame = 1)
|
||||
{
|
||||
StackTrace stackTrace = new StackTrace();
|
||||
StackFrame stackFrame = stackTrace.GetFrame(frame);
|
||||
string methodName = stackFrame.GetMethod().Name;
|
||||
string className = stackFrame.GetMethod().DeclaringType.Name;
|
||||
MelonLogger.Msg(color, $"[{className}.{methodName}] {message}");
|
||||
MethodBase methodBase = stackFrame.GetMethod();
|
||||
|
||||
string methodName = methodBase.Name;
|
||||
string className = methodBase.DeclaringType.Name;
|
||||
string cleanCaller = GetCleanCaller(className, methodName);
|
||||
|
||||
MelonLogger.Msg(color, $"[{cleanCaller}] {message}");
|
||||
}
|
||||
|
||||
public static void Warning(string message)
|
||||
|
||||
@@ -83,7 +83,21 @@ namespace BoneSync.Sync.Components
|
||||
public bool isStale => Time.realtimeSinceStartup - _lastSyncTime > 5f;
|
||||
public bool isOwner => _ownerId == BoneSync.lobby.GetLocalId();
|
||||
|
||||
public bool isValid => this != null;
|
||||
public bool isValid => _GetIsValid();
|
||||
|
||||
private bool _GetIsValid()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this == null) return false;
|
||||
if (gameObject == null) return false;
|
||||
return true;
|
||||
|
||||
} catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInHolster(bool val)
|
||||
{
|
||||
@@ -131,6 +145,7 @@ namespace BoneSync.Sync.Components
|
||||
public bool IsStatic() => rigidbodies.Length == 0;
|
||||
private void CheckAutoSync()
|
||||
{
|
||||
if (!isValid) return;
|
||||
FindAndUpdateComponents();
|
||||
bool shouldAutoSync = ShouldAutoSync();
|
||||
if (shouldAutoSync && (BoneSync.lobby.IsHost || ClientSpawningAllowed()))
|
||||
|
||||
Reference in New Issue
Block a user