74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using BepInEx;
|
|
using BepInEx.Logging;
|
|
using BepInEx.Unity.IL2CPP;
|
|
using CsvHelper;
|
|
using Photon.Pun;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace PhotonViewDumper;
|
|
|
|
public class ViewElement
|
|
{
|
|
public int RecNetId { get; set; }
|
|
public int ActorId { get; set; }
|
|
public string NickName { get; set; }
|
|
public string RecNetUserName { get; set; }
|
|
public int ViewId { get; set; }
|
|
public string PrefabName { get; set; }
|
|
}
|
|
|
|
[BepInPlugin("dev.proxnet.recroom.photonviewdumper", "PhotonViewDumper", "0.1.0")]
|
|
public class Plugin : BasePlugin
|
|
{
|
|
public static new ManualLogSource Log;
|
|
|
|
public override void Load()
|
|
{
|
|
Log = base.Log;
|
|
Log.LogInfo($"Loaded");
|
|
|
|
AddComponent<GameObject>();
|
|
}
|
|
|
|
public static void Dump()
|
|
{
|
|
List<ViewElement> views = new();
|
|
foreach (PhotonView view in PhotonNetwork.PhotonViews)
|
|
{
|
|
try
|
|
{
|
|
var creator = PhotonNetwork.PlayerList.FirstOrDefault(player => player.ActorNumber == view.CreatorActorNr);
|
|
if (creator == null)
|
|
{
|
|
Log.LogWarning($"Could not get creator for view ID {view.ViewID}");
|
|
continue;
|
|
}
|
|
|
|
CCEOLAOLEKJ recNetAccount = null;
|
|
PEGGCEDHBOF.DKNKKLPCGLM.TryGetValue(creator.RecNetAccountId, out recNetAccount);
|
|
|
|
views.Add(new ViewElement
|
|
{
|
|
RecNetId = creator.RecNetAccountId,
|
|
ActorId = creator.ActorNumber,
|
|
NickName = creator.nickName,
|
|
RecNetUserName = recNetAccount == null ? "" : recNetAccount.BIOGKFGIMDG.ToString(),
|
|
ViewId = view.ViewID,
|
|
PrefabName = view.name
|
|
});
|
|
} catch (Exception ex)
|
|
{
|
|
Log.LogWarning($"Failed to dump view {view.ViewID}: {ex}");
|
|
}
|
|
}
|
|
|
|
using var writer = new StreamWriter("views.csv");
|
|
using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture);
|
|
csv.WriteRecords(views);
|
|
Log.LogInfo($"Wrote {views.Count} to views.csv");
|
|
}
|
|
} |