mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[NAK_CVR_Mods] Change every instance of "NotAKidOnSteam" to "NotAKidoS"
This commit is contained in:
parent
a6c030955e
commit
7f02d6811f
159 changed files with 711 additions and 294 deletions
|
@ -1,17 +0,0 @@
|
|||
using ABI_RC.Core.Base;
|
||||
using NAK.OriginShift;
|
||||
using NAK.OriginShift.Hacks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OriginShift.ModCompatibility;
|
||||
|
||||
public static class ThirdPersonCompatibility
|
||||
{
|
||||
internal static void Fix()
|
||||
{
|
||||
GameObject thirdPersonCameraObj = GameObject.Find("_PLAYERLOCAL/[CameraRigDesktop]/Camera/ThirdPersonCameraObj");
|
||||
if (thirdPersonCameraObj == null) return;
|
||||
OriginShiftMod.Logger.Msg("Found ThirdPerson, fixing compatibility...");
|
||||
thirdPersonCameraObj.AddComponentIfMissing<OriginShiftOcclusionCullingDisabler>();
|
||||
}
|
||||
}
|
|
@ -58,6 +58,11 @@ public class OriginShiftMod : MelonMod
|
|||
WorldFilter._Base.Add(typeof(OriginShiftTrailRendererReceiver)); // trail renderer
|
||||
WorldFilter._Base.Add(typeof(OriginShiftTransformReceiver)); // transform
|
||||
|
||||
// chunk controller
|
||||
WorldFilter._Base.Add(typeof(ChunkController));
|
||||
WorldFilter._Base.Add(typeof(ChunkListener));
|
||||
WorldFilter._Base.Add(typeof(ChunkCreator));
|
||||
|
||||
InitializeIntegration("BTKUILib", BtkUiAddon.Initialize); // quick menu ui
|
||||
InitializeIntegration("ThirdPerson", ThirdPersonAddon.Initialize); // camera occlusion culling
|
||||
InitializeIntegration("PlayerRagdollMod", RagdollAddon.Initialize); // ragdoll rigidbodys
|
||||
|
|
144
OriginShift/OriginShift/Components/Chunk/ChunkController.cs
Normal file
144
OriginShift/OriginShift/Components/Chunk/ChunkController.cs
Normal file
|
@ -0,0 +1,144 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class ChunkController : MonoBehaviour
|
||||
{
|
||||
// manage all chunks (all axis, likely 10kx10k10)
|
||||
// keep track of nearby chunks to player (these are "active" chunks)
|
||||
// when origin shift occurs, need to mark flag to go through and disable/enable chunks again
|
||||
// allow 1ms each frame to be spent on updating chunks, until work is completely done
|
||||
// when a chunk is enabled/disabled, a callback is sent to the chunk to update its state
|
||||
|
||||
#region Serialized Fields
|
||||
|
||||
[SerializeField, NotKeyable] private int _maxChunkDistance = 10;
|
||||
|
||||
#endregion Serialized Fields
|
||||
|
||||
#region Chunk Class
|
||||
|
||||
public class Chunk
|
||||
{
|
||||
public Vector3Int Position { get; }
|
||||
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
IsActive = active;
|
||||
if (active)
|
||||
OnChunkLoad?.Invoke();
|
||||
else
|
||||
OnChunkUnload?.Invoke();
|
||||
}
|
||||
|
||||
public Chunk(Vector3Int position, Action onChunkLoad, Action onChunkUnload)
|
||||
{
|
||||
Position = position;
|
||||
OnChunkLoad = onChunkLoad;
|
||||
OnChunkUnload = onChunkUnload;
|
||||
}
|
||||
|
||||
private readonly Action OnChunkLoad;
|
||||
private readonly Action OnChunkUnload;
|
||||
}
|
||||
|
||||
#endregion Chunk Class
|
||||
|
||||
public static Dictionary<Vector3Int, Chunk> Chunks { get; private set; } = new();
|
||||
|
||||
public static void AddChunk(Chunk chunk)
|
||||
=> Chunks.Add(chunk.Position, chunk);
|
||||
|
||||
public static void RemoveChunk(Chunk chunk)
|
||||
=> Chunks.Remove(chunk.Position);
|
||||
|
||||
private Chunk[,,] _loadedChunks;
|
||||
private int _halfChunkDistance;
|
||||
|
||||
private int _originX = int.MaxValue;
|
||||
private int _originY = int.MaxValue;
|
||||
private int _originZ = int.MaxValue;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_maxChunkDistance = Mathf.Max(1, _maxChunkDistance);
|
||||
_halfChunkDistance = _maxChunkDistance / 2;
|
||||
_loadedChunks = new Chunk[_maxChunkDistance, _maxChunkDistance, _maxChunkDistance];
|
||||
UpdateMap(0, 0, 0); // initial load
|
||||
|
||||
OriginShiftManager.OnPostOriginShifted += OnOriginShift;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
OriginShiftManager.OnPostOriginShifted -= OnOriginShift;
|
||||
}
|
||||
|
||||
private void UpdateMap(int xPos, int yPos, int zPos) {
|
||||
int deltaX = xPos - _originX;
|
||||
int deltaY = yPos - _originY;
|
||||
int deltaZ = zPos - _originZ;
|
||||
|
||||
_originX = xPos;
|
||||
_originY = yPos;
|
||||
_originZ = zPos;
|
||||
|
||||
for (int x = 0; x < _maxChunkDistance; x++) {
|
||||
for (int y = 0; y < _maxChunkDistance; y++) {
|
||||
for (int z = 0; z < _maxChunkDistance; z++) {
|
||||
int offsetX = x + deltaX;
|
||||
int offsetY = y + deltaY;
|
||||
int offsetZ = z + deltaZ;
|
||||
|
||||
if (offsetX < 0 || offsetX >= _maxChunkDistance || offsetY < 0 || offsetY >= _maxChunkDistance
|
||||
|| offsetZ < 0 || offsetZ >= _maxChunkDistance) {
|
||||
int tileX = x + xPos;
|
||||
int tileY = y + yPos;
|
||||
int tileZ = z + zPos;
|
||||
|
||||
int mapX = tileX % _maxChunkDistance;
|
||||
int mapY = tileY % _maxChunkDistance;
|
||||
int mapZ = tileZ % _maxChunkDistance;
|
||||
|
||||
if (mapX < 0) mapX += _maxChunkDistance;
|
||||
if (mapY < 0) mapY += _maxChunkDistance;
|
||||
if (mapZ < 0) mapZ += _maxChunkDistance;
|
||||
|
||||
// call OnChunkUnload on chunk
|
||||
_loadedChunks[mapX, mapY, mapZ]?.SetActive(false);
|
||||
|
||||
// access new chunk
|
||||
tileX -= _halfChunkDistance;
|
||||
tileY -= _halfChunkDistance;
|
||||
tileZ -= _halfChunkDistance;
|
||||
|
||||
// create Vector3Int for lookup
|
||||
Vector3Int newChunkPosition = new(tileX, tileY, tileZ);
|
||||
if (Chunks.TryGetValue(newChunkPosition, out Chunk chunk))
|
||||
{
|
||||
chunk.SetActive(true);
|
||||
_loadedChunks[mapX, mapY, mapZ] = chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
|
||||
#region Origin Shift Events
|
||||
|
||||
private void OnOriginShift(Vector3 _)
|
||||
{
|
||||
Vector3Int currentChunk = OriginShiftManager.Instance.ChunkOffset;
|
||||
UpdateMap(currentChunk.x, currentChunk.y, currentChunk.z);
|
||||
}
|
||||
|
||||
#endregion Origin Shift Events
|
||||
}
|
27
OriginShift/OriginShift/Components/Chunk/ChunkCreator.cs
Normal file
27
OriginShift/OriginShift/Components/Chunk/ChunkCreator.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class ChunkCreator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject _chunkPrefab;
|
||||
|
||||
private bool _isChunkCreated;
|
||||
|
||||
public void CreateChunk()
|
||||
{
|
||||
_isChunkCreated = true;
|
||||
|
||||
Transform transform1 = transform;
|
||||
Instantiate(_chunkPrefab, transform1.position, Quaternion.identity, transform1);
|
||||
}
|
||||
|
||||
public void DestroyChunk()
|
||||
{
|
||||
if (!_isChunkCreated)
|
||||
return;
|
||||
|
||||
_isChunkCreated = false;
|
||||
Destroy(gameObject.transform.GetChild(0).gameObject);
|
||||
}
|
||||
}
|
52
OriginShift/OriginShift/Components/Chunk/ChunkListener.cs
Normal file
52
OriginShift/OriginShift/Components/Chunk/ChunkListener.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace NAK.OriginShift.Components;
|
||||
|
||||
public class ChunkListener : MonoBehaviour
|
||||
{
|
||||
#region Serialized Properties
|
||||
|
||||
[SerializeField] private Vector3Int _chunkCoords;
|
||||
[SerializeField] private UnityEvent _onChunkLoad;
|
||||
[SerializeField] private UnityEvent _onChunkUnload;
|
||||
|
||||
#endregion Serialized Properties
|
||||
|
||||
#region Private Variables
|
||||
|
||||
private ChunkController.Chunk _chunk;
|
||||
|
||||
#endregion Private Variables
|
||||
|
||||
#region Unity Events
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_chunk = new ChunkController.Chunk(_chunkCoords, OnChunkLoad, OnChunkUnload);
|
||||
ChunkController.AddChunk(_chunk);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ChunkController.RemoveChunk(_chunk);
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
|
||||
#region Chunk Events
|
||||
|
||||
private void OnChunkLoad()
|
||||
{
|
||||
Vector3Int chunkAbsPos = _chunk.Position * OriginShiftController.ORIGIN_SHIFT_THRESHOLD;
|
||||
transform.position = OriginShiftManager.GetLocalizedPosition(chunkAbsPos);
|
||||
_onChunkLoad?.Invoke();
|
||||
}
|
||||
|
||||
private void OnChunkUnload()
|
||||
{
|
||||
_onChunkUnload?.Invoke();
|
||||
}
|
||||
|
||||
#endregion Chunk Events
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace NAK.OriginShift.Components
|
|||
[Header("Config / Shift Params")]
|
||||
|
||||
[SerializeField] private bool _shiftVertical = true;
|
||||
[SerializeField] [Range(10f, 2500f)] private float _shiftThreshold = 15f;
|
||||
[SerializeField] [Range(10, 2500)] private int _shiftThreshold = 15;
|
||||
|
||||
[Header("Config / Scene Objects")]
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace NAK.OriginShift.Components
|
|||
|
||||
#if !UNITY_EDITOR
|
||||
|
||||
public static float ORIGIN_SHIFT_THRESHOLD = 15f;
|
||||
public static int ORIGIN_SHIFT_THRESHOLD = 15;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace NAK.OriginShift.Components
|
|||
private void Start()
|
||||
{
|
||||
// set threshold (we can not support dynamic threshold change)
|
||||
ORIGIN_SHIFT_THRESHOLD = IsForced ? 1000f : _shiftThreshold;
|
||||
ORIGIN_SHIFT_THRESHOLD = IsForced ? 1000 : _shiftThreshold;
|
||||
|
||||
OriginShiftManager.OnOriginShifted += OnOriginShifted;
|
||||
OriginShiftManager.Instance.SetupManager(IsForced);
|
||||
|
|
|
@ -21,12 +21,12 @@ namespace NAK.OriginShift.Hacks
|
|||
_originalCullingState = _camera.useOcclusionCulling;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
private void Awake() // we want to execute even if the component is disabled
|
||||
{
|
||||
OriginShiftManager.OnStateChanged += OnOriginShiftStateChanged;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
private void OnDestroy()
|
||||
{
|
||||
OriginShiftManager.OnStateChanged -= OnOriginShiftStateChanged;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace NAK.OriginShift;
|
|||
public class OriginShiftManager : MonoBehaviour
|
||||
{
|
||||
#region Singleton
|
||||
|
||||
|
||||
private static OriginShiftManager _instance;
|
||||
|
||||
public static OriginShiftManager Instance
|
||||
|
@ -87,16 +87,16 @@ public class OriginShiftManager : MonoBehaviour
|
|||
|
||||
public static Action<OriginShiftState> OnStateChanged = delegate { };
|
||||
|
||||
public static Action<Vector3> OnOriginShifted = delegate { };
|
||||
public static Action<Vector3> OnPostOriginShifted = delegate { };
|
||||
public static Action<Vector3> OnOriginShifted = delegate { }; // move everything
|
||||
public static Action<Vector3> OnPostOriginShifted = delegate { }; // player & chunks
|
||||
|
||||
#endregion Actions
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[PublicAPI] public bool IsOriginShifted => ChunkOffset != Vector3.zero;
|
||||
[PublicAPI] public Vector3 ChunkOffset { get; internal set; } = Vector3.zero;
|
||||
[PublicAPI] public Vector3 ChunkPosition => ChunkOffset * OriginShiftController.ORIGIN_SHIFT_THRESHOLD;
|
||||
[PublicAPI] public bool IsOriginShifted => ChunkOffset != Vector3Int.zero;
|
||||
[PublicAPI] public Vector3Int ChunkOffset { get; internal set; } = Vector3Int.zero;
|
||||
[PublicAPI] public Vector3Int ChunkPosition => ChunkOffset * OriginShiftController.ORIGIN_SHIFT_THRESHOLD;
|
||||
|
||||
public enum OriginShiftState
|
||||
{
|
||||
|
@ -178,12 +178,12 @@ public class OriginShiftManager : MonoBehaviour
|
|||
stopwatch.Start();
|
||||
|
||||
// normalize
|
||||
float halfThreshold = (OriginShiftController.ORIGIN_SHIFT_THRESHOLD / 2);
|
||||
float halfThreshold = (OriginShiftController.ORIGIN_SHIFT_THRESHOLD / 2f);
|
||||
rawPosition += new Vector3(halfThreshold, halfThreshold, halfThreshold);
|
||||
|
||||
// add to chunk
|
||||
Vector3 chunkDifference;
|
||||
Vector3 calculatedChunk = chunkDifference = ChunkOffset;
|
||||
Vector3Int chunkDifference;
|
||||
Vector3Int calculatedChunk = chunkDifference = ChunkOffset;
|
||||
|
||||
calculatedChunk.x += Mathf.FloorToInt(rawPosition.x / OriginShiftController.ORIGIN_SHIFT_THRESHOLD);
|
||||
calculatedChunk.y += Mathf.FloorToInt(rawPosition.y / OriginShiftController.ORIGIN_SHIFT_THRESHOLD);
|
||||
|
@ -210,7 +210,7 @@ public class OriginShiftManager : MonoBehaviour
|
|||
if (!_useOriginShift) return;
|
||||
|
||||
ShiftOrigin(-ChunkPosition);
|
||||
ChunkOffset = Vector3.zero;
|
||||
ChunkOffset = Vector3Int.zero;
|
||||
}
|
||||
|
||||
#endregion Origin Shift Implementation
|
||||
|
|
|
@ -42,14 +42,14 @@ namespace NAK.OriginShift
|
|||
Vector3 position = PlayerSetup.Instance.GetPlayerPosition();
|
||||
|
||||
// respawn height check
|
||||
Vector3 absPosition = OriginShiftManager.GetAbsolutePosition(position);
|
||||
if (absPosition.y < BetterBetterCharacterController.Instance.respawnHeight)
|
||||
{
|
||||
RootLogic.Instance.Respawn();
|
||||
return;
|
||||
}
|
||||
// Vector3 absPosition = OriginShiftManager.GetAbsolutePosition(position);
|
||||
// if (absPosition.y < BetterBetterCharacterController.Instance.respawnHeight)
|
||||
// {
|
||||
// RootLogic.Instance.Respawn();
|
||||
// return;
|
||||
// }
|
||||
|
||||
float halfThreshold = OriginShiftController.ORIGIN_SHIFT_THRESHOLD / 2; // i keep forgetting this
|
||||
float halfThreshold = OriginShiftController.ORIGIN_SHIFT_THRESHOLD / 2f; // i keep forgetting this
|
||||
if (Mathf.Abs(position.x) > halfThreshold
|
||||
|| Mathf.Abs(position.y) > halfThreshold
|
||||
|| Mathf.Abs(position.z) > halfThreshold)
|
||||
|
|
|
@ -15,7 +15,7 @@ using System.Reflection;
|
|||
nameof(NAK.OriginShift),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/OriginShift"
|
||||
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/OriginShift"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r29/RelativeSync.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/RelativeSync/",
|
||||
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r29/RelativeSync.dll",
|
||||
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/RelativeSync/",
|
||||
"changelog": "- Enabled the Experimental settings to fix **local** jitter on Movement Parents by default\n- Adjusted BBCC No Interpolation fix to account for potential native fix (now respects initial value)",
|
||||
"embedcolor": "#507e64"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue