Added the new coilhead behaviour to the knight Added treasure room puzzle for bedroom Changed many LogInfo into LogDebug Removed jank animator override stuff (no offense) Changed how treasure rooms lock their doors to work in multiplayer Removed basement scripts
121 lines
3.6 KiB
C#
121 lines
3.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using System.Reflection;
|
|
using Unity.Netcode;
|
|
using DunGen.Graph;
|
|
using DunGen;
|
|
using System.Collections;
|
|
|
|
namespace ScarletMansion {
|
|
public static class PrintProperties {
|
|
|
|
public static void PrintDungeonFlow(DungeonFlow flow){
|
|
if (flow == null) return;
|
|
PrintObject(flow, 0, 0, typeof(DungeonFlow), typeof(GameObject));
|
|
}
|
|
|
|
public static void PrintGameObject(GameObject go){
|
|
if (go == null) return;
|
|
PrintObject(go, 0, 0);
|
|
}
|
|
|
|
public static void PrintObject(object o, int index, int depth, params Type[] ignoreList){
|
|
if (o == null) return;
|
|
if (depth > 7) return;
|
|
|
|
if (IsPrimitive(o)) return;
|
|
|
|
if (index > 0 && ignoreList.Contains(o.GetType())) return;
|
|
|
|
if (IsIEnumerable(o)){
|
|
PrintIEnumerable(o, index, depth, ignoreList);
|
|
return;
|
|
}
|
|
|
|
var spacing = new string(' ', index);
|
|
Plugin.logger.LogDebug($"{spacing}[{o.ToString()}]");
|
|
|
|
var props = o.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
|
|
foreach(var pi in props){
|
|
|
|
if (pi.GetIndexParameters().Length > 0){
|
|
var count = 0;
|
|
while(true) {
|
|
try {
|
|
pi.GetValue(o, new object[] { count } );
|
|
count++;
|
|
} catch (TargetInvocationException) { break; }
|
|
}
|
|
|
|
for(var i = 0; i < count; ++i) {
|
|
var value = pi.GetValue(o, new object[] { i } );
|
|
Plugin.logger.LogDebug($"{spacing}{pi.Name}[{i}]: {GetObjectString(value)}");
|
|
PrintObject(value, index + 1, depth + 1, ignoreList);
|
|
}
|
|
|
|
|
|
} else {
|
|
var value = pi.GetValue(o);
|
|
Plugin.logger.LogDebug($"{spacing}{pi.Name}: {GetObjectString(value)}");
|
|
PrintObject(value, index + 1, depth + 1, ignoreList);
|
|
}
|
|
|
|
}
|
|
|
|
var fields = o.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
|
|
foreach(var fi in fields){
|
|
var value = fi.GetValue(o);
|
|
Plugin.logger.LogDebug($"{spacing}{fi.Name}: {GetObjectString(value)}");
|
|
PrintObject(value, index + 1, depth + 1, ignoreList);
|
|
}
|
|
|
|
if (o is GameObject){
|
|
var gameobject = o as GameObject;
|
|
var comps = gameobject.GetComponents<Component>();
|
|
Plugin.logger.LogDebug("--- Components --- ");
|
|
foreach(var c in comps){
|
|
PrintObject(c, index, depth, ignoreList);
|
|
}
|
|
|
|
Plugin.logger.LogDebug("--- Children --- ");
|
|
foreach(Transform t in gameobject.transform){
|
|
PrintObject(t.gameObject, index + 1, depth + 1, ignoreList);
|
|
}
|
|
}
|
|
|
|
|
|
Plugin.logger.LogDebug("");
|
|
}
|
|
|
|
public static void PrintIEnumerable(object o, int index, int depth, params Type[] ignoreList){
|
|
if (o == null) return;
|
|
var spacing = new string(' ', index);
|
|
|
|
var list = o as IEnumerable;
|
|
var i = 0;
|
|
foreach(var item in list){
|
|
Plugin.logger.LogDebug($"{spacing}[IEnumerable {i}]: {GetObjectString(item)}");
|
|
PrintObject(item, index + 1, depth + 1, ignoreList);
|
|
i++;
|
|
}
|
|
|
|
}
|
|
|
|
public static bool IsIEnumerable(object o){
|
|
return o is IEnumerable;
|
|
}
|
|
|
|
public static bool IsPrimitive(object o){
|
|
var type = o.GetType();
|
|
return type.IsPrimitive || type == typeof(string) || type.IsEnum || Convert.GetTypeCode(type) != TypeCode.Object;
|
|
}
|
|
|
|
public static string GetObjectString(object o){
|
|
return o == null ? "NULL" : o.ToString();
|
|
}
|
|
|
|
}
|
|
}
|