예제 #1
0
    public override void Convert()
    {
        if (HasPower && IsOn && furnaceHeatingFormula.TryCombine())
        {
            FlexData.Heat.Push(heatProductionPerTickUnits);
        }

        RefreshFurnaceGlow();

        if (FlexData.Heat.CurrentAmount >= minimumHeat &&
            FlexData.CurrentOre != Matter.Unspecified &&
            Data.Containers[FlexData.CurrentOre].CurrentAmount >= oreMeltPerTickUnits)
        {
            float purity = Data.Containers[FlexData.CurrentOre].AvgPurity;
            Data.Containers[FlexData.CurrentOre].Pull(oreMeltPerTickUnits);

            if (capturedPowder == null)
            {
#warning furnace does not create powder crate yet if none assigned
                var newT = BounceLander.CreateCratelike(FlexData.CurrentOre.MatchingPowder(), 0f, powderSnap.transform.position);
                newT.GetComponent <ResourceComponent>();
            }
            else
            {
                capturedPowder.Data.Container.Push(oreMeltPerTickUnits * purity);
            }
        }

        //thermal loss every tick
        if (FlexData.Heat.CurrentAmount > 0)
        {
            FlexData.Heat.Pull(heatLossPerTickUnits);
        }
    }
예제 #2
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);
        }
    }
예제 #3
0
    private void Pack(Order o)
    {
        this.Data = new DroneRoverData()
        {
            Delivery = o.LineItemUnits
        };

        int i = 0;

        foreach (Matter key in this.Data.Delivery.Keys)
        {
            var crateEnumerator = this.Data.Delivery.SquareMeters(key);
            while (crateEnumerator.MoveNext())
            {
                float volume = crateEnumerator.Current;

                int x, y, z;
                if (TryGetOpenSlot(out x, out y, out z))
                {
                    float xF = BedCrateSeparation;
                    if (x > 0)
                    {
                        xF = -xF;
                    }
                    Vector3 cratelikePosition = this.BedAnchor.localPosition - new Vector3(xF, y * -1f, z * 1f);
                    var     newCratelike      = BounceLander.CreateCratelike(key, volume, cratelikePosition, this.transform);
                    newCratelike.GetComponent <NavMeshObstacle>().enabled = false;
                    Slots[x, y, z] = newCratelike.GetComponent <IMovableSnappable>();
                }
                i++;
            }
        }
    }
예제 #4
0
    public void Deliver(Dictionary <Matter, int> supplies, Dictionary <Craftable, int> craftables)
    {
        int totalN = 0;

        foreach (KeyValuePair <Matter, int> supply in supplies)
        {
            float totalAmountToSpawnVolume = supply.Key.CubicMetersPerUnit() * supply.Value;
            while (totalAmountToSpawnVolume > 0)
            {
                Vector3 position            = GetSpiralPosition(totalN);
                float   amountToSpawnVolume = Mathf.Min(1f, totalAmountToSpawnVolume);
                BounceLander.CreateCratelike(supply.Key, amountToSpawnVolume, position);

                totalN++;
                totalAmountToSpawnVolume -= amountToSpawnVolume;
            }
        }
        foreach (KeyValuePair <Craftable, int> craftable in craftables)
        {
            int amountToSpawn = craftable.Value;
            while (amountToSpawn > 0)
            {
                Vector3 position = GetSpiralPosition(totalN);
                BounceLander.CreateCratelike(craftable.Key, position);

                totalN++;
                amountToSpawn--;
            }
        }
    }
예제 #5
0
 protected override void OnHarvestComplete(float harvestAmountUnits)
 {
     if (outputs[0] != null)
     {
         outputs[0].Data.Container.Push(harvestAmountUnits);
     }
     else if (outputs[1] != null)
     {
         outputs[1].Data.Container.Push(harvestAmountUnits);
     }
     else
     {
         ContainerSize size;
         if (GreenhouseScale == 1)
         {
             size = ContainerSize.Quarter;
         }
         else
         {
             size = ContainerSize.Full;
         }
         ResourceComponent res = BounceLander.CreateCratelike(Matter.Produce, harvestAmountUnits, defaultSnap.position, null, size).GetComponent <ResourceComponent>();
         res.SnapCrate(this, defaultSnap.position);
         outputs[0] = res;
     }
 }
예제 #6
0
 private void SpawnCraftable(Craftable craftable)
 {
     if (craftable.IsCraftableEVASuitComponent())
     {
         Game.Current.Player.PackData.SetUpgrade(craftable.ToEVASuitUpgrade());
         RefreshSuitDisplay();
     }
     else
     {
         BounceLander.CreateCratelike(craftable, this.SpawnPosition.position);
     }
 }
예제 #7
0
    protected override void OnHarvestComplete(float harvestAmountUnits)
    {
        if (capturedResource == null)
        {
            capturedResource = BounceLander.CreateCratelike(Matter.Produce, 0f, CrateAnchor.position, size: ContainerSize.Quarter).GetComponent <ResourceComponent>();
            //capturedResource.RefreshLabel();
            capturedResource.SnapCrate(this, CrateAnchor.position);
        }

        if (capturedResource.Data.Container.AvailableCapacity >= harvestAmountUnits)
        {
            capturedResource.Data.Container.Push(harvestAmountUnits);
        }
    }
예제 #8
0
    public override void InitializeStartingData()
    {
        base.InitializeStartingData();

        if (attachedDeposit == null)
        {
            UnityEngine.Debug.LogWarning("Ore extractor started with no attached deposit!");
        }
        else
        {
            FlexData.DepositInstanceID = attachedDeposit.Data.DepositInstanceID;
            BounceLander.CreateCratelike(attachedDeposit.Data.Extractable.MatterType, 0f, this.CrateSnapAnchor.position);
        }
    }
예제 #9
0
    //grabber top, grabber bottom, unlatch, grabber top
    private IEnumerator SetDownOnGround(int y)
    {
        Vector3 targetBottomPositions = y == 1 ? grabberGroundBottomPosition : grabberGroundTopPosition;

        yield return(MoveGrabber(grabberTopPosition, targetBottomPositions));

        yield return(Latch(false));

        if (currentlyGrabbedCratelike != null)
        {
            currentlyGrabbedCratelike.GetComponent <NavMeshObstacle>().enabled = true;
            BounceLander.EnlivenCratelike(currentlyGrabbedCratelike);
            currentlyGrabbedCratelike = null;
        }

        yield return(MoveGrabber(targetBottomPositions, grabberTopPosition));
    }
예제 #10
0
    /// <summary>
    /// landing sequence
    /// </summary>
    /// <returns></returns>
    private IEnumerator DoLand()
    {
        Lander.gameObject.SetActive(true);

        yield return(DoFly(airborneLanderPosition, landedLanderLocalPosition));

        bool turnedLightsOn = false;

        if (Game.Current.Environment.CurrentHour > 20 || Game.Current.Environment.CurrentHour < 6)
        {
            this.LZ.ToggleLights(true);
            turnedLightsOn = true;
        }

        yield return(DoFireRockets(airborneLanderHinge, landedLanderHinge));

        int i = 0;

        TriggerForwarder[] slots = new TriggerForwarder[Bays.Keys.Count];
        Bays.Keys.CopyTo(slots, 0);
        foreach (Matter key in this.Data.Delivery.Keys)
        {
            var crateEnumerator = this.Data.Delivery.SquareMeters(key);
            while (crateEnumerator.MoveNext())
            {
                float volume = crateEnumerator.Current;

                TriggerForwarder child = slots[i];

                var t = BounceLander.CreateCratelike(key, volume, Vector3.zero, this.Lander);

                Bays[child] = t.GetComponent <ResourceComponent>();

                i++;
            }
        }
        this.Data.Delivery = null;

        foreach (var kvp in Bays)
        {
            if (kvp.Value != null)
            {
                kvp.Value.transform.SetParent(null);
                kvp.Value.SnapCrate(this, kvp.Key.transform.position, globalRotation: kvp.Key.transform.rotation);
                kvp.Value.GetComponent <Collider>().enabled = true;
            }
        }

        SetState(FlightState.Landed);

        yield return(new WaitForSeconds(3f));

        doorSource.Play();
        if (!rampsDown)
        {
            ToggleAllRamps();
        }

        yield return(new WaitForSeconds(DoorMoveDuration));

        doorSource.Stop();

        if (turnedLightsOn)
        {
            this.LZ.ToggleLights(false);
        }

        movement = null;
    }