mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 19:39:21 +00:00
New mod: PlayerAvatarHistory
Incremented version for nightly to prevent rollback by auto-updater Minor fixes
This commit is contained in:
parent
7f29079109
commit
9f78aa4620
23 changed files with 575 additions and 23 deletions
59
ml_pah/Main.cs
Normal file
59
ml_pah/Main.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using ABI_RC.Systems.GameEventSystem;
|
||||
|
||||
namespace ml_pah
|
||||
{
|
||||
public class PlayerAvatarHistory : MelonLoader.MelonMod
|
||||
{
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
Settings.Init();
|
||||
HistoryManager.Initialize();
|
||||
ModUi.Initialize();
|
||||
MelonLoader.MelonCoroutines.Start(WaitForRootLogic());
|
||||
}
|
||||
|
||||
public override void OnDeinitializeMelon()
|
||||
{
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.RemoveListener(this.OnLocalAvatarLoad);
|
||||
HistoryManager.OnEntriesUpdated.RemoveListener(this.OnHistoryEntriesUpdated);
|
||||
|
||||
ModUi.Shutdown();
|
||||
HistoryManager.Shutdown();
|
||||
}
|
||||
|
||||
IEnumerator WaitForRootLogic()
|
||||
{
|
||||
while(RootLogic.Instance == null)
|
||||
yield return null;
|
||||
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.AddListener(this.OnLocalAvatarLoad);
|
||||
HistoryManager.OnEntriesUpdated.AddListener(this.OnHistoryEntriesUpdated);
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
HistoryManager.Update();
|
||||
}
|
||||
|
||||
// Game events
|
||||
void OnLocalAvatarLoad(CVRAvatar p_avatar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if((p_avatar.AssetInfo != null) && (p_avatar.AssetInfo.objectId.Length > 0))
|
||||
HistoryManager.AddEntry(p_avatar.AssetInfo.objectId);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Mod events
|
||||
void OnHistoryEntriesUpdated() => ModUi.UpdateAvatarsList();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue