Skip to content

Commit

Permalink
Merge pull request #62 from Kylon99/dev/master/#59_Add_Mod_Option_Men…
Browse files Browse the repository at this point in the history
…u_with_list_of_configuration_options_for_easy_selection_0.7.6

Add Gameplay Setup Menu with list of configuration options for easy selection
  • Loading branch information
Kylon99 authored Jun 17, 2023
2 parents 7f37450 + f0b9f84 commit 3f8e591
Show file tree
Hide file tree
Showing 79 changed files with 2,213 additions and 1,147 deletions.
39 changes: 36 additions & 3 deletions AlternativePlay/AlternativePlay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@
<Compile Include="BehaviorCatalog.cs" />
<Compile Include="DarthMaulBehavior.cs" />
<Compile Include="HarmonyPatches\BeatFlailNoteMoverPatch.cs" />
<Compile Include="HarmonyPatches\GameplaySetupViewControllerPatch.cs" />
<Compile Include="HarmonyPatches\NunchakuHapticPatch.cs" />
<Compile Include="Models\ConfigurationData075.cs" />
<Compile Include="Models\ConfigurationIconSummary.cs" />
<Compile Include="NunchakuBehavior.cs" />
<Compile Include="BeatFlailBehavior.cs" />
<Compile Include="HarmonyPatches\MultiplayerPatch.cs" />
Expand All @@ -143,10 +146,13 @@
<Compile Include="UI\BeatSaberView.cs" />
<Compile Include="UI\BeatFlailView.cs" />
<Compile Include="Models\IconNames.cs" />
<Compile Include="UI\AlternativePlayView.cs" />
<Compile Include="UI\PlayModeSelectOption.cs" />
<Compile Include="UI\PlayModeSelectTab.cs" />
<Compile Include="UI\NunchakuView.cs" />
<Compile Include="UI\GameModifiersView.cs" />
<Compile Include="UI\DarthMaulView.cs" />
<Compile Include="UI\AlternativePlayView.cs" />
<Compile Include="UI\PlayModeSelectView.cs" />
<Compile Include="UI\ModMainFlowCoordinator.cs" />
<Compile Include="UI\TrackerDisplayText.cs" />
<Compile Include="UI\TrackerPoseView.cs" />
Expand All @@ -157,7 +163,32 @@
<EmbeddedResource Include="manifest.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\XIcon.png" />
<EmbeddedResource Include="Resources\LeftFlail.png" />
<EmbeddedResource Include="Resources\RightFlail.png" />
<EmbeddedResource Include="Resources\LeftController.png" />
<EmbeddedResource Include="Resources\ReverseMaulDirection.png" />
<EmbeddedResource Include="Resources\ReverseSpearDirection.png" />
<EmbeddedResource Include="Resources\RightController.png" />
<EmbeddedResource Include="Resources\NoArrowsRandom256.png" />
<EmbeddedResource Include="Resources\BeatFlail256.png" />
<EmbeddedResource Include="Resources\BeatSaber256.png" />
<EmbeddedResource Include="Resources\BeatSpear256.png" />
<EmbeddedResource Include="Resources\DarthMaul256.png" />
<EmbeddedResource Include="Resources\NoArrows256.png" />
<EmbeddedResource Include="Resources\NoSliders256.png" />
<EmbeddedResource Include="Resources\Nunchaku256.png" />
<EmbeddedResource Include="Resources\OneColor256.png" />
<EmbeddedResource Include="Resources\TouchNotes256.png" />
<EmbeddedResource Include="Resources\OneController.png" />
<EmbeddedResource Include="Resources\TwoController.png" />
<EmbeddedResource Include="Resources\Empty.png" />
<EmbeddedResource Include="Resources\LeftSaber.png" />
<EmbeddedResource Include="Resources\LeftTracker.png" />
<EmbeddedResource Include="Resources\ReverseBoth.png" />
<EmbeddedResource Include="Resources\ReverseLeft.png" />
<EmbeddedResource Include="Resources\ReverseRight.png" />
<EmbeddedResource Include="Resources\RightSaber.png" />
<EmbeddedResource Include="Resources\RightTracker.png" />
<EmbeddedResource Include="Resources\ViveTracker.png" />
<EmbeddedResource Include="Public\TouchNotes.png" />
<EmbeddedResource Include="Public\BeatFlail.png" />
Expand Down Expand Up @@ -192,9 +223,11 @@
<EmbeddedResource Include="Public\NoArrowsRandom.png" />
<EmbeddedResource Include="Public\OneColor.png" />
<Content Include="Public\OneColor.svg" />
<EmbeddedResource Include="UI\AlternativePlayView.bsml" />
<EmbeddedResource Include="UI\PlayModeSelectTab.bsml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="UI\AlternativePlayView.bsml" />
<EmbeddedResource Include="UI\PlayModeSelectView.bsml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="UI\DarthMaulView.bsml" />
Expand Down
63 changes: 29 additions & 34 deletions AlternativePlay/BeatFlailBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ public class BeatFlailBehavior : MonoBehaviour
public void BeginGameCoreScene()
{
// Do nothing if we aren't playing Flail
if (Configuration.instance.ConfigurationData.PlayMode != PlayMode.BeatFlail) { return; }
if (Configuration.Current.PlayMode != PlayMode.BeatFlail) { return; }

TrackedDeviceManager.instance.LoadTrackedDevices();

var config = Configuration.instance.ConfigurationData;
if (config.LeftFlailMode != BeatFlailMode.None)
if (Configuration.Current.LeftFlailMode != BeatFlailMode.None)
{
Utilities.CheckAndDisableForTrackerTransforms(config.LeftFlailTracker);
Utilities.CheckAndDisableForTrackerTransforms(Configuration.Current.LeftTracker);
}

if (config.RightFlailMode != BeatFlailMode.None)
if (Configuration.Current.RightFlailMode != BeatFlailMode.None)
{
Utilities.CheckAndDisableForTrackerTransforms(config.RightFlailTracker);
Utilities.CheckAndDisableForTrackerTransforms(Configuration.Current.RightTracker);
}

this.StartCoroutine(this.DisableSaberMeshes());
Expand All @@ -51,27 +50,25 @@ public void BeginGameCoreScene()
private void Awake()
{
// Do nothing if we aren't playing Flail
if (Configuration.instance.ConfigurationData.PlayMode != PlayMode.BeatFlail) { return; }
if (Configuration.Current.PlayMode != PlayMode.BeatFlail) { return; }

// Create the GameObjects used for physics calculations
var config = Configuration.instance.ConfigurationData;
this.leftPhysicsFlail = this.CreatePhysicsChain("Left", config.LeftFlailLength / 100.0f);
this.rightPhysicsFlail = this.CreatePhysicsChain("Right", config.RightFlailLength / 100.0f);
this.leftLinkMeshes = Utilities.CreateLinkMeshes(this.leftPhysicsFlail.Count, config.LeftFlailLength / 100.0f);
this.leftPhysicsFlail = this.CreatePhysicsChain("Left", Configuration.Current.LeftFlailLength / 100.0f);
this.rightPhysicsFlail = this.CreatePhysicsChain("Right", Configuration.Current.RightFlailLength / 100.0f);
this.leftLinkMeshes = Utilities.CreateLinkMeshes(this.leftPhysicsFlail.Count, Configuration.Current.LeftFlailLength / 100.0f);
this.leftHandleMesh = GameObject.Instantiate(BehaviorCatalog.instance.AssetLoaderBehavior.FlailHandlePrefab);
this.rightLinkMeshes = Utilities.CreateLinkMeshes(this.rightPhysicsFlail.Count, config.RightFlailLength / 100.0f);
this.rightLinkMeshes = Utilities.CreateLinkMeshes(this.rightPhysicsFlail.Count, Configuration.Current.RightFlailLength / 100.0f);
this.rightHandleMesh = GameObject.Instantiate(BehaviorCatalog.instance.AssetLoaderBehavior.FlailHandlePrefab);
}

private void FixedUpdate()
{
// Do nothing if we aren't playing Flail
if (Configuration.instance.ConfigurationData.PlayMode != PlayMode.BeatFlail) { return; }
if (Configuration.Current.PlayMode != PlayMode.BeatFlail) { return; }

var config = Configuration.instance.ConfigurationData;
float gravity = config.FlailGravity * -9.81f;
float gravity = Configuration.Current.Gravity * -9.81f;

switch(config.LeftFlailMode)
switch(Configuration.Current.LeftFlailMode)
{
default:
case BeatFlailMode.Flail:
Expand All @@ -84,7 +81,7 @@ private void FixedUpdate()

// Apply motion force from the left controller
var leftFirstLink = this.leftPhysicsFlail.First();
Pose leftSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetLeftSaberPose(config.LeftFlailTracker);
Pose leftSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetLeftSaberPose(Configuration.Current.LeftTracker);
leftFirstLink.transform.position = leftSaberPose.position * 10.0f;
leftFirstLink.transform.rotation = leftSaberPose.rotation * Quaternion.Euler(0.0f, 90.0f, 0.0f);
break;
Expand All @@ -95,7 +92,7 @@ private void FixedUpdate()
break;
}

switch (config.RightFlailMode)
switch (Configuration.Current.RightFlailMode)
{
default:
case BeatFlailMode.Flail:
Expand All @@ -108,7 +105,7 @@ private void FixedUpdate()

// Apply motion force from the right controller
var rightFirstLink = this.rightPhysicsFlail.First();
Pose rightSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetRightSaberPose(config.RightFlailTracker);
Pose rightSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetRightSaberPose(Configuration.Current.RightTracker);
rightFirstLink.transform.position = rightSaberPose.position * 10.0f;
rightFirstLink.transform.rotation = rightSaberPose.rotation * Quaternion.Euler(0.0f, 90.0f, 0.0f);
break;
Expand All @@ -123,10 +120,9 @@ private void FixedUpdate()
private void Update()
{
// Do nothing if we aren't playing Flail
if (Configuration.instance.ConfigurationData.PlayMode != PlayMode.BeatFlail) { return; }
if (Configuration.Current.PlayMode != PlayMode.BeatFlail) { return; }

var config = Configuration.instance.ConfigurationData;
switch (config.LeftFlailMode)
switch (Configuration.Current.LeftFlailMode)
{
default:
case BeatFlailMode.Flail:
Expand All @@ -136,11 +132,11 @@ private void Update()
BehaviorCatalog.instance.SaberDeviceManager.SetLeftSaberPose(leftLastLinkPose);

// Move all links into place
Utilities.MoveLinkMeshes(this.leftLinkMeshes, this.leftPhysicsFlail, (float)config.LeftFlailLength / 100f);
Utilities.MoveLinkMeshes(this.leftLinkMeshes, this.leftPhysicsFlail, (float)Configuration.Current.LeftFlailLength / 100f);

// Move handle based on the original saber position
Pose leftSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetLeftSaberPose(config.LeftFlailTracker);
float oneChainDistance = config.LeftFlailLength / 100.0f / (leftPhysicsFlail.Count - 1);
Pose leftSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetLeftSaberPose(Configuration.Current.LeftTracker);
float oneChainDistance = Configuration.Current.LeftFlailLength / 100.0f / (this.leftPhysicsFlail.Count - 1);
Vector3 moveHandleUp = leftSaberPose.rotation * new Vector3(0.0f, 0.0f, oneChainDistance); // Move handle forward one chain length
this.leftHandleMesh.transform.position = leftSaberPose.position + moveHandleUp;
this.leftHandleMesh.transform.rotation = leftSaberPose.rotation;
Expand All @@ -152,11 +148,11 @@ private void Update()

case BeatFlailMode.None:
// Remove the sword
BehaviorCatalog.instance.SaberDeviceManager.SetLeftSaberPose(leftHiddenPose);
BehaviorCatalog.instance.SaberDeviceManager.SetLeftSaberPose(this.leftHiddenPose);
break;
}

switch (config.RightFlailMode)
switch (Configuration.Current.RightFlailMode)
{
default:
case BeatFlailMode.Flail:
Expand All @@ -166,11 +162,11 @@ private void Update()
BehaviorCatalog.instance.SaberDeviceManager.SetRightSaberPose(rightLastLinkPose);

// Move all links into place
Utilities.MoveLinkMeshes(this.rightLinkMeshes, this.rightPhysicsFlail, config.RightFlailLength / 100.0f);
Utilities.MoveLinkMeshes(this.rightLinkMeshes, this.rightPhysicsFlail, Configuration.Current.RightFlailLength / 100.0f);

// Move handle based on the original saber position
Pose rightSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetRightSaberPose(config.RightFlailTracker);
float oneChainDistance = config.RightFlailLength / 100.0f / (rightPhysicsFlail.Count - 1);
Pose rightSaberPose = BehaviorCatalog.instance.SaberDeviceManager.GetRightSaberPose(Configuration.Current.RightTracker);
float oneChainDistance = Configuration.Current.RightFlailLength / 100.0f / (this.rightPhysicsFlail.Count - 1);
Vector3 moveHandleUp = rightSaberPose.rotation * new Vector3(0.0f, 0.0f, oneChainDistance); // Move handle forward one chain length
this.rightHandleMesh.transform.position = rightSaberPose.position + moveHandleUp;
this.rightHandleMesh.transform.rotation = rightSaberPose.rotation;
Expand All @@ -182,7 +178,7 @@ private void Update()

case BeatFlailMode.None:
// Remove the sword
BehaviorCatalog.instance.SaberDeviceManager.SetRightSaberPose(rightHiddenPose);
BehaviorCatalog.instance.SaberDeviceManager.SetRightSaberPose(this.rightHiddenPose);
break;
}
}
Expand Down Expand Up @@ -238,13 +234,12 @@ private IEnumerator DisableSaberMeshes()
{
yield return new WaitForSecondsRealtime(0.1f);

var config = Configuration.instance.ConfigurationData;
if (config.LeftFlailMode == BeatFlailMode.None)
if (Configuration.Current.LeftFlailMode == BeatFlailMode.None)
{
BehaviorCatalog.instance.SaberDeviceManager.DisableLeftSaberMesh();
}

if (config.RightFlailMode == BeatFlailMode.None)
if (Configuration.Current.RightFlailMode == BeatFlailMode.None)
{
BehaviorCatalog.instance.SaberDeviceManager.DisableRightSaberMesh();
}
Expand Down
37 changes: 16 additions & 21 deletions AlternativePlay/BeatSaberBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,59 @@ public class BeatSaberBehavior : MonoBehaviour
public void BeginGameCoreScene()
{
// Do nothing if we aren't playing Beat Saber
var config = Configuration.instance.ConfigurationData;
if (config.PlayMode != PlayMode.BeatSaber) { return; }
if (Configuration.Current.PlayMode != PlayMode.BeatSaber) { return; }

Utilities.CheckAndDisableForTrackerTransforms(Configuration.instance.ConfigurationData.LeftSaberTracker);
Utilities.CheckAndDisableForTrackerTransforms(Configuration.instance.ConfigurationData.RightSaberTracker);
Utilities.CheckAndDisableForTrackerTransforms(Configuration.Current.LeftTracker);
Utilities.CheckAndDisableForTrackerTransforms(Configuration.Current.RightTracker);

this.StartCoroutine(this.DisableOtherSaberMesh());
}

private void Update()
{
var config = Configuration.instance.ConfigurationData;
if (config.PlayMode != PlayMode.BeatSaber) return;
if (Configuration.Current.PlayMode != PlayMode.BeatSaber) return;

this.UpdateLeftSaber();
this.UpdateRightSaber();
}

private void UpdateLeftSaber()
{
var config = Configuration.instance.ConfigurationData;
var saberDeviceManager = BehaviorCatalog.instance.SaberDeviceManager;

if (config.OneColor && config.RemoveOtherSaber && !config.UseLeftSaber)
if (Configuration.Current.OneColor && Configuration.Current.RemoveOtherSaber && !Configuration.Current.UseLeft)
{
// Move the other saber away since there's a bug in the base game which makes it
// able to cut bombs still
saberDeviceManager.SetLeftSaberPose(hiddenPose);
saberDeviceManager.SetLeftSaberPose(this.hiddenPose);
return;
}

// Move the left saber if we are reversing it or it was assigned a tracker
if (config.ReverseLeftSaber || !String.IsNullOrWhiteSpace(config.LeftSaberTracker.Serial))
if (Configuration.Current.ReverseLeftSaber || !String.IsNullOrWhiteSpace(Configuration.Current.LeftTracker.Serial))
{
Pose leftSaberPose = saberDeviceManager.GetLeftSaberPose(config.LeftSaberTracker);
saberDeviceManager.SetLeftSaberPose(config.ReverseLeftSaber ? leftSaberPose.Reverse() : leftSaberPose);
Pose leftSaberPose = saberDeviceManager.GetLeftSaberPose(Configuration.Current.LeftTracker);
saberDeviceManager.SetLeftSaberPose(Configuration.Current.ReverseLeftSaber ? leftSaberPose.Reverse() : leftSaberPose);
}
}

private void UpdateRightSaber()
{
var config = Configuration.instance.ConfigurationData;
var saberDeviceManager = BehaviorCatalog.instance.SaberDeviceManager;

if (config.OneColor && config.RemoveOtherSaber && config.UseLeftSaber)
if (Configuration.Current.OneColor && Configuration.Current.RemoveOtherSaber && Configuration.Current.UseLeft)
{
// Move the other saber away since there's a bug in the base game which makes it
// able to cut bombs still
saberDeviceManager.SetRightSaberPose(hiddenPose);
saberDeviceManager.SetRightSaberPose(this.hiddenPose);
return;
}

// Move the right saber if we are reversing it or it was assigned a tracker
if (config.ReverseRightSaber || !String.IsNullOrWhiteSpace(config.RightSaberTracker.Serial))
if (Configuration.Current.ReverseRightSaber || !String.IsNullOrWhiteSpace(Configuration.Current.RightTracker.Serial))
{
Pose rightSaberPose = saberDeviceManager.GetRightSaberPose(config.RightSaberTracker);
saberDeviceManager.SetRightSaberPose(config.ReverseRightSaber ? rightSaberPose.Reverse() : rightSaberPose);
Pose rightSaberPose = saberDeviceManager.GetRightSaberPose(Configuration.Current.RightTracker);
saberDeviceManager.SetRightSaberPose(Configuration.Current.ReverseRightSaber ? rightSaberPose.Reverse() : rightSaberPose);
}
}

Expand All @@ -82,10 +78,9 @@ private IEnumerator DisableOtherSaberMesh()
{
yield return new WaitForSecondsRealtime(0.1f);

var config = Configuration.instance.ConfigurationData;
if (!(config.OneColor && config.RemoveOtherSaber)) { yield break; }
if (!(Configuration.Current.OneColor && Configuration.Current.RemoveOtherSaber)) { yield break; }

if (config.UseLeftSaber)
if (Configuration.Current.UseLeft)
{
BehaviorCatalog.instance.SaberDeviceManager.DisableRightSaberMesh();
}
Expand Down
Loading

0 comments on commit 3f8e591

Please sign in to comment.