Skip to content

Commit

Permalink
feat(input): add interaction to planter (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenira committed Jan 27, 2024
1 parent 292b565 commit 85ed0ff
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: plugin
path: |
Expand All @@ -55,7 +55,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: plugin
- name: Copy Files
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- name: Download release artifact
if: ${{ steps.release.outputs.release_created }}
uses: actions/download-artifact@v4
with:
name: release-artifact
path: artifact
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.DEPENDENCY_TOKEN }}
- id: release
uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
config-file: release-please-config.json
- name: Download release artifact
if: ${{ steps.release.outputs.release_created }}
uses: dawidd6/action-download-artifact@v3
with:
workflow: "dotnet.yml"
name: release-artifact
skip_unpack: true
- name: Download Tobey.UnityAudio
if: ${{ steps.release.outputs.release_created }}
uses: dsaltares/fetch-gh-release-asset@1.1.1
Expand All @@ -38,8 +39,6 @@ jobs:
- name: Zip release artifact
if: ${{ steps.release.outputs.release_created }}
run: |
mkdir artifact
unzip release-artifact.zip -d ./artifact/
cd artifact && npx downdoc README.adoc && zip -r techtonica_vr-${{ steps.release.outputs.tag_name }}-thunderstore.zip ./ && cd ..
mv artifact/techtonica_vr-${{ steps.release.outputs.tag_name }}-thunderstore.zip .
rm artifact/README.md
Expand Down
2 changes: 0 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ While the mod is in a playable state, it is still in early development. Some fea
- Hand crank using uhhhhh... hands?

=== Known Issues
- Button prompts are not for VR controllers. (#13)
- Haptics are played on both controllers by the game. One improvement would be to play them on the hand that is actually holding the tool.
- The game is locked to 60fps when running in windowed mode. This is based on the refresh rate of your monitor. To unlock the framerate, switch to fullscreen mode. (#10)
- Menus are a little jittery (#18)

=== Cool stuff to try
- Tobii eye tracking for dynamic foveated rendering
Expand Down
40 changes: 40 additions & 0 deletions plugin/src/input/ui/machine/PlanterInteractableUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Linq;
using TechtonicaVR.Util;
using UnityEngine;

namespace TechtonicaVR.Input.Ui.Machine;

public class PlanterInteractableUi : InventoryInteractableUI
{
private static PluginLogger Logger = PluginLogger.GetLogger<PlanterInteractableUi>();

public PlanterInteractableUi(GameObject gameObject) : base(gameObject)
{
zIndex = 0.001f;

interactable = gameObject.GetComponentsInChildren<InventoryResourceSlotUI>().Select(getInteractable).ToList();
Logger.LogDebug($"Interactable: {rectTransform.rect}");
}

protected override void init()
{
}

private Interactable getInteractable(InventoryResourceSlotUI slot)
{
var rectTransform = slot.GetComponent<RectTransform>();
var rect = getRect(rectTransform);
Logger.LogDebug($"Slot rect: {slot} {rect} {rectTransform.localPosition}");

return new InteractableBuilder(this, rect, rectTransform.gameObject)
.withRecalculate(() => getRect(rectTransform))
.withDrag(() => draggedResourceInfo ?? slot.resourceType,
(ui) => onDrag(slot),
(ui, source, target) => onDrop(ui, target, slot),
(ui) => onCancelDrag(slot))
.withDrop(onAcceptsDrop, (ui, source) => onReceiveDrop(source, slot))
.withHoverEnter((ui) => onHoverEnter(slot))
.withHoverExit((ui) => onHoverExit(slot))
.build();
}
}
8 changes: 8 additions & 0 deletions plugin/src/ui/patch/UiMenuPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ private static void addInteractableUi(UIMenu instance)
menu = new UIMenuWrapper(instance)
};
}
else if (instance is PlanterUI)
{
var container = GameObjectFinder.FindChildObjectByName("Content Container", instance.gameObject);
new PlanterInteractableUi(container)
{
menu = new UIMenuWrapper(instance)
};
}
}

private static void disableButtonPrompts(UIMenu __instance)
Expand Down

0 comments on commit 85ed0ff

Please sign in to comment.