Skip to content

Commit

Permalink
Inspection rotation call backs and add interactionfinder base
Browse files Browse the repository at this point in the history
  • Loading branch information
BDeshiDev committed Aug 8, 2024
1 parent 45ae349 commit b4c3131
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public override async UniTask DoInteraction(CancellationToken token)
{
await InspectionManager.Instance.ShowInspectable(this, token);
}

public virtual void HandleRotation(bool isRotationActive)
{

}


public void ToggleCamStacking(bool shouldCamStackingBeActive)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class InspectionManager:MonoBehaviourSingletonPersistent<InspectionManage

public Transform InspectionObjectParent;

[SerializeField] private PlayerInteractionFinder _subInteractionFinder;
[SerializeField] private InteractionFinderBase _subInteractionFinder;

private Transform _examinationObject;
private Transform _ogParent;
Expand All @@ -42,7 +42,7 @@ public class InspectionManager:MonoBehaviourSingletonPersistent<InspectionManage

protected override void Initialize()
{
_subInteractionFinder = GetComponentInChildren<PlayerInteractionFinder>();

}

private void Start()
Expand All @@ -54,7 +54,7 @@ private void Start()
InteractionManager.Instance.InputHandler.InteractCancelButton.AddPerformedCallback(gameObject, HandleInspectionCancelled);
InteractionManager.Instance.InputHandler.InspectResetButton.AddPerformedCallback(gameObject, HandleInspectResetPerformed);
}

public void HandleInspectResetPerformed()
{
if (_isInspecting && _examinationObject != null)
Expand Down Expand Up @@ -194,8 +194,6 @@ public void HandleInteractionInitialize(InspectableBase inspectable)
//urp camera stacking
ActivateInspectionCamStacking();

_subInteractionFinder.SetCam(_inspectionCamera);

_wantsToCancel = false;
_isDragging = false;
_isInspecting = true;
Expand Down Expand Up @@ -273,6 +271,8 @@ private void UpdateDrag(InspectableBase inspectableBase, Transform spawnedExamin
spawnedExaminationObject.RotateAround(spawnedExaminationObject.position, _inspectionCamera.transform.up, rotationAmountX);
spawnedExaminationObject.RotateAround(spawnedExaminationObject.position, _inspectionCamera.transform.right, rotationAmountY);
}

_curInspectable.HandleRotation(_isDragging);
}

public async UniTask ShowInspectable(InspectableBase inspectable, CancellationToken token)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Bdeshi.Helpers.Utility.Extensions;
using Studio23.SS2.InteractionSystem.Abstract;
using Studio23.SS2.InteractionSystem.Data;
using UnityEngine;

namespace Studio23.SS2.InteractionSystem.Core
{
/// <summary>
/// Looks for Interactables on scene based on camera position and orientation
/// </summary>
public abstract class InteractionFinderBase: MonoBehaviour
{
public abstract List<InteractableBase> FindInteractables();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Studio23.SS2.InteractionSystem.Core
/// <summary>
/// Looks for Interactables on scene based on camera position and orientation
/// </summary>
public class PlayerInteractionFinder: MonoBehaviour
public class PlayerInteractionFinder: InteractionFinderBase
{
public Vector3 InteractionFindDirection => _cam.transform.forward;
public Vector3 InteractionRayOrigin => _cam.transform.position;
Expand All @@ -34,7 +34,7 @@ private void Start()
/// Optimize if needed
/// </summary>
/// <returns> a list of interactables </returns>
public List<InteractableBase> FindInteractables()
public override List<InteractableBase> FindInteractables()
{
var mask = _interactionLayerMask | _obstacleLayerMask;
List<InteractableBase> results = new List<InteractableBase>();
Expand Down

0 comments on commit b4c3131

Please sign in to comment.