Move many mods to Deprecated folder, fix spelling

This commit is contained in:
NotAKidoS 2025-04-03 02:57:35 -05:00
parent 5e822cec8d
commit 0042590aa6
539 changed files with 7475 additions and 3120 deletions

View file

@ -1,161 +0,0 @@
using UnityEngine;
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Systems.ModNetwork;
namespace NAK.LuaNetVars;
public class PickupableBehaviour : MNSyncedBehaviour
{
private enum PickupMessageType : byte
{
GrabState,
Transform
}
private bool isHeld;
private string holderId;
private Vector3 lastPosition;
private Quaternion lastRotation;
public PickupableObject Pickupable { get; private set; }
public PickupableBehaviour(string networkId, PickupableObject pickupable) : base(networkId, autoAcceptTransfers: false)
{
Pickupable = pickupable;
isHeld = false;
holderId = string.Empty;
lastPosition = pickupable.transform.position;
lastRotation = pickupable.transform.rotation;
}
public void OnGrabbed(InteractionContext context)
{
RequestOwnership(success => {
if (success)
{
isHeld = true;
holderId = LocalUserId;
SendNetworkedData(WriteGrabState);
}
else
{
// Ownership request failed, drop the object
Pickupable.ControllerRay = null; // Force drop
}
});
}
public void OnDropped()
{
if (!HasOwnership) return;
isHeld = false;
holderId = string.Empty;
SendNetworkedData(WriteGrabState);
}
public void UpdateTransform(Vector3 position, Quaternion rotation)
{
if (!HasOwnership || !isHeld) return;
lastPosition = position;
lastRotation = rotation;
SendNetworkedData(WriteTransform);
}
protected override OwnershipResponse OnOwnershipRequested(string requesterId)
{
// If the object is held by the current owner, reject the transfer
if (isHeld && holderId == LocalUserId)
return OwnershipResponse.Rejected;
// If theft is disallowed and the object is held by someone, reject the transfer
if (Pickupable.DisallowTheft && !string.IsNullOrEmpty(holderId))
return OwnershipResponse.Rejected;
return OwnershipResponse.Accepted;
}
protected override void WriteState(ModNetworkMessage message)
{
message.Write(isHeld);
message.Write(holderId);
message.Write(lastPosition);
message.Write(lastRotation);
}
protected override void ReadState(ModNetworkMessage message)
{
message.Read(out isHeld);
message.Read(out holderId);
message.Read(out lastPosition);
message.Read(out lastRotation);
UpdatePickupableState();
}
private void WriteGrabState(ModNetworkMessage message)
{
message.Write((byte)PickupMessageType.GrabState);
message.Write(isHeld);
message.Write(holderId);
}
private void WriteTransform(ModNetworkMessage message)
{
message.Write((byte)PickupMessageType.Transform);
message.Write(lastPosition);
message.Write(lastRotation);
}
protected override void ReadCustomData(ModNetworkMessage message)
{
message.Read(out byte messageType);
switch ((PickupMessageType)messageType)
{
case PickupMessageType.GrabState:
message.Read(out isHeld);
message.Read(out holderId);
break;
case PickupMessageType.Transform:
message.Read(out Vector3 position);
message.Read(out Quaternion rotation);
lastPosition = position;
lastRotation = rotation;
break;
}
UpdatePickupableState();
}
private void UpdatePickupableState()
{
// Update transform if we're not the holder
if (!isHeld || holderId != LocalUserId)
{
Pickupable.transform.position = lastPosition;
Pickupable.transform.rotation = lastRotation;
}
// Force drop if we were holding but someone else took ownership
if (isHeld && holderId != LocalUserId)
{
Pickupable.ControllerRay = null; // Force drop
}
}
protected override void OnOwnershipChanged(string newOwnerId)
{
base.OnOwnershipChanged(newOwnerId);
// If we lost ownership and were holding, force drop
if (!HasOwnership && holderId == LocalUserId)
{
isHeld = false;
holderId = string.Empty;
Pickupable.ControllerRay = null; // Force drop
}
}
}

View file

@ -1,72 +0,0 @@
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.InteractionSystem.Base;
using UnityEngine;
namespace NAK.LuaNetVars;
public class PickupableObject : Pickupable
{
[SerializeField] private bool canPickup = true;
[SerializeField] private bool disallowTheft = false;
[SerializeField] private float maxGrabDistance = 2f;
[SerializeField] private float maxPushDistance = 2f;
[SerializeField] private bool isAutoHold = false;
[SerializeField] private bool allowRotation = true;
[SerializeField] private bool allowPushPull = true;
[SerializeField] private bool allowInteraction = true;
private PickupableBehaviour behaviour;
private bool isInitialized;
private void Awake()
{
// Generate a unique network ID based on the instance ID
string networkId = $"pickup_{gameObject.name}";
behaviour = new PickupableBehaviour(networkId, this);
isInitialized = true;
}
private void OnDestroy()
{
behaviour?.Dispose();
}
private void Update()
{
if (behaviour?.HasOwnership == true)
{
transform.SetPositionAndRotation(ControllerRay.pivotPoint.position, ControllerRay.pivotPoint.rotation);
behaviour.UpdateTransform(transform.position, transform.rotation);
}
}
#region Pickupable Implementation
public override void OnGrab(InteractionContext context, Vector3 grabPoint)
{
if (!isInitialized) return;
behaviour.OnGrabbed(context);
}
public override void OnDrop(InteractionContext context)
{
if (!isInitialized) return;
behaviour.OnDropped();
}
public override void OnFlingTowardsTarget(Vector3 target)
{
// ignore
}
public override bool CanPickup => canPickup;
public override bool DisallowTheft => disallowTheft;
public override float MaxGrabDistance => maxGrabDistance;
public override float MaxPushDistance => maxPushDistance;
public override bool IsAutoHold => isAutoHold;
public override bool IsObjectRotationAllowed => allowRotation;
public override bool IsObjectPushPullAllowed => allowPushPull;
public override bool IsObjectInteractionAllowed => allowInteraction;
#endregion Pickupable Implementation
}