Beispiel #1
0
    public override void Awake()
    {
        try
        {
            base.Awake();

            autoSetup = new SnugAutoSetup(context.containingAtom, this);

            disableSelfGrabJSON = new JSONStorableBool("DisablePersonGrab", false);
            falloffJSON         = new JSONStorableFloat("Falloff", 0.3f, 0f, 5f, false);

            _lHand = new SnugHand {
                controller = containingAtom.freeControllers.FirstOrDefault(fc => fc.name == "lHandControl")
            };
            _rHand = new SnugHand {
                controller = containingAtom.freeControllers.FirstOrDefault(fc => fc.name == "rHandControl")
            };

            InitAnchors();
            InitVisualCues();
        }
        catch (Exception exc)
        {
            SuperController.LogError($"{nameof(SnugModule)}.{nameof(Awake)}: {exc}");
        }
    }
Beispiel #2
0
    public bool Apply()
    {
        var autoSetup = new SnugAutoSetup(context.containingAtom, context.snug);

        autoSetup.AutoSetup();

        context.trackers.motionControls.First(mc => mc.name == MotionControlNames.LeftHand).enabled  = false;
        context.trackers.motionControls.First(mc => mc.name == MotionControlNames.RightHand).enabled = false;
        var lElbowControl = context.trackers.motionControls.FirstOrDefault(mc => mc.mappedControllerName == "lElbowControl");

        if (lElbowControl != null)
        {
            lElbowControl.enabled = false;
        }
        var rElbowControl = context.trackers.motionControls.FirstOrDefault(mc => mc.mappedControllerName == "rElbowControl");

        if (rElbowControl != null)
        {
            rElbowControl.enabled = false;
        }
        context.embody.activeJSON.val = true;

        var idx = _steps.IndexOf(this);

        if (idx == -1)
        {
            throw new InvalidOperationException($"{nameof(AskSnugStep)} was not found in the steps list");
        }
        // _steps.Insert++idx, (new MeasureHandsPaddingStep(context));
        {
            var anchor = context.snug.anchorPoints.First(a => a.id == "Head");
            _steps.Insert(++idx, new MeasureAnchorWidthStep(context, anchor, 100));
            _steps.Insert(++idx, new MeasureAnchorDepthAndOffsetStep(context, anchor, -10));
        }
        {
            var anchor = context.snug.anchorPoints.First(a => a.id == "Chest");
            _steps.Insert(++idx, new MeasureAnchorWidthStep(context, anchor, -20, true));
            _steps.Insert(++idx, new MeasureAnchorDepthAndOffsetStep(context, anchor, -10));
        }
        {
            var anchor = context.snug.anchorPoints.First(a => a.id == "Abdomen");
            _steps.Insert(++idx, new MeasureAnchorWidthStep(context, anchor, -20));
            _steps.Insert(++idx, new MeasureAnchorDepthAndOffsetStep(context, anchor, 10));
        }
        {
            var anchor = context.snug.anchorPoints.First(a => a.id == "Hips");
            _steps.Insert(++idx, new MeasureAnchorWidthStep(context, anchor, -60));
            _steps.Insert(++idx, new MeasureAnchorDepthAndOffsetStep(context, anchor, 70));
        }
        {
            var anchor = context.snug.anchorPoints.First(a => a.id == "Thighs");
            _steps.Insert(++idx, new MeasureArmsAtRestStep(context, anchor));
        }
        _steps.Insert(++idx, new FinishSnugSetupStep(context));

        return(true);
    }
Beispiel #3
0
    public override void Awake()
    {
        try
        {
            base.Awake();

            autoSetup = new SnugAutoSetup(context.containingAtom, this);

            _lHand = new SnugHand {
                controller = containingAtom.freeControllers.FirstOrDefault(fc => fc.name == "lHandControl")
            };
            _rHand = new SnugHand {
                controller = containingAtom.freeControllers.FirstOrDefault(fc => fc.name == "rHandControl")
            };

            InitAnchors();
            InitVisualCues();
        }
        catch (Exception exc)
        {
            SuperController.LogError($"{nameof(SnugModule)}.{nameof(Awake)}: {exc}");
        }
    }
Beispiel #4
0
    public override void InitReferences()
    {
        base.InitReferences();

        autoSetup = new SnugAutoSetup(context.containingAtom, this);

        _lHand = new SnugHand {
            controller = containingAtom.freeControllers.First(fc => fc.name == "lHandControl")
        };
        _rHand = new SnugHand {
            controller = containingAtom.freeControllers.First(fc => fc.name == "rHandControl")
        };

        _lToe = context.bones.First(b => b.name == "lToe");
        _rToe = context.bones.First(b => b.name == "rToe");

        foreach (var anchorPoint in anchorPoints)
        {
            anchorPoint.scaleChangeReceiver = context.scaleChangeReceiver;
            anchorPoint.bone = anchorPoint.initBone();
            anchorPoint.Update();
        }
    }
Beispiel #5
0
    private IEnumerator StartWizardCo()
    {
        embody.activeJSON.val = false;
        context.Initialize();

        yield return(0);

        var wizardContext = new WizardContext
        {
            embody  = embody,
            context = context
        };

        if (worldScale.selectedJSON.val)
        {
            SuperController.singleton.worldScale = 1f;
        }

        if (snug.selectedJSON.val)
        {
            if (passenger.selectedJSON.val)
            {
                StopWizard("You cannot run the wizard with Passenger selected.");
                yield break;
            }

            var autoSetup = new SnugAutoSetup(context.containingAtom, snug);
            autoSetup.AutoSetup();
        }

        var steps = new List <IWizardStep>();

        if (worldScale.selectedJSON.val)
        {
            steps.Add(new RecordPlayerHeightStep(worldScale));
        }

        if (snug.selectedJSON.val)
        {
            // TODO: Load pose
            steps.Add(new MeasureHandsPaddingStep(wizardContext));
            steps.Add(new ActivateWithoutSnugStep(embody, snug));
            var hipsAnchor = snug.anchorPoints.First(a => a.label == "Hips");
            steps.Add(new MeasureAnchorWidthStep(wizardContext, "hips", hipsAnchor));
            steps.Add(new MeasureAnchorDepthAndOffsetStep(wizardContext, "hips", hipsAnchor));
            steps.Add(new EnableSnugStep(embody, snug));
        }
        else
        {
            steps.Add(new ActivateStep(embody));
        }

        if (steps.Count == 0)
        {
            StopWizard("None of the selected modules use the wizard.\n\nNothing to setup, moving on!");
            yield break;
        }

        for (var i = 0; i < steps.Count; i++)
        {
            var step       = steps[i];
            var stepUpdate = step as IWizardUpdate;
            statusJSON.val = $"Step {i + 1} / {steps.Count}\n\n{step.helpText}";
            while (!AreAnyStartRecordKeysDown())
            {
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    StopWizard("Wizard canceled");
                    yield break;
                }

                yield return(0);

                stepUpdate?.Update();
            }

            step.Run();
        }

        StopWizard("All done! You can now activate Embody.");
    }