コード例 #1
0
    private IEnumerator FinishPrinting(bool success)
    {
        laser.enabled = false;
        currentPrintRenderer.enabled = false;

        if (success)
        {
            BounceLander.CreateCratelike(FlexData.Printing, 1f, this.transform.TransformPoint(crateStartLocalPosition));
            GuiBridge.Instance.ShowNews(NewsSource.PrintingComplete);
        }

        FlexData.Printing = Matter.Unspecified;
        FlexData.Progress = 0f;

        if (GuiBridge.Instance.Printer.Showing)
        {
            GuiBridge.Instance.Printer.SetShowing(true, this);
        }

        SunOrbit.Instance.ResetToNormalTime();

        MainMenu.LerpContext reset = new MainMenu.LerpContext()
        {
            Space = Space.Self
        };
        reset.Seed(printArm.localPosition, resetPosition, 2f);
        while (!reset.Done)
        {
            reset.Tick(printArm);
            printArmHarness.localPosition = new Vector3(0f, 0f, printArm.localPosition.z);
            yield return(null);
        }
    }
コード例 #2
0
    private IEnumerator ArmPrint()
    {
        MainMenu.LerpContext armY = new MainMenu.LerpContext()
        {
            Space = Space.Self
        };
        MainMenu.LerpContext headX = GetNextHead();
        float alreadyPassed        = FlexData.Progress * FlexData.Duration;

        armY.Seed(Vector3.up * minArmY, Vector3.up * maxArmY, FlexData.Duration - alreadyPassed, _time: alreadyPassed);
        bool back = false;

        laser.enabled = true;
        int skipCounter = 0;

        while (!armY.Done)
        {
            if (scrapFlag)
            {
                scrapFlag = false;
                yield return(FinishPrinting(false));

                yield break;
            }

            FlexData.Progress = armY.T;

            while (!HasPower || !IsOn)
            {
                skipCounter++;
                yield return(new WaitForSeconds(1f));

                if (skipCounter > 60 * 4)
                {
                    GuiBridge.Instance.ShowNews(NewsSource.PrintingStallCancel);
                    yield return(FinishPrinting(false));

                    yield break;
                }
            }

            armY.Tick(printArm);
            headX.Tick(printHead);
            printArm.localPosition        = new Vector3(printArm.localPosition.x, printArm.localPosition.y, back ? Mathf.Lerp(minArmZ, maxArmZ, headX.T) : Mathf.Lerp(maxArmZ, minArmZ, headX.T));
            printArmHarness.localPosition = new Vector3(0f, 0f, printArm.localPosition.z);
            UpdateLaser();
            currentPrintRenderer.material.SetFloat("_showPercentY", armY.T * 100f);

            yield return(null);

            if (headX.Done)
            {
                headX = GetNextHead();
                back  = !back;
            }
        }

        yield return(FinishPrinting(true));
    }
コード例 #3
0
    private MainMenu.LerpContext GetNextHead()
    {
        var lerp = new MainMenu.LerpContext()
        {
            Space = Space.Self
        };

        lerp.Seed(printHead.localPosition, new Vector3(UnityEngine.Random.Range(minHeadX, maxHeadX), 0f, 0f), 1f);
        return(lerp);
    }