mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
Move many mods to Deprecated folder, fix spelling
This commit is contained in:
parent
5e822cec8d
commit
0042590aa6
539 changed files with 7475 additions and 3120 deletions
|
@ -4,19 +4,19 @@ using BTKUILib.UIObjects;
|
|||
using BTKUILib.UIObjects.Components;
|
||||
using NAK.OriginShift;
|
||||
|
||||
namespace NAK.OriginShiftMod.Integrations
|
||||
namespace NAK.OriginShiftMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
public static partial class BtkUiAddon
|
||||
private static Category _ourCategory;
|
||||
|
||||
private static Button _ourMainButton;
|
||||
private static bool _isForcedMode;
|
||||
|
||||
private static ToggleButton _ourToggle;
|
||||
|
||||
private static void Setup_OriginShiftModCategory(Page page)
|
||||
{
|
||||
private static Category _ourCategory;
|
||||
|
||||
private static Button _ourMainButton;
|
||||
private static bool _isForcedMode;
|
||||
|
||||
private static ToggleButton _ourToggle;
|
||||
|
||||
private static void Setup_OriginShiftModCategory(Page page)
|
||||
{
|
||||
// dear category
|
||||
_ourCategory = page.AddCategory(ModSettings.OSM_SettingsCategory, ModSettings.ModName, true, true, false);
|
||||
|
||||
|
@ -38,21 +38,21 @@ namespace NAK.OriginShiftMod.Integrations
|
|||
debugToggle.OnValueUpdated += OnDebugToggle;
|
||||
}
|
||||
|
||||
#region Category Actions
|
||||
#region Category Actions
|
||||
|
||||
private static void UpdateCategoryModUserCount()
|
||||
{
|
||||
private static void UpdateCategoryModUserCount()
|
||||
{
|
||||
int modUsers = 1; // we are always here :3
|
||||
int playerCount = CVRPlayerManager.Instance.NetworkPlayers.Count + 1; // +1 for us :3
|
||||
_ourCategory.CategoryName = $"{ModSettings.OSM_SettingsCategory} ({modUsers}/{playerCount})";
|
||||
}
|
||||
|
||||
#endregion Category Actions
|
||||
#endregion Category Actions
|
||||
|
||||
#region Button Actions
|
||||
#region Button Actions
|
||||
|
||||
private static void SetButtonState(OriginShiftManager.OriginShiftState state)
|
||||
{
|
||||
private static void SetButtonState(OriginShiftManager.OriginShiftState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
default:
|
||||
|
@ -74,8 +74,8 @@ namespace NAK.OriginShiftMod.Integrations
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnMainButtonClick()
|
||||
{
|
||||
private static void OnMainButtonClick()
|
||||
{
|
||||
// if active, return as world is using Origin Shift
|
||||
if (OriginShiftManager.Instance.CurrentState
|
||||
is OriginShiftManager.OriginShiftState.Active)
|
||||
|
@ -97,19 +97,19 @@ namespace NAK.OriginShiftMod.Integrations
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnOriginShiftStateChanged(OriginShiftManager.OriginShiftState state)
|
||||
{
|
||||
private static void OnOriginShiftStateChanged(OriginShiftManager.OriginShiftState state)
|
||||
{
|
||||
_isForcedMode = state == OriginShiftManager.OriginShiftState.Forced;
|
||||
SetButtonState(state);
|
||||
SetToggleLocked(_isForcedMode);
|
||||
}
|
||||
|
||||
#endregion Button Actions
|
||||
#endregion Button Actions
|
||||
|
||||
#region Toggle Actions
|
||||
#region Toggle Actions
|
||||
|
||||
private static void SetToggleLocked(bool value)
|
||||
{
|
||||
private static void SetToggleLocked(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// lock the toggle
|
||||
|
@ -126,20 +126,19 @@ namespace NAK.OriginShiftMod.Integrations
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnCompatibilityModeToggle(bool value)
|
||||
{
|
||||
private static void OnCompatibilityModeToggle(bool value)
|
||||
{
|
||||
ModSettings.EntryCompatibilityMode.Value = value;
|
||||
}
|
||||
|
||||
#endregion Toggle Actions
|
||||
#endregion Toggle Actions
|
||||
|
||||
#region Debug Toggle Actions
|
||||
#region Debug Toggle Actions
|
||||
|
||||
private static void OnDebugToggle(bool value)
|
||||
{
|
||||
private static void OnDebugToggle(bool value)
|
||||
{
|
||||
OriginShiftManager.Instance.ToggleDebugOverlay(value);
|
||||
}
|
||||
|
||||
#endregion Debug Toggle Actions
|
||||
}
|
||||
#endregion Debug Toggle Actions
|
||||
}
|
|
@ -3,23 +3,23 @@ using BTKUILib;
|
|||
using BTKUILib.UIObjects;
|
||||
using NAK.OriginShift;
|
||||
|
||||
namespace NAK.OriginShiftMod.Integrations
|
||||
{
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static Page _miscTabPage;
|
||||
private static string _miscTabElementID;
|
||||
namespace NAK.OriginShiftMod.Integrations;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static Page _miscTabPage;
|
||||
private static string _miscTabElementID;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Prepare_Icons();
|
||||
Setup_OriginShiftTab();
|
||||
}
|
||||
|
||||
#region Initialization
|
||||
#region Initialization
|
||||
|
||||
private static void Prepare_Icons()
|
||||
{
|
||||
private static void Prepare_Icons()
|
||||
{
|
||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "OriginShift-Icon-Active",
|
||||
GetIconStream("OriginShift-Icon-Active.png"));
|
||||
|
||||
|
@ -30,8 +30,8 @@ namespace NAK.OriginShiftMod.Integrations
|
|||
GetIconStream("OriginShift-Icon-Forced.png"));
|
||||
}
|
||||
|
||||
private static void Setup_OriginShiftTab()
|
||||
{
|
||||
private static void Setup_OriginShiftTab()
|
||||
{
|
||||
_miscTabPage = QuickMenuAPI.MiscTabPage;
|
||||
_miscTabElementID = _miscTabPage.ElementID;
|
||||
QuickMenuAPI.UserJoin += OnUserJoinLeave;
|
||||
|
@ -51,16 +51,15 @@ namespace NAK.OriginShiftMod.Integrations
|
|||
// Setup_DebugOptionsCategory(_miscTabPage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Player Count Display
|
||||
#region Player Count Display
|
||||
|
||||
private static void OnWorldLeave()
|
||||
=> UpdateCategoryModUserCount();
|
||||
private static void OnWorldLeave()
|
||||
=> UpdateCategoryModUserCount();
|
||||
|
||||
private static void OnUserJoinLeave(CVRPlayerEntity _)
|
||||
=> UpdateCategoryModUserCount();
|
||||
private static void OnUserJoinLeave(CVRPlayerEntity _)
|
||||
=> UpdateCategoryModUserCount();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
|
@ -5,60 +5,59 @@ using BTKUILib.UIObjects.Components;
|
|||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShiftMod.Integrations
|
||||
namespace NAK.OriginShiftMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
#region Melon Preference Helpers
|
||||
#region Melon Preference Helpers
|
||||
|
||||
private static ToggleButton AddMelonToggle(ref Category category, MelonPreferences_Entry<bool> entry)
|
||||
{
|
||||
private static ToggleButton AddMelonToggle(ref Category category, MelonPreferences_Entry<bool> entry)
|
||||
{
|
||||
ToggleButton toggle = category.AddToggle(entry.DisplayName, entry.Description, entry.Value);
|
||||
toggle.OnValueUpdated += b => entry.Value = b;
|
||||
return toggle;
|
||||
}
|
||||
|
||||
private static SliderFloat AddMelonSlider(ref Category category, MelonPreferences_Entry<float> entry, float min,
|
||||
float max, int decimalPlaces = 2, bool allowReset = true)
|
||||
{
|
||||
private static SliderFloat AddMelonSlider(ref Category category, MelonPreferences_Entry<float> entry, float min,
|
||||
float max, int decimalPlaces = 2, bool allowReset = true)
|
||||
{
|
||||
SliderFloat slider = category.AddSlider(entry.DisplayName, entry.Description,
|
||||
Mathf.Clamp(entry.Value, min, max), min, max, decimalPlaces, entry.DefaultValue, allowReset);
|
||||
slider.OnValueUpdated += f => entry.Value = f;
|
||||
return slider;
|
||||
}
|
||||
|
||||
private static Button AddMelonStringInput(ref Category category, MelonPreferences_Entry<string> entry, string buttonIcon = "", ButtonStyle buttonStyle = ButtonStyle.TextOnly)
|
||||
{
|
||||
private static Button AddMelonStringInput(ref Category category, MelonPreferences_Entry<string> entry, string buttonIcon = "", ButtonStyle buttonStyle = ButtonStyle.TextOnly)
|
||||
{
|
||||
Button button = category.AddButton(entry.DisplayName, buttonIcon, entry.Description, buttonStyle);
|
||||
button.OnPress += () => QuickMenuAPI.OpenKeyboard(entry.Value, s => entry.Value = s);
|
||||
return button;
|
||||
}
|
||||
|
||||
private static Button AddMelonNumberInput(ref Category category, MelonPreferences_Entry<float> entry, string buttonIcon = "", ButtonStyle buttonStyle = ButtonStyle.TextOnly)
|
||||
{
|
||||
private static Button AddMelonNumberInput(ref Category category, MelonPreferences_Entry<float> entry, string buttonIcon = "", ButtonStyle buttonStyle = ButtonStyle.TextOnly)
|
||||
{
|
||||
Button button = category.AddButton(entry.DisplayName, buttonIcon, entry.Description, buttonStyle);
|
||||
button.OnPress += () => QuickMenuAPI.OpenNumberInput(entry.DisplayName, entry.Value, f => entry.Value = f);
|
||||
return button;
|
||||
}
|
||||
|
||||
private static Category AddMelonCategory(ref Page page, MelonPreferences_Entry<bool> entry, bool showHeader = true)
|
||||
{
|
||||
private static Category AddMelonCategory(ref Page page, MelonPreferences_Entry<bool> entry, bool showHeader = true)
|
||||
{
|
||||
Category category = page.AddCategory(entry.DisplayName, showHeader, true, entry.Value);
|
||||
category.OnCollapse += b => entry.Value = b;
|
||||
return category;
|
||||
}
|
||||
|
||||
#endregion Melon Preference Helpers
|
||||
#endregion Melon Preference Helpers
|
||||
|
||||
#region Icon Utils
|
||||
#region Icon Utils
|
||||
|
||||
private static Stream GetIconStream(string iconName)
|
||||
{
|
||||
private static Stream GetIconStream(string iconName)
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
string assemblyName = assembly.GetName().Name;
|
||||
return assembly.GetManifestResourceStream($"{assemblyName}.Resources.{iconName}");
|
||||
}
|
||||
|
||||
#endregion Icon Utils
|
||||
}
|
||||
#endregion Icon Utils
|
||||
}
|
|
@ -7,45 +7,45 @@ using NAK.OriginShift.Utility;
|
|||
|
||||
// Creator Exposed component
|
||||
|
||||
namespace NAK.OriginShift.Components
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class OriginShiftController : MonoBehaviour
|
||||
{
|
||||
public class OriginShiftController : MonoBehaviour
|
||||
{
|
||||
public static OriginShiftController Instance { get; private set; }
|
||||
public static OriginShiftController Instance { get; private set; }
|
||||
|
||||
#region Serialized Fields
|
||||
#region Serialized Fields
|
||||
|
||||
[Header("Config / Shift Params")]
|
||||
[Header("Config / Shift Params")]
|
||||
|
||||
[SerializeField] private bool _shiftVertical = true;
|
||||
[SerializeField] [Range(10, 2500)] private int _shiftThreshold = 15;
|
||||
[SerializeField] private bool _shiftVertical = true;
|
||||
[SerializeField] [Range(10, 2500)] private int _shiftThreshold = 15;
|
||||
|
||||
[Header("Config / Scene Objects")]
|
||||
[Header("Config / Scene Objects")]
|
||||
|
||||
[SerializeField] private bool _autoMoveSceneRoots = true;
|
||||
[SerializeField] private Transform[] _toShiftTransforms = Array.Empty<Transform>();
|
||||
[SerializeField] private bool _autoMoveSceneRoots = true;
|
||||
[SerializeField] private Transform[] _toShiftTransforms = Array.Empty<Transform>();
|
||||
|
||||
[Header("Config / Additive Objects")]
|
||||
[Header("Config / Additive Objects")]
|
||||
|
||||
[SerializeField] private bool _shiftRemotePlayers = true;
|
||||
[SerializeField] private bool _shiftSpawnedObjects = true;
|
||||
[SerializeField] private bool _shiftRemotePlayers = true;
|
||||
[SerializeField] private bool _shiftSpawnedObjects = true;
|
||||
|
||||
#endregion Serialized Fields
|
||||
#endregion Serialized Fields
|
||||
|
||||
#region Internal Fields
|
||||
#region Internal Fields
|
||||
|
||||
internal bool IsForced { get; set; }
|
||||
internal bool IsForced { get; set; }
|
||||
|
||||
#endregion Internal Fields
|
||||
#endregion Internal Fields
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
public static int ORIGIN_SHIFT_THRESHOLD = 15;
|
||||
public static int ORIGIN_SHIFT_THRESHOLD = 15;
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null
|
||||
&& Instance != this)
|
||||
{
|
||||
|
@ -56,8 +56,8 @@ namespace NAK.OriginShift.Components
|
|||
Instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
// set threshold (we can not support dynamic threshold change)
|
||||
ORIGIN_SHIFT_THRESHOLD = IsForced ? 1000 : _shiftThreshold;
|
||||
|
||||
|
@ -73,26 +73,26 @@ namespace NAK.OriginShift.Components
|
|||
AnchorAllStaticRenderers();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
private void OnDestroy()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted -= OnOriginShifted;
|
||||
OriginShiftManager.Instance.ResetManager();
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void GetAllSceneRootTransforms()
|
||||
{
|
||||
private void GetAllSceneRootTransforms()
|
||||
{
|
||||
Scene scene = gameObject.scene;
|
||||
var sceneRoots = scene.GetRootGameObjects();
|
||||
_toShiftTransforms = new Transform[sceneRoots.Length + 1]; // +1 for the static batch anchor
|
||||
for (var i = 0; i < sceneRoots.Length; i++) _toShiftTransforms[i] = sceneRoots[i].transform;
|
||||
}
|
||||
|
||||
private void AnchorAllStaticRenderers()
|
||||
{
|
||||
private void AnchorAllStaticRenderers()
|
||||
{
|
||||
// create an anchor object at 0,0,0
|
||||
Transform anchor = new GameObject("NAK.StaticBatchAnchor").transform;
|
||||
anchor.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
|
@ -113,12 +113,12 @@ namespace NAK.OriginShift.Components
|
|||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
#endregion Private Methods
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShifted(Vector3 shift)
|
||||
{
|
||||
private void OnOriginShifted(Vector3 shift)
|
||||
{
|
||||
foreach (Transform toShiftTransform in _toShiftTransforms)
|
||||
{
|
||||
if (toShiftTransform == null) continue; // skip nulls
|
||||
|
@ -126,8 +126,7 @@ namespace NAK.OriginShift.Components
|
|||
}
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
#endregion Origin Shift Events
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,56 +1,65 @@
|
|||
using JetBrains.Annotations;
|
||||
using ABI.CCK.Components;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
using ABI_RC.Core.Util;
|
||||
using ABI_RC.Core.Util.AssetFiltering;
|
||||
#endif
|
||||
|
||||
namespace NAK.OriginShift.Components
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class OriginShiftEventReceiver : MonoBehaviour
|
||||
{
|
||||
public class OriginShiftEventReceiver : MonoBehaviour
|
||||
{
|
||||
#region Serialized Fields
|
||||
#region Serialized Fields
|
||||
|
||||
[SerializeField] private UnityEvent _onOriginShifted = new();
|
||||
[SerializeField] private bool _filterChunkBoundary;
|
||||
[SerializeField] private Vector3 _chunkBoundaryMin = Vector3.zero;
|
||||
[SerializeField] private Vector3 _chunkBoundaryMax = Vector3.one;
|
||||
[SerializeField] private UnityEvent _onOriginShifted = new();
|
||||
[SerializeField] private bool _filterChunkBoundary;
|
||||
[SerializeField] private Vector3 _chunkBoundaryMin = Vector3.zero;
|
||||
[SerializeField] private Vector3 _chunkBoundaryMax = Vector3.one;
|
||||
|
||||
#endregion Serialized Fields
|
||||
#endregion Serialized Fields
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
#region Private Fields
|
||||
#region Private Fields
|
||||
|
||||
private bool _isInitialized;
|
||||
private bool _isInitialized;
|
||||
|
||||
#endregion Private Fields
|
||||
#endregion Private Fields
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!_isInitialized)
|
||||
{
|
||||
SharedFilter.SanitizeUnityEvents("OriginShiftEventReceiver", _onOriginShifted);
|
||||
//SharedFilter.SanitizeUnityEvents("OriginShiftEventReceiver", _onOriginShifted);
|
||||
|
||||
UnityEventsHelper.SanitizeUnityEvents("OriginShiftEventReceiver",
|
||||
UnityEventsHelper.EventSource.Unknown,
|
||||
this,
|
||||
CVRWorld.Instance,
|
||||
_onOriginShifted);
|
||||
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
OriginShiftManager.OnOriginShifted += HandleOriginShifted;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
private void OnDisable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted -= HandleOriginShifted;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void HandleOriginShifted(Vector3 shift)
|
||||
{
|
||||
private void HandleOriginShifted(Vector3 shift)
|
||||
{
|
||||
if (_filterChunkBoundary && !IsWithinChunkBoundary(shift))
|
||||
return;
|
||||
|
||||
|
@ -65,15 +74,14 @@ namespace NAK.OriginShift.Components
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsWithinChunkBoundary(Vector3 shift)
|
||||
{
|
||||
private bool IsWithinChunkBoundary(Vector3 shift)
|
||||
{
|
||||
return shift.x >= _chunkBoundaryMin.x && shift.x <= _chunkBoundaryMax.x &&
|
||||
shift.y >= _chunkBoundaryMin.y && shift.y <= _chunkBoundaryMax.y &&
|
||||
shift.z >= _chunkBoundaryMin.z && shift.z <= _chunkBoundaryMax.z;
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
#endregion Origin Shift Events
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift.Components
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class OriginShiftParticleSystemReceiver : MonoBehaviour
|
||||
{
|
||||
public class OriginShiftParticleSystemReceiver : MonoBehaviour
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
// max particles count cause i said so 2
|
||||
private static readonly ParticleSystem.Particle[] _tempParticles = new ParticleSystem.Particle[10000];
|
||||
// max particles count cause i said so 2
|
||||
private static readonly ParticleSystem.Particle[] _tempParticles = new ParticleSystem.Particle[10000];
|
||||
|
||||
private ParticleSystem[] _particleSystems;
|
||||
private ParticleSystem[] _particleSystems;
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void Start()
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
_particleSystems = GetComponentsInChildren<ParticleSystem>(true);
|
||||
if (_particleSystems.Length == 0)
|
||||
{
|
||||
|
@ -23,35 +23,34 @@ namespace NAK.OriginShift.Components
|
|||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
private void OnEnable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted += OnOriginShifted;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
private void OnDisable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted -= OnOriginShifted;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShifted(Vector3 offset)
|
||||
{
|
||||
private void OnOriginShifted(Vector3 offset)
|
||||
{
|
||||
foreach (ParticleSystem particleSystem in _particleSystems)
|
||||
ShiftParticleSystem(particleSystem, offset);
|
||||
}
|
||||
|
||||
private static void ShiftParticleSystem(ParticleSystem particleSystem, Vector3 offset)
|
||||
{
|
||||
private static void ShiftParticleSystem(ParticleSystem particleSystem, Vector3 offset)
|
||||
{
|
||||
int particleCount = particleSystem.GetParticles(_tempParticles);
|
||||
for (int i = 0; i < particleCount; i++) _tempParticles[i].position += offset;
|
||||
particleSystem.SetParticles(_tempParticles, particleCount);
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
#endregion Origin Shift Events
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift.Components
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class OriginShiftRigidbodyReceiver : MonoBehaviour
|
||||
{
|
||||
public class OriginShiftRigidbodyReceiver : MonoBehaviour
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
private Rigidbody _rigidbody;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void Start()
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
_rigidbody = GetComponentInChildren<Rigidbody>();
|
||||
if (_rigidbody == null)
|
||||
{
|
||||
|
@ -20,27 +20,26 @@ namespace NAK.OriginShift.Components
|
|||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
private void OnEnable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted += OnOriginShifted;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
private void OnDisable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted -= OnOriginShifted;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShifted(Vector3 shift)
|
||||
{
|
||||
private void OnOriginShifted(Vector3 shift)
|
||||
{
|
||||
_rigidbody.position += shift;
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
#endregion Origin Shift Events
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift.Components
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class OriginShiftTrailRendererReceiver : MonoBehaviour
|
||||
{
|
||||
public class OriginShiftTrailRendererReceiver : MonoBehaviour
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
// max positions count cause i said so
|
||||
private static readonly Vector3[] _tempPositions = new Vector3[10000];
|
||||
// max positions count cause i said so
|
||||
private static readonly Vector3[] _tempPositions = new Vector3[10000];
|
||||
|
||||
private TrailRenderer[] _trailRenderers;
|
||||
private TrailRenderer[] _trailRenderers;
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void Start()
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
_trailRenderers = GetComponentsInChildren<TrailRenderer>(true);
|
||||
if (_trailRenderers.Length == 0)
|
||||
{
|
||||
|
@ -23,35 +23,34 @@ namespace NAK.OriginShift.Components
|
|||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
private void OnEnable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted += OnOriginShifted;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
private void OnDisable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted -= OnOriginShifted;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShifted(Vector3 offset)
|
||||
{
|
||||
private void OnOriginShifted(Vector3 offset)
|
||||
{
|
||||
foreach (TrailRenderer trailRenderer in _trailRenderers)
|
||||
ShiftTrailRenderer(trailRenderer, offset);
|
||||
}
|
||||
|
||||
private static void ShiftTrailRenderer(TrailRenderer trailRenderer, Vector3 offset)
|
||||
{
|
||||
private static void ShiftTrailRenderer(TrailRenderer trailRenderer, Vector3 offset)
|
||||
{
|
||||
trailRenderer.GetPositions(_tempPositions);
|
||||
for (var i = 0; i < _tempPositions.Length; i++) _tempPositions[i] += offset;
|
||||
trailRenderer.SetPositions(_tempPositions);
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
#endregion Origin Shift Events
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,34 +1,33 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift.Components
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class OriginShiftTransformReceiver : MonoBehaviour
|
||||
{
|
||||
public class OriginShiftTransformReceiver : MonoBehaviour
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
private void OnEnable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted += OnOriginShifted;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
private void OnDisable()
|
||||
{
|
||||
OriginShiftManager.OnOriginShifted -= OnOriginShifted;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShifted(Vector3 shift)
|
||||
{
|
||||
private void OnOriginShifted(Vector3 shift)
|
||||
{
|
||||
transform.position += shift;
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
#endregion Origin Shift Events
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift.Hacks
|
||||
{
|
||||
public class OriginShiftOcclusionCullingDisabler : MonoBehaviour
|
||||
{
|
||||
private Camera _camera;
|
||||
private bool _originalCullingState;
|
||||
|
||||
#region Unity Events
|
||||
namespace NAK.OriginShift.Hacks;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
public class OriginShiftOcclusionCullingDisabler : MonoBehaviour
|
||||
{
|
||||
private Camera _camera;
|
||||
private bool _originalCullingState;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
if (_camera == null)
|
||||
{
|
||||
|
@ -21,25 +21,24 @@ namespace NAK.OriginShift.Hacks
|
|||
_originalCullingState = _camera.useOcclusionCulling;
|
||||
}
|
||||
|
||||
private void Awake() // we want to execute even if the component is disabled
|
||||
{
|
||||
private void Awake() // we want to execute even if the component is disabled
|
||||
{
|
||||
OriginShiftManager.OnStateChanged += OnOriginShiftStateChanged;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
private void OnDestroy()
|
||||
{
|
||||
OriginShiftManager.OnStateChanged -= OnOriginShiftStateChanged;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShiftStateChanged(OriginShiftManager.OriginShiftState state)
|
||||
{
|
||||
private void OnOriginShiftStateChanged(OriginShiftManager.OriginShiftState state)
|
||||
{
|
||||
_camera.useOcclusionCulling = state != OriginShiftManager.OriginShiftState.Forced && _originalCullingState;
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
}
|
||||
#endregion Origin Shift Events
|
||||
}
|
|
@ -9,35 +9,35 @@ using UnityEngine;
|
|||
using ABI_RC.Systems.Movement;
|
||||
#endif
|
||||
|
||||
namespace NAK.OriginShift
|
||||
namespace NAK.OriginShift;
|
||||
|
||||
[DefaultExecutionOrder(int.MaxValue)]
|
||||
public class OriginShiftMonitor : MonoBehaviour
|
||||
{
|
||||
[DefaultExecutionOrder(int.MaxValue)]
|
||||
public class OriginShiftMonitor : MonoBehaviour
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
private PlayerSetup _playerSetup;
|
||||
private BetterBetterCharacterController _characterController;
|
||||
private PlayerSetup _playerSetup;
|
||||
private BetterBetterCharacterController _characterController;
|
||||
#endif
|
||||
|
||||
#region Unity Events
|
||||
#region Unity Events
|
||||
|
||||
private void Start()
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
_playerSetup = GetComponent<PlayerSetup>();
|
||||
_characterController = GetComponent<BetterBetterCharacterController>();
|
||||
_playerSetup = GetComponent<PlayerSetup>();
|
||||
_characterController = GetComponent<BetterBetterCharacterController>();
|
||||
#endif
|
||||
OriginShiftManager.OnPostOriginShifted += OnPostOriginShifted;
|
||||
}
|
||||
OriginShiftManager.OnPostOriginShifted += OnPostOriginShifted;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
private void OnDestroy()
|
||||
{
|
||||
OriginShiftManager.OnPostOriginShifted -= OnPostOriginShifted;
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
private void Update()
|
||||
{
|
||||
// in CVR use GetPlayerPosition to account for VR offset
|
||||
Vector3 position = PlayerSetup.Instance.GetPlayerPosition();
|
||||
|
||||
|
@ -56,21 +56,20 @@ namespace NAK.OriginShift
|
|||
OriginShiftManager.Instance.ShiftOrigin(position);
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnPostOriginShifted(Vector3 shift)
|
||||
{
|
||||
private void OnPostOriginShifted(Vector3 shift)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// shift our transform back
|
||||
transform.position += shift;
|
||||
#else
|
||||
_characterController.OffsetBy(shift);
|
||||
_playerSetup.OffsetAvatarMovementData(shift);
|
||||
_characterController.OffsetBy(shift);
|
||||
_playerSetup.OffsetAvatarMovementData(shift);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
}
|
|
@ -10,6 +10,7 @@ using ABI_RC.Systems.GameEventSystem;
|
|||
using ABI_RC.Systems.Movement;
|
||||
using ABI.CCK.Components;
|
||||
using DarkRift;
|
||||
using ECM2;
|
||||
using HarmonyLib;
|
||||
using NAK.OriginShift.Components;
|
||||
using NAK.OriginShift.Hacks;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue