diff --git a/CHANGELOG.md b/CHANGELOG.md index ee738e9..5f301dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # CHANGELOG.md +## 1.5.1 (2023-December-9) - The Christmas Update + +### Features +- Added the **Fireflies** mod which allows you to summon a firefly that will track a player in the lobby. +- Added the **Join Bark Code** button which will let you join a private code for Bark users. +- You can now summon Bark using the **B** button on your keyboard. +- Added some Christmas lights to the menu + +### Fixed +- Fixed potions and teleport for the new update + + ## 1.5.0 (2023-November-11) - The Settings Update ### Features diff --git a/GUI/MenuController.cs b/GUI/MenuController.cs index 708508c..b3e3279 100644 --- a/GUI/MenuController.cs +++ b/GUI/MenuController.cs @@ -17,6 +17,7 @@ using UnityEngine.XR; using Bark.Modules.Misc; using Photon.Pun; +using UnityEngine.InputSystem; namespace Bark.GUI { @@ -36,6 +37,7 @@ public Vector3 public static InputTracker SummonTracker; public static ConfigEntry SummonInput; public static ConfigEntry SummonInputHand; + bool docked; protected override void Awake() { @@ -82,6 +84,9 @@ protected override void Awake() gameObject.AddComponent(), gameObject.AddComponent(), gameObject.AddComponent(), + + //// Misc + gameObject.AddComponent(), }; Halo halo = gameObject.AddComponent(); @@ -134,6 +139,20 @@ void Summon() void FixedUpdate() { + if (Keyboard.current.bKey.wasPressedThisFrame) + { + if (!docked) + Summon(); + else + { + _rigidbody.isKinematic = false; + _rigidbody.useGravity = true; + transform.SetParent(null); + AddBlockerToAllButtons(ButtonController.Blocker.MENU_FALLING); + docked = false; + } + } + // The potions tutorial needs to be updated frequently to keep the current size // up-to-date, even when the mod is disabled if (BarkModule.LastEnabled && BarkModule.LastEnabled == Potions.Instance) @@ -154,6 +173,7 @@ void ResetPosition() { button.RemoveBlocker(ButtonController.Blocker.MENU_FALLING); } + docked = true; } void BuildMenu() @@ -174,7 +194,7 @@ void BuildMenu() SetupInteraction(); SetupModPages(); SetupSettingsPage(); - + transform.SetParent(Player.Instance.bodyCollider.transform); ResetPosition(); Logging.Debug("Build successful."); @@ -191,7 +211,7 @@ private void SetupSettingsPage() btnController.OnPressed += (obj, pressed) => { settingsPage.SetActive(pressed); - if(pressed) + if (pressed) settingsPage.GetComponent().UpdateText(); modPage.SetActive(!pressed); }; @@ -336,7 +356,7 @@ public void NextPage(ButtonController button, bool isPressed) { modPages[i].gameObject.SetActive(i == pageIndex); } - modPage = modPages[pageIndex].gameObject; + modPage = modPages[pageIndex].gameObject; } public void SetupInteraction() @@ -346,6 +366,7 @@ public void SetupInteraction() this.OnSelectExit += (_, __) => { AddBlockerToAllButtons(ButtonController.Blocker.MENU_FALLING); + docked = false; }; this.OnSelectEnter += (_, __) => { diff --git a/Interaction/BarkGrabbable.cs b/Interaction/BarkGrabbable.cs index 194e5f4..4177c2f 100644 --- a/Interaction/BarkGrabbable.cs +++ b/Interaction/BarkGrabbable.cs @@ -66,7 +66,7 @@ public override void OnDeselect(BarkInteractor interactor) rb.useGravity = true; // Apply the force to the rigidbody - rb.velocity = (velEstimator.linearVelocity + Player.Instance.currentVelocity) * throwForceMultiplier; + rb.velocity = (Player.Instance.currentVelocity) + velEstimator.linearVelocity * throwForceMultiplier; rb.velocity *= 1 / Player.Instance.scale; rb.angularVelocity = velEstimator.angularVelocity; } diff --git a/Modules/Misc/Lobby.cs b/Modules/Misc/Lobby.cs new file mode 100644 index 0000000..c7a4581 --- /dev/null +++ b/Modules/Misc/Lobby.cs @@ -0,0 +1,30 @@ +using Bark.GUI; +using GorillaNetworking; + +namespace Bark.Modules.Misc +{ + public class Lobby : BarkModule + { + + public static readonly string DisplayName = "Join Bark Code"; + + protected override void OnEnable() + { + if (!MenuController.Instance.Built) return; + base.OnEnable(); + Plugin.Instance.JoinLobby("BARK_MOD", "MODDED_MODDED_CASUALCASUAL"); + this.enabled = false; + } + public override string GetDisplayName() + { + return DisplayName; + } + + public override string Tutorial() + { + return "Joins the official Bark Mod code"; + } + + protected override void Cleanup() { } + } +} diff --git a/Modules/Movement/Nailgun.cs b/Modules/Movement/Nailgun.cs index f5bfb5a..181b846 100644 --- a/Modules/Movement/Nailgun.cs +++ b/Modules/Movement/Nailgun.cs @@ -88,17 +88,6 @@ GameObject MakeNail() return null; } - void MakeSlideHelper(Transform parent) - { - GameObject slideHelper = new GameObject("SlideHelper"); - slideHelper.transform.SetParent(parent, false); - slideHelper.AddComponent().overrideIndex = 89; - var climbable = slideHelper.AddComponent(); - climbable.snapX = false; - climbable.snapY = false; - climbable.snapZ = false; - } - Vector3? GetEndpoint(Vector3 origin, Vector3 forward) { Ray ray = new Ray(origin, forward); diff --git a/Modules/Movement/Platforms.cs b/Modules/Movement/Platforms.cs index 39d1b1d..3d3a4bf 100644 --- a/Modules/Movement/Platforms.cs +++ b/Modules/Movement/Platforms.cs @@ -366,6 +366,7 @@ void OnGripPressed(NetworkedPlayer player, bool isLeft) platformLeft.SetActive(true); platformLeft.transform.position = leftHand.TransformPoint(new Vector3(-12, 18, -10) / 200f); platformLeft.transform.rotation = leftHand.transform.rotation * Quaternion.Euler(215, 0, -15); + platformLeft.transform.localScale = Vector3.one * networkedPlayer.rig.scaleFactor; } else { @@ -373,6 +374,7 @@ void OnGripPressed(NetworkedPlayer player, bool isLeft) platformRight.SetActive(true); platformRight.transform.localPosition = rightHand.TransformPoint(new Vector3(12, 18, 10) / 200f); platformRight.transform.localRotation = rightHand.transform.rotation * Quaternion.Euler(-45, -25, -190); + platformLeft.transform.localScale = Vector3.one * networkedPlayer.rig.scaleFactor; } } diff --git a/Modules/Multiplayer/Fireflies.cs b/Modules/Multiplayer/Fireflies.cs index 7a7e06a..167ed94 100644 --- a/Modules/Multiplayer/Fireflies.cs +++ b/Modules/Multiplayer/Fireflies.cs @@ -1,6 +1,7 @@ using Bark.Extensions; using Bark.Gestures; using Bark.GUI; +using Bark.Modules.Movement; using Bark.Patches; using Bark.Tools; using GorillaLocomotion; @@ -13,11 +14,12 @@ namespace Bark.Modules.Multiplayer public class Firefly : MonoBehaviour { public VRRig rig; - public GameObject _object; + public GameObject fly; public ParticleSystem particles, trail; + Vector3 startPos; public Transform leftWing, rightWing; public float startTime; - public static float duration = 10f; + public static float duration = 1.5f; public ParticleSystemRenderer particleRenderer, trailRenderer; Renderer modelRenderer; public bool seek = false; @@ -27,14 +29,14 @@ void Awake() try { rig = this.gameObject.GetComponent(); - _object = Instantiate(Plugin.assetBundle.LoadAsset("Firefly")).gameObject; - modelRenderer = _object.transform.Find("Model").GetComponent(); - leftWing = _object.transform.Find("Model/Wing L"); - rightWing = _object.transform.Find("Model/Wing R"); - particles = _object.GetComponent(); + fly = Instantiate(Plugin.assetBundle.LoadAsset("Firefly")).gameObject; + modelRenderer = fly.transform.Find("Model").GetComponent(); + leftWing = fly.transform.Find("Model/Wing L"); + rightWing = fly.transform.Find("Model/Wing R"); + particles = fly.transform.Find("Particles").GetComponent(); + trail = fly.transform.Find("Trail").GetComponent(); particleRenderer = particles.GetComponent(); particleRenderer.material = Instantiate(particleRenderer.material); - trail = _object.transform.Find("Trail").GetComponent(); trailRenderer = trail.GetComponent(); trailRenderer.trailMaterial = Instantiate(trailRenderer.trailMaterial); particles.Play(); @@ -44,6 +46,7 @@ void Awake() catch (Exception e) { Logging.Exception(e); } } + void FixedUpdate() { try @@ -61,22 +64,65 @@ void FixedUpdate() //particleRenderer.material.SetColor("_EmissionColor", color); trailRenderer.trailMaterial.color = color; //trailRenderer.trailMaterial.SetColor("_EmissionColor", color); + + Vector3 targetPos = target.position + Vector3.up * .4f * rig.scaleFactor; + fly.transform.LookAt(targetPos); + if (seek) { - _object.transform.position = Vector3.Slerp( - _object.transform.position, - target.position, - (Time.time - startTime) / duration); - _object.transform.localScale = Vector3.Lerp(_object.transform.localScale, rig.scaleFactor * Vector3.one, .1f); + float t = (Time.time - startTime) / duration; + if (t < 1) + { + fly.transform.position = Vector3.Slerp(startPos, targetPos, t); + fly.transform.localScale = Vector3.Lerp( + Vector3.one * Player.Instance.scale, + Vector3.one * rig.scaleFactor, t); + } + else + { + //make the fly circle around the player + float angle = (Time.time * 5) % (Mathf.PI * 2); + float x = Mathf.Cos(angle); + float z = Mathf.Sin(angle); + Vector3 offset = new Vector3(x, 0, z) * .2f * rig.scaleFactor; + fly.transform.position = targetPos + offset; + fly.transform.localScale = Vector3.one * rig.scaleFactor; + + } + //trail.transform.localScale = Vector3.Lerp( + // Vector3.one * Player.Instance.scale, + // Vector3.one * rig.scaleFactor, .1f); } } } catch (Exception e) { Logging.Exception(e); } } + public void Reset(VRRig rig, Transform hand) + { + particles.Stop(); + trail.Stop(); + particles.Clear(); + trail.Clear(); + this.rig = rig; + this.hand = hand; + seek = false; + fly.transform.localScale = Vector3.one * Player.Instance.scale; + fly.transform.position = hand.position; + } + + public void Launch() + { + startTime = Time.time; + startPos = fly.transform.position; + seek = true; + particles.Play(); + trail.Play(); + } + void OnDestroy() { - _object?.Obliterate(); + fly?.Obliterate(); } } @@ -116,6 +162,7 @@ void OnGrip(InputTracker tracker) firefly.Obliterate(); } } + StopAllCoroutines(); fireflies.RemoveAll(fly => fly is null); bool isLeft = tracker == GestureTracker.Instance.leftGrip; var interactor = isLeft ? GestureTracker.Instance.leftPalmInteractor : GestureTracker.Instance.rightPalmInteractor; @@ -127,21 +174,27 @@ void OnGrip(InputTracker tracker) void FixedUpdate() { if (!charging || !hand) return; - for(int i = 0; i < fireflies.Count; i++) + for (int i = 0; i < fireflies.Count; i++) { float angle = (i * Mathf.PI * 2 / fireflies.Count) + Time.time; float x = Mathf.Cos(angle); float z = Mathf.Sin(angle); Vector3 offset = new Vector3(x, z, 0); - var fly = fireflies[i]._object; + var fly = fireflies[i].fly; fly.transform.position = hand.transform.TransformPoint(offset * 2); - fly.transform.LookAt(fireflies[i].rig.transform); + fly.transform.localScale = Vector3.one * Player.Instance.scale; } } - void OnGripReleased(InputTracker _) + void OnGripReleased(InputTracker tracker) { - StartCoroutine(ReleaseFireflies()); + if ( + tracker == GestureTracker.Instance.leftGrip && hand == GestureTracker.Instance.leftPalmInteractor.transform + || + tracker == GestureTracker.Instance.rightGrip && hand == GestureTracker.Instance.rightPalmInteractor.transform) + { + StartCoroutine(ReleaseFireflies()); + } } IEnumerator ReleaseFireflies() @@ -154,12 +207,8 @@ IEnumerator ReleaseFireflies() foreach (var firefly in fireflies) { - firefly.startTime = Time.time; - firefly.seek = true; - firefly._object.transform.localScale = Vector3.zero; - firefly.particles.Play(); - firefly.trail.Play(); - Sounds.Play(Sounds.Sound.BeeSqueeze, .1f, hand == GestureTracker.Instance.leftPalmInteractor.transform); + firefly.Launch(); + Sounds.Play(Sounds.Sound.BeeSqueeze, .1f, hand == GestureTracker.Instance.leftPalmInteractor.transform); yield return new WaitForSeconds(.05f); } } @@ -177,16 +226,8 @@ IEnumerator SpawnFireflies(Transform hand, bool isLeft) if (rig != null && !rig.isOfflineVRRig) { var firefly = rig.gameObject.GetOrAddComponent(); - firefly.particles.Stop(); - firefly.trail.Stop(); - firefly.particles.Clear(); - firefly.trail.Clear(); - firefly.rig = rig; - firefly.hand = hand; - firefly.seek = false; - firefly.particles.transform.localScale = Vector3.one * Player.Instance.scale; - firefly.particles.transform.position = hand.position; - if (!fireflies.Contains(firefly)) + firefly.Reset(rig, hand); + if (!fireflies.Contains(firefly)) fireflies.Add(firefly); } } @@ -236,8 +277,8 @@ private void OnRigCached(Player player, VRRig rig) } //public static ConfigEntry PunchForce; - public static void BindConfigEntries() - { + //public static void BindConfigEntries() + //{ //Logging.Debug("Binding", DisplayName, "to config"); //PunchForce = Plugin.configFile.Bind( // section: DisplayName, @@ -245,7 +286,7 @@ public static void BindConfigEntries() // defaultValue: 5, // description: "How much force will be applied to you when you get punched" //); - } + //} public override string GetDisplayName() { @@ -254,7 +295,7 @@ public override string GetDisplayName() public override string Tutorial() { - return "Effect: Press [Grip] to summon trails that will follow each player upon release"; + return "Effect: Hold [Grip] to summon fireflies that will follow each player upon release"; } } } diff --git a/Modules/Multiplayer/Telekinesis.cs b/Modules/Multiplayer/Telekinesis.cs index cdab0eb..3095499 100644 --- a/Modules/Multiplayer/Telekinesis.cs +++ b/Modules/Multiplayer/Telekinesis.cs @@ -74,15 +74,17 @@ void FixedUpdate() sithlordHandParticles.Clear(); playerParticles.Stop(); playerParticles.Clear(); + rb.velocity = Player.Instance.bodyVelocityTracker.GetAverageVelocity(true, 0.15f, false) * 2; return; } Vector3 end = sithLord.controllingHand.position + sithLord.controllingHand.up * 3 * sithLord.rig.scaleFactor; Vector3 direction = end - Player.Instance.bodyCollider.transform.position; rb.AddForce(direction * 10, ForceMode.Impulse); - float dampingThreshold = direction.magnitude * 20; - if (rb.velocity.magnitude > dampingThreshold) - rb.velocity = rb.velocity.normalized * dampingThreshold; + float dampingThreshold = direction.magnitude * 10; + //if (rb.velocity.magnitude > dampingThreshold) + //if(direction.magnitude < 1) + rb.velocity = Vector3.Lerp(rb.velocity, Vector3.zero, .1f); } } diff --git a/Modules/Physics/Potions.cs b/Modules/Physics/Potions.cs index ae04e50..a659398 100644 --- a/Modules/Physics/Potions.cs +++ b/Modules/Physics/Potions.cs @@ -9,6 +9,7 @@ using Bark.Interaction; using System.Collections.Generic; using Bark.Networking; +using HarmonyLib; namespace Bark.Modules.Physics { @@ -20,6 +21,7 @@ public class Potions : BarkModule private Transform holsterL, holsterR; private Vector3 holsterOffset = new Vector3(0.15f, -0.15f, 0.15f); public static SizeChanger sizeChanger; + public static Traverse sizeChangerTraverse, minScale, maxScale; public static Potions Instance; public static bool active; @@ -66,9 +68,13 @@ void Setup() NetworkPropertyHandler.Instance?.ChangeProperty(playerSizeKey, Player.Instance.scale); sizeChanger = new GameObject("Bark Size Changer").AddComponent(); - sizeChanger.myType = SizeChanger.ChangerType.Static; - sizeChanger.minScale = Player.Instance.scale; - sizeChanger.maxScale = Player.Instance.scale; + sizeChangerTraverse = Traverse.Create(sizeChanger); + minScale = sizeChangerTraverse.Field("minScale"); + maxScale = sizeChangerTraverse.Field("maxScale"); + sizeChangerTraverse.Field("myType").SetValue(SizeChanger.ChangerType.Static); + sizeChangerTraverse.Field("staticEasing").SetValue(.5f); + minScale.SetValue(Player.Instance.scale); + maxScale.SetValue(Player.Instance.scale); holsterL = new GameObject($"Holster (Left)").transform; shrinkPotion = Instantiate(bottlePrefab); @@ -90,6 +96,7 @@ void SetupPotion(ref Transform holster, ref GameObject potion, bool isLeft) try { holster.SetParent(Player.Instance.bodyCollider.transform, false); + holster.localScale = Vector3.one; var offset = new Vector3( holsterOffset.x * (isLeft ? -1 : 1), holsterOffset.y, @@ -114,13 +121,13 @@ void DrinkPotion(SizePotion potion) bool shrink = potion.gameObject == shrinkPotion; if (!shrink && !PositionValidator.Instance.isValidAndStable) return; float delta = shrink ? .99f : 1.01f; - delta = Mathf.Clamp(sizeChanger.minScale * delta, .03f, 20f); + delta = Mathf.Clamp(sizeChanger.MinScale * delta, .03f, 20f); if(delta < 1) potion.gulp.pitch = MathExtensions.Map(Player.Instance.scale, 0, 1, 1.5f, 1); else potion.gulp.pitch = MathExtensions.Map(Player.Instance.scale, 1, 20, 1, .5f); - sizeChanger.minScale = delta; - sizeChanger.maxScale = delta; + minScale.SetValue(delta); + maxScale.SetValue(delta); active = true; } @@ -160,24 +167,25 @@ protected override void OnDestroy() } foreach (SizeManager manager in FindObjectsOfType()) { + Traverse managerTraverse = Traverse.Create(manager); + Traverse scaleFromChanger = managerTraverse.Method("ScaleFromChanger"); + Traverse controllingChanger = managerTraverse.Method("ControllingChanger"); try { if (manager.myType != SizeManager.SizeChangerType.LocalOffline) { var t = manager.targetRig?.transform; if (!t) continue; - float scale = manager.ScaleFromChanger(manager.ControllingChanger(t), t); + float scale = scaleFromChanger.GetValue(controllingChanger.GetValue(t), t); t.localScale = Vector3.one * scale; manager.targetRig.scaleFactor = scale; NetworkPropertyHandler.Instance?.ChangeProperty(playerSizeKey, Player.Instance.scale); } else { + var t = manager.mainCameraTransform; var player = manager.targetPlayer; - float scale = manager.ScaleFromChanger( - manager.ControllingChanger(manager.mainCameraTransform), - manager.mainCameraTransform - ); + float scale = scaleFromChanger.GetValue(controllingChanger.GetValue(t), t); player.turnParent.transform.localScale = Vector3.one * scale; player.scale = scale; } @@ -223,6 +231,7 @@ public static void BindConfigEntries() } public static void TryGetSizeChangerForRig(VRRig rig, out SizeChanger sc) { + float size = rig.GetProperty(Potions.playerSizeKey); if (!rig.HasProperty(Potions.playerSizeKey)) { sc = null; @@ -231,20 +240,33 @@ public static void TryGetSizeChangerForRig(VRRig rig, out SizeChanger sc) if (sizeChangers.ContainsKey(rig)) { sc = sizeChangers[rig]; + var sizeChangerTraverse = Traverse.Create(sc); + var minScale = sizeChangerTraverse.Field("minScale"); + var maxScale = sizeChangerTraverse.Field("maxScale"); + + size = Mathf.Lerp(sc.MinScale, size, .75f * Time.fixedDeltaTime); + minScale.SetValue(size); + maxScale.SetValue(size); } else { - sc = new GameObject("Bark Size Changer").AddComponent(); - sc.transform.SetParent(rig.transform); - sc.myType = SizeChanger.ChangerType.Static; - sc.minScale = rig.scaleFactor; - sc.maxScale = rig.scaleFactor; + size = Mathf.Lerp(rig.scaleFactor, size, .75f * Time.fixedDeltaTime); + sc = CreateSizeChanger(size); sizeChangers.Add(rig, sc); } - float size = rig.GetProperty(Potions.playerSizeKey); - size = Mathf.Lerp(sc.minScale, size, .75f * Time.fixedDeltaTime); - sc.minScale = size; - sc.maxScale = size; + } + + public static SizeChanger CreateSizeChanger(float scale) + { + var sizeChanger = new GameObject("Bark Size Changer").AddComponent(); + var sizeChangerTraverse = Traverse.Create(sizeChanger); + var minScale = sizeChangerTraverse.Field("minScale"); + var maxScale = sizeChangerTraverse.Field("maxScale"); + sizeChangerTraverse.Field("myType").SetValue(SizeChanger.ChangerType.Static); + sizeChangerTraverse.Field("staticEasing").SetValue(.5f); + minScale.SetValue(scale); + maxScale.SetValue(scale); + return sizeChanger; } } @@ -370,6 +392,7 @@ public void Holster(Transform holster) transform.SetParent(holster); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; + transform.localScale = Vector3.one; cork.enabled = false; cork.rb.isKinematic = true; diff --git a/Modules/Teleportation/Pearl.cs b/Modules/Teleportation/Pearl.cs index 2eac6e0..1e8dd34 100644 --- a/Modules/Teleportation/Pearl.cs +++ b/Modules/Teleportation/Pearl.cs @@ -114,7 +114,7 @@ public class ThrowablePearl : BarkGrabbable Rigidbody rigidbody; AudioSource audioSource; LayerMask mask; - bool thrown = false; + bool thrown = false,landed = true; Material monkeMat, trailMat; VRRig playerRig; ParticleSystem trail; @@ -184,6 +184,9 @@ void FixedUpdate() TeleportPatch.TeleportPlayer(hit.point + hit.normal * Player.Instance.scale / 2f); audioSource.Play(); thrown = false; + landed = true; + trail.Stop(); + this.transform.position = Vector3.down * 1000; } } diff --git a/Patches/DebugPatches.cs b/Patches/DebugPatches.cs index b3824d8..5efc22e 100644 --- a/Patches/DebugPatches.cs +++ b/Patches/DebugPatches.cs @@ -28,71 +28,71 @@ public static bool Ignore(string s) } } - [HarmonyPatch(typeof(Debug))] - [HarmonyPatch("LogError", MethodType.Normal)] - [HarmonyPatch(new Type[] { typeof(object) })] - public class LogErrorPatch - { - private static void Postfix(object message) - { - try - { - var stack = new StackTrace(); - if (DebugPatches.Ignore($"{message} {stack}")) return; - Logging.Debug(stack); - } - catch (Exception e) { Logging.Exception(e); } - } - } + //[HarmonyPatch(typeof(Debug))] + //[HarmonyPatch("LogError", MethodType.Normal)] + //[HarmonyPatch(new Type[] { typeof(object) })] + //public class LogErrorPatch + //{ + // private static void Postfix(object message) + // { + // try + // { + // var stack = new StackTrace(); + // if (DebugPatches.Ignore($"{message} {stack}")) return; + // Logging.Debug(stack); + // } + // catch (Exception e) { Logging.Exception(e); } + // } + //} - [HarmonyPatch(typeof(Debug))] - [HarmonyPatch("LogWarning", MethodType.Normal)] - [HarmonyPatch(new Type[] { typeof(object) })] - public class LogWarningPatch - { - private static void Postfix(object message) - { - try - { - var stack = new StackTrace(); - if (DebugPatches.Ignore($"{message} {stack}")) return; - Logging.Debug(stack); - } - catch (Exception e) { Logging.Exception(e); } - } - } + //[HarmonyPatch(typeof(Debug))] + //[HarmonyPatch("LogWarning", MethodType.Normal)] + //[HarmonyPatch(new Type[] { typeof(object) })] + //public class LogWarningPatch + //{ + // private static void Postfix(object message) + // { + // try + // { + // var stack = new StackTrace(); + // if (DebugPatches.Ignore($"{message} {stack}")) return; + // Logging.Debug(stack); + // } + // catch (Exception e) { Logging.Exception(e); } + // } + //} - [HarmonyPatch(typeof(Debug))] - [HarmonyPatch("LogError", MethodType.Normal)] - [HarmonyPatch(new Type[] { typeof(object), typeof(UnityEngine.Object) })] - public class LogError2Patch - { - private static void Postfix(object message, Object context) - { - try - { - var stack = new StackTrace(); - if (DebugPatches.Ignore($"{message} {context} {stack}")) return; - Logging.Debug(message, context, stack); - } - catch (Exception e) { Logging.Exception(e); } - } - } + //[HarmonyPatch(typeof(Debug))] + //[HarmonyPatch("LogError", MethodType.Normal)] + //[HarmonyPatch(new Type[] { typeof(object), typeof(UnityEngine.Object) })] + //public class LogError2Patch + //{ + // private static void Postfix(object message, Object context) + // { + // try + // { + // var stack = new StackTrace(); + // if (DebugPatches.Ignore($"{message} {context} {stack}")) return; + // Logging.Debug(message, context, stack); + // } + // catch (Exception e) { Logging.Exception(e); } + // } + //} - [HarmonyPatch(typeof(Debug))] - [HarmonyPatch("LogWarning", MethodType.Normal)] - [HarmonyPatch(new Type[] { typeof(object) })] - public class LogWarning2Patch - { - private static void Postfix(object message) - { - try - { - var stack = new StackTrace(); - if (DebugPatches.Ignore($"{message} {stack}")) return; - Logging.Debug(message, stack); - } - catch (Exception e) { Logging.Exception(e); } - } - } + //[HarmonyPatch(typeof(Debug))] + //[HarmonyPatch("LogWarning", MethodType.Normal)] + //[HarmonyPatch(new Type[] { typeof(object) })] + //public class LogWarning2Patch + //{ + // private static void Postfix(object message) + // { + // try + // { + // var stack = new StackTrace(); + // if (DebugPatches.Ignore($"{message} {stack}")) return; + // Logging.Debug(message, stack); + // } + // catch (Exception e) { Logging.Exception(e); } + // } + //} } diff --git a/Patches/SizePatches.cs b/Patches/SizePatches.cs index f155591..790667e 100644 --- a/Patches/SizePatches.cs +++ b/Patches/SizePatches.cs @@ -18,8 +18,10 @@ private static void Postfix(ref SizeChanger __result, Transform t) if (!Plugin.inRoom) return; try { - if (Potions.active && t == Camera.main.transform) + if (Potions.active && t == GorillaTagger.Instance.offlineVRRig.transform) + { __result = Potions.sizeChanger; + } else if ( !(Potions.ShowNetworkedSizes is null) && @@ -35,17 +37,17 @@ private static void Postfix(ref SizeChanger __result, Transform t) } } - [HarmonyPatch(typeof(SizeManager))] - [HarmonyPatch("LerpSizeToNormal", MethodType.Normal)] - public class SizeLerpPatch - { - private static void Postfix(float currentSize, ref float __result) - { - if (!Plugin.inRoom) return; - if (Mathf.Abs(1f - currentSize) < 0.05f) - __result = 1; - else - __result = Mathf.Lerp(currentSize, 1f, .75f * Time.fixedDeltaTime); - } - } + //[HarmonyPatch(typeof(SizeManager))] + //[HarmonyPatch("LerpSizeToNormal", MethodType.Normal)] + //public class SizeLerpPatch + //{ + // private static void Postfix(float currentSize, ref float __result) + // { + // if (!Plugin.inRoom) return; + // if (Mathf.Abs(1f - currentSize) < 0.05f) + // __result = 1; + // else + // __result = Mathf.Lerp(currentSize, 1f, .75f * Time.fixedDeltaTime); + // } + //} } \ No newline at end of file diff --git a/Patches/VRRigCachePatches.cs b/Patches/VRRigCachePatches.cs index 0cba5b1..32fa37f 100644 --- a/Patches/VRRigCachePatches.cs +++ b/Patches/VRRigCachePatches.cs @@ -19,7 +19,6 @@ public class VRRigCachePatches static IEnumerable TargetMethods() { - Logging.Debug(typeof(VRRig).AssemblyQualifiedName); return new MethodBase[] { AccessTools.Method("VRRigCache:RemoveRigFromGorillaParent") }; diff --git a/Plugin.cs b/Plugin.cs index 5d8fed3..bbf096d 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -14,6 +14,9 @@ using GorillaLocomotion; using UnityEngine.UI; using HarmonyLib; +using System.Collections; +using GorillaNetworking; +using Photon.Pun; namespace Bark { @@ -23,6 +26,7 @@ namespace Bark public class Plugin : BaseUnityPlugin { + public static Plugin Instance; public static bool initialized, inRoom; bool pluginEnabled = false; public static AssetBundle assetBundle; @@ -34,6 +38,7 @@ public class Plugin : BaseUnityPlugin GestureTracker gt; NetworkPropertyHandler nph; + public void Setup() { if (menuController || !pluginEnabled || !inRoom) return; @@ -41,7 +46,7 @@ public void Setup() try { gt = this.gameObject.GetOrAddComponent(); - nph = this.gameObject.GetOrAddComponent(); + nph = this.gameObject.GetOrAddComponent(); menuController = Instantiate(monkeMenuPrefab).AddComponent(); } catch (Exception e) @@ -69,6 +74,7 @@ void Awake() { try { + Instance = this; Logging.Init(); CI.Init(); configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "Bark.cfg"), true); @@ -206,5 +212,33 @@ void RoomLeft(string gamemode) inRoom = false; Cleanup(); } + + public void JoinLobby(string name, string gamemode) + { + StartCoroutine(JoinLobbyInternal(name, gamemode)); + } + + IEnumerator JoinLobbyInternal(string name, string gamemode) + { + PhotonNetworkController.Instance.AttemptDisconnect(); + do + { + yield return new WaitForSeconds(1f); + Logging.Debug("Waiting to disconnect"); + } + while (PhotonNetwork.InRoom); + + string gamemodeCache = GorillaComputer.instance.currentGameMode; + Logging.Debug("Changing gamemode from", gamemodeCache, "to", gamemode); + GorillaComputer.instance.currentGameMode = gamemode; + PhotonNetworkController.Instance.AttemptToJoinSpecificRoom(name); + + while (!PhotonNetwork.InRoom) + { + yield return new WaitForSeconds(1f); + Logging.Debug("Waiting to connect"); + } + GorillaComputer.instance.currentGameMode = gamemodeCache; + } } } diff --git a/PluginInfo.cs b/PluginInfo.cs index ebd5fa1..a7be5c0 100644 --- a/PluginInfo.cs +++ b/PluginInfo.cs @@ -7,6 +7,6 @@ internal class PluginInfo { public const string GUID = "com.kylethescientist.gorillatag.bark"; public const string Name = "Bark"; - public const string Version = "1.5.0.2"; + public const string Version = "1.5.1"; } } diff --git a/README.md b/README.md index f3014db..4f77a3c 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,13 @@ * `Teleport` - **Make a triangle with your thumbs and index fingers and peer through it** to initiate a teleport. Use your head to aim more finely. ### Multiplayer * `Boxing` - Better known as "punch mod", this allows the player to be punched around by others in the lobby. You can't be punched while touching the ground. +* `Fireflies` - Press [Grip] to summon a firefly for each player in the lobby. Release [Grip] to send them flying to their player. * `Piggyback` - Allows you to ride other players! To mount someone, **have them give a thumbs-up**, and then **grip nearby them**. If they **give you a thumbs down** at any point, you'll stop riding them. *Consent is important!* * `Telekinesis` - If another player points at you with their grip button pressed, they can pick you up and throw you from afar. * `X-Ray` - Allows you to see other players through walls. +### Miscellaneous +* `Join Bark Code` - Allows you to join a private lobby for Bark users. These modules can be useful for exploring the game world, experimenting with gameplay mechanics, or just having fun with friends. They are **not** meant to be used to harass others, which can result in a ban from the game. diff --git a/Resources/barkbundle b/Resources/barkbundle index e84ea3f..5ec1689 100644 Binary files a/Resources/barkbundle and b/Resources/barkbundle differ