Skip to content

Commit b5632d4

Browse files
authored
feat: 466 disallow lateral movement when inside brain (#473)
* Prevent lateral manipulator movement when inside brain * Disable lateral keyboard input
1 parent 4dcaab0 commit b5632d4

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

Assets/Scripts/TrajectoryPlanner/Probes/Controllers/CartesianProbeController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public override Vector4 UnlockedDir {
4646
private Vector3 _unlockedRot;
4747
public override Vector3 UnlockedRot
4848
{
49-
get
50-
{
51-
return _unlockedRot;
52-
}
49+
get => _unlockedRot;
5350
set
5451
{
5552
_unlockedRot = value;

Assets/Scripts/TrajectoryPlanner/Probes/ManipulatorBehaviorController.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ private void Awake()
110110
{
111111
// Start off as disabled
112112
enabled = false;
113+
114+
// Update manipulator inside brain state
115+
_probeController.MovedThisFrameEvent.AddListener(() =>
116+
{
117+
if (_isSetToInsideBrain != _probeManager.IsProbeInBrain())
118+
CommunicationManager.Instance.SetInsideBrain(ManipulatorID, _probeManager.IsProbeInBrain(),
119+
insideBrain =>
120+
{
121+
_isSetToInsideBrain = insideBrain;
122+
_probeController.UnlockedDir = insideBrain ? new Vector4(0, 0, 0, 1) : Vector4.one;
123+
});
124+
});
113125
}
114126

115127
private void OnDisable()
@@ -197,6 +209,7 @@ public bool IsRightHanded
197209
private bool _isSetToDropToSurfaceWithDepth = true;
198210
private bool _isRightHanded;
199211
private float _lastLoggedTime;
212+
private bool _isSetToInsideBrain;
200213

201214
#endregion
202215

@@ -364,22 +377,13 @@ public void MoveByWorldSpaceDelta(Vector4 worldSpaceDelta, Action<bool> onSucces
364377
{
365378
// Process depth movement
366379
var targetDepth = newPos.w + manipulatorSpaceDepth;
367-
CommunicationManager.Instance.SetInsideBrain(
368-
ManipulatorID, true, _ =>
380+
// Move the manipulator
381+
CommunicationManager.Instance.DriveToDepth(
382+
ManipulatorID, targetDepth, AUTOMATIC_MOVEMENT_SPEED,
383+
_ =>
369384
{
370-
// Move the manipulator
371-
CommunicationManager.Instance.DriveToDepth(
372-
ManipulatorID, targetDepth, AUTOMATIC_MOVEMENT_SPEED,
373-
_ =>
374-
{
375-
CommunicationManager.Instance.SetInsideBrain(
376-
ManipulatorID, false,
377-
_ =>
378-
{
379-
CommunicationManager.Instance.SetCanWrite(ManipulatorID, false, 0,
380-
onSuccessCallback, onErrorCallback);
381-
}, onErrorCallback);
382-
}, onErrorCallback);
385+
CommunicationManager.Instance.SetCanWrite(ManipulatorID, false, 0,
386+
onSuccessCallback, onErrorCallback);
383387
}, onErrorCallback);
384388
}, onErrorCallback);
385389
}, onErrorCallback);

0 commit comments

Comments
 (0)