Ejemplo n.º 1
0
    private void PointCastParts(Vector2 clickPos)
    {
        List <RaycastHit2D> list = new List <RaycastHit2D>(Physics2D.RaycastAll(clickPos, Vector2.up, 0.01f, this.maskPartHibox));

        if (list.Count == 0)
        {
            return;
        }
        Transform transform = this.GetTopPart(list);

        while (transform.GetComponent <Part>() == null)
        {
            transform = transform.parent;
        }
        Part component = transform.GetComponent <Part>();

        if (component.vessel != Ref.mainVessel)
        {
            MsgController.ShowMsg("Cannot use a part on a rocket that you are not controlling");
            return;
        }
        if (!Ref.mainVessel.controlAuthority)
        {
            MsgController.ShowMsg("No control");
            return;
        }
        component.UsePart();
        if (Ref.inputController.instructionsPartsHolder.activeSelf && component.HasEngineModule())
        {
            Ref.inputController.instructionsPartsHolder.SetActive(false);
            Ref.inputController.CheckAllInstructions();
        }
    }
Ejemplo n.º 2
0
 public void ToggleRCS(Vessel vessel, bool showMsg)
 {
     if (!vessel.RCS)
     {
         if (this.rcsFuel.Count == 0)
         {
             MsgController.ShowMsg("No fuel source", showMsg);
             return;
         }
         if (!this.TakeFromAllFuelGrups(0.0))
         {
             MsgController.ShowMsg("Out of fuel", 2f, showMsg);
             return;
         }
     }
     vessel.RCS = !vessel.RCS;
     if (!vessel.RCS)
     {
         for (int i = 0; i < this.rcsModules.Count; i++)
         {
             this.rcsModules[i].effect.SetTargetTime(0f);
         }
     }
     MsgController.ShowMsg("RCS " + ((!vessel.RCS) ? "Off" : "On"), showMsg);
 }
Ejemplo n.º 3
0
    public void ApplyTorqueForce(bool controlAuthority, ref float horizontalAxis, Vessel vessel)
    {
        if (this.torque <= 0f)
        {
            return;
        }
        if (!controlAuthority)
        {
            if (Ref.mainVessel == vessel && Ref.inputController.horizontalAxis != 0f && MsgController.main.msgText.color.a < 0.6f)
            {
                MsgController.ShowMsg("No control");
            }
            horizontalAxis = 0f;
            return;
        }
        float num = this.torque / this.rb2d.mass / Time.fixedDeltaTime;

        if (Ref.mainVessel == vessel && Ref.inputController.horizontalAxis != 0f)
        {
            horizontalAxis             = Ref.inputController.horizontalAxis;
            this.rb2d.angularVelocity -= num * Ref.inputController.horizontalAxis * Time.fixedDeltaTime;
            return;
        }
        horizontalAxis             = Mathf.Clamp(this.rb2d.angularVelocity / (num * Time.fixedDeltaTime), -1f, 1f);
        this.rb2d.angularVelocity -= num * horizontalAxis * Time.fixedDeltaTime;
    }
Ejemplo n.º 4
0
    public void SelectCelestilaBodyAsTarget(CelestialBodyData newTarget)
    {
        CelestialBodyData celestialBodyData = this.targetPlanet;

        if (newTarget != celestialBodyData)
        {
            this.targetPlanet = newTarget;
            this.mapRefs[newTarget].nameIconText.text      = "►" + newTarget.bodyName + "◄";
            this.mapRefs[newTarget].nameIconText.fontStyle = FontStyle.BoldAndItalic;
            if (celestialBodyData != null)
            {
                this.mapRefs[celestialBodyData].nameIconText.text      = celestialBodyData.bodyName;
                this.mapRefs[celestialBodyData].nameIconText.fontStyle = FontStyle.Bold;
            }
            MsgController.ShowMsg(newTarget.bodyName + " set as target");
        }
        else if (celestialBodyData != null)
        {
            this.mapRefs[celestialBodyData].nameIconText.text      = celestialBodyData.bodyName;
            this.mapRefs[celestialBodyData].nameIconText.fontStyle = FontStyle.Bold;
            this.targetPlanet = null;
        }
        Ref.inputController.PlayClickSound(0.2f);
        this.CreateNewTransferWindow();
    }
Ejemplo n.º 5
0
 public void ToggleThrottle()
 {
     if (Ref.timeWarping)
     {
         MsgController.ShowMsg("Cannot toggle throttle while time warping");
         return;
     }
     if (!Ref.mainVessel.controlAuthority)
     {
         MsgController.ShowMsg("No control");
         return;
     }
     Ref.mainVessel.SetThrottle(new Vessel.Throttle(!Ref.mainVessel.throttle.throttleOn, Ref.mainVessel.throttle.throttleRaw));
     if (Ref.inputController.instructionToggleThrottleHolder.activeSelf)
     {
         Ref.inputController.instructionToggleThrottleHolder.SetActive(false);
         Ref.inputController.CheckAllInstructions();
     }
     if (Ref.mainVessel.throttle.throttleRaw != 0f)
     {
         foreach (EngineModule engineModule in Ref.mainVessel.partsManager.engineModules)
         {
             if (engineModule.engineOn.boolValue)
             {
                 return;
             }
         }
     }
     Ref.inputController.PlayClickSound(0.6f);
 }
Ejemplo n.º 6
0
    private void StartTouch(int fingerId, int i, Vector2 posPixel)
    {
        this.touchesInfo[fingerId].touchDownTime      = Time.time;
        this.touchesInfo[fingerId].lastFingerPosPixel = posPixel;
        GameObject gameObject = Ref.inputController.PointCastUI(posPixel, Ref.inputController.uIColliders);

        if (gameObject != null)
        {
            this.touchesInfo[fingerId].touchState      = global::Touch.TouchState.OnUI;
            this.touchesInfo[fingerId].touchDownButton = gameObject.transform;
            if (Ref.timeWarping && (gameObject.name == "Left Arrow Button" || gameObject.name == "Right Arrow Button"))
            {
                MsgController.ShowMsg("Cannot turn while time warping");
            }
        }
        else
        {
            this.touchesInfo[fingerId].touchState = global::Touch.TouchState.OnEmpty;
            Vector2 posWorld = Camera.main.ScreenToWorldPoint((Vector3)posPixel + Vector3.forward * -Ref.cam.transform.position.z);
            Ref.inputController.StartTouchEmpty(posWorld, fingerId);
            int lastOnEmptyId = this.GetLastOnEmptyId(i);
            if (lastOnEmptyId != -1)
            {
                this.zoomFinger1 = Input.GetTouch(i).fingerId;
                this.zoomFinger2 = lastOnEmptyId;
            }
        }
    }
Ejemplo n.º 7
0
    public void Delete(int tabIndex)
    {
        if (!this.PreCheck())
        {
            return;
        }
        MonoBehaviour.print("Deleted " + tabIndex);
        if (this.Deleting)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Wait_Request);
            return;
        }
        this.Deleting = true;
        DeletePacket toSend = new DeletePacket
        {
            Target = this.pagesIDS[tabIndex]
        };

        GameTracker.Tracker.client.AuthedRequest(toSend, delegate(DefaultPacket r)
        {
            SyncContext.RunOnUI(delegate
            {
                if (r.Success)
                {
                    MsgController.ShowMsg("Rocket deleted");
                    this.ReloadPage(null);
                }
                else
                {
                    MsgController.ShowMsg("Could not delete rocket because:\n" + r.Error);
                }
                this.Deleting = false;
            });
        });
    }
Ejemplo n.º 8
0
 public void CompleteLoadProcess()
 {
     Ref.SceneType currentScene = Ref.currentScene;
     if (currentScene != Ref.SceneType.Build)
     {
         if (currentScene == Ref.SceneType.Game)
         {
             GameSaving.Quicksaves quicksaves = GameSaving.Quicksaves.LoadQuicksaves();
             if (this.selectedSaveId != -1 && this.selectedSaveId < quicksaves.QuicksavesCount)
             {
                 GameSaving.LoadGame(quicksaves.quicksaves[this.selectedSaveId]);
                 MsgController.ShowMsg("Game Loaded");
                 this.CloseMenus();
             }
         }
     }
     else
     {
         Build.BuildQuicksaves buildQuicksaves = Build.BuildQuicksaves.LoadBuildQuicksaves();
         if (this.selectedSaveId != -1 && this.selectedSaveId < buildQuicksaves.QuicksavesCount)
         {
             Build.main.LoadSave(buildQuicksaves.buildSaves[this.selectedSaveId]);
             this.CloseMenus();
         }
     }
 }
Ejemplo n.º 9
0
 public static bool ConfirmSources(FlowModule[] resourceSources, bool showMsg)
 {
     FlowModule.State state = FlowModule.State.Flowing;
     for (int i = 0; i < resourceSources.Length; i++)
     {
         if (resourceSources[i].state != FlowModule.State.Flowing)
         {
             if (resourceSources[i].state == FlowModule.State.NoSource)
             {
                 if (showMsg)
                 {
                     MsgController.ShowMsg((resourceSources[i].state != FlowModule.State.NoSource) ? ("Out of " + Resource.GetResourceName(resourceSources[i].resourceType).ToLower()) : ("No " + Resource.GetResourceName(resourceSources[i].resourceType).ToLower() + " source"));
                 }
                 return(false);
             }
             if (resourceSources[i].state == FlowModule.State.NoResource)
             {
                 state = FlowModule.State.NoResource;
                 if (showMsg)
                 {
                     MsgController.ShowMsg((resourceSources[i].state != FlowModule.State.NoSource) ? ("Out of " + Resource.GetResourceName(resourceSources[i].resourceType).ToLower()) : ("No " + Resource.GetResourceName(resourceSources[i].resourceType).ToLower() + " source"));
                 }
             }
         }
     }
     return(state == FlowModule.State.Flowing);
 }
Ejemplo n.º 10
0
 public override void OnPartUsed()
 {
     if (Ref.timeWarping)
     {
         MsgController.ShowMsg((this.moveModule.targetTime.floatValue != this.closed) ? this.onTimeWarpWarningClose : this.onTimeWarpWarningOpen);
     }
     else
     {
         this.moveModule.SetTargetTime((this.moveModule.targetTime.floatValue != this.closed) ? this.closed : this.open);
     }
 }
Ejemplo n.º 11
0
 public override void OnPartUsed()
 {
     if (!Ref.timeWarping)
     {
         this.ToggleEngine(true);
     }
     else
     {
         MsgController.ShowMsg("Cannot toggle engine while time warping");
     }
 }
Ejemplo n.º 12
0
 private void ShowSwitchedPlanetMsg(CelestialBodyData newPlanet, CelestialBodyData oldPlanet)
 {
     if (oldPlanet.parentBody == newPlanet && oldPlanet != null)
     {
         MsgController.ShowMsg("Left " + oldPlanet.bodyName + " sphere of influence");
     }
     if (newPlanet.parentBody == oldPlanet)
     {
         MsgController.ShowMsg("Entered " + newPlanet.bodyName + " sphere of influence");
     }
 }
Ejemplo n.º 13
0
    public void SwitchVessel(Vessel newVessel)
    {
        if (newVessel == null || newVessel == Ref.mainVessel)
        {
            return;
        }
        this.viewPositons = Vector2.zero;
        Vessel mainVessel = Ref.mainVessel;

        Ref.mainVessel = newVessel;
        Ref.map.UpdateVesselsMapIcons();
        Double3           getGlobalPosition = newVessel.GetGlobalPosition;
        CelestialBodyData getVesselPlanet   = newVessel.GetVesselPlanet;

        Ref.map.SelectVessel(Ref.selectedVessel, true);
        this.RepositionFuelIcons();
        this.UpdateVesselButtons();
        Ref.map.following = new OrbitLines.Target(newVessel.GetVesselPlanet);
        Ref.map.UpdateMapPosition(newVessel.GetGlobalPosition / 10000.0);
        Ref.map.UpdateMapZoom(Ref.map.mapPosition.z);
        newVessel.SetThrottle(newVessel.throttle);
        bool flag = newVessel.GetGlobalPosition.magnitude2d < newVessel.GetVesselPlanet.radius + newVessel.GetVesselPlanet.minTimewarpHeightKm * 1000.0;

        foreach (Vessel vessel in Ref.controller.vessels)
        {
            vessel.SetVesselState(Vessel.ToState.ToUnloaded);
        }
        Vessel.ToState toState = (Ref.timeWarping && !flag) ? Vessel.ToState.ToTimewarping : Vessel.ToState.ToRealTime;
        Ref.planetManager.SwitchLocation(getVesselPlanet, getGlobalPosition, false, true, 0.0);
        if (Ref.timeWarping && flag)
        {
            this.timewarpPhase = 1;
            this.DecelerateTime();
            MsgController.ShowMsg("Cannot time warp below: " + newVessel.GetVesselPlanet.minTimewarpHeightKm.ToString() + "km");
        }
        else
        {
            if (toState == Vessel.ToState.ToRealTime)
            {
                bool   flag2 = this.GetEnableVelocityOffset(Ref.mainVessel);
                double x     = (!flag2) ? 0.0 : (Math.Floor((Math.Abs(Ref.mainVessel.GetGlobalVelocity.x) + 25.0) / 50.0) * 50.0 * (double)Math.Sign(Ref.mainVessel.GetGlobalVelocity.x));
                double y     = (!flag2) ? 0.0 : (Math.Floor((Math.Abs(Ref.mainVessel.GetGlobalVelocity.y) + 25.0) / 50.0) * 50.0 * (double)Math.Sign(Ref.mainVessel.GetGlobalVelocity.y));
                Ref.velocityOffset = new Double3(x, y);
            }
            Ref.mainVessel.SetVesselState(toState);
        }
        Ref.mainVessel.SetThrottle(new Vessel.Throttle(false, newVessel.throttle.throttleRaw));
        if (mainVessel != null)
        {
            Ref.map.SelectVessel(mainVessel, false);
        }
        Ref.planetManager.totalDistanceMoved += 100000.0;
    }
Ejemplo n.º 14
0
    public void Upvote(int tabIndex)
    {
        if (!this.PreCheck())
        {
            return;
        }
        if (this.Upvoting)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Wait_Request);
            return;
        }
        string ID = this.pages[tabIndex].ID;

        this.Upvoting = true;
        VotePacket toSend = new VotePacket
        {
            vote   = true,
            voteOn = ID
        };

        GameTracker.Tracker.client.AuthedRequest(toSend, delegate(DefaultPacket r)
        {
            SyncContext.RunOnUI(delegate
            {
                if (r.Success)
                {
                    VoteResponse voteResponse = r.ToTargetPacket <VoteResponse>();
                    Debug.Log(voteResponse.Action);
                    if (voteResponse.Action == "VOTE_PLACED")
                    {
                        MsgController.ShowMsg(SFST.T.Sharing_Vote_Placed);
                    }
                    else
                    {
                        MsgController.ShowMsg(SFST.T.Sharing_Vote_Revoked);
                    }
                    this.ReloadPage(delegate
                    {
                        RocketPost post = this.GetPost(ID);
                        if (post != null)
                        {
                            post.PlayAnimation();
                        }
                    });
                }
                else
                {
                    MsgController.ShowMsg(SFST.T.Sharing_Vote_Failed);
                }
                this.Upvoting = false;
            });
        });
    }
Ejemplo n.º 15
0
        public void StartConnection(Action after)
        {
            this.doAfterFetch = after;
            MasterInfo masterInfo = MasterInfo.Fetch();

            if (masterInfo == null)
            {
                if (GameTracker.mgcache0 == null)
                {
                    GameTracker.mgcache0 = new Action <string>(MsgController.ShowMsg);
                }
                SyncContext.RunOnUI <string>(GameTracker.mgcache0, SFST.T.STP_Request_Timeout);
                return;
            }
            this.client = new Client(masterInfo.REDIRECT, 100);
            this.client.rec.eventSystem.RegisterListener(new EventListener <ClientAuthedEvent>(delegate(ClientAuthedEvent e)
            {
                SyncContext.RunOnUI(after);
            }));
            this.client.rec.eventSystem.RegisterListener(new EventListener <InitialTimeoutEvent>(delegate(InitialTimeoutEvent e)
            {
                if (GameTracker.mgcache1 == null)
                {
                    GameTracker.mgcache1 = new Action <string>(MsgController.ShowMsg);
                }
                SyncContext.RunOnUI <string>(GameTracker.mgcache1, SFST.T.STP_Request_Timeout);
            }));
            this.client.rec.eventSystem.RegisterListener(new EventListener <PacketReceivedEvent>(delegate(PacketReceivedEvent e)
            {
                if (e.receivedPacket.Is <ServerErrorPacket>())
                {
                    ServerErrorPacket serverErrorPacket = e.receivedPacket.ToTargetPacket <ServerErrorPacket>();
                    if (serverErrorPacket.Error == "AUTHENTICATION")
                    {
                        SyncContext.RunOnUI(delegate
                        {
                            MsgController.ShowMsg(SFST.T.STP_Old_Credentials);
                            Sharing.sharing.downloadMenu.SetActive(false);
                            this.client.rec.Delete();
                            this.client.CleanCreds();
                        });
                        this.StartConnection(delegate
                        {
                            if (GameTracker.mgcache2 == null)
                            {
                                GameTracker.mgcache2 = new Action <string>(MsgController.ShowMsg);
                            }
                            SyncContext.RunOnUI <string>(GameTracker.mgcache2, SFST.T.STP_Reconnected);
                        });
                    }
                }
            }));
        }
Ejemplo n.º 16
0
 public override void OnPartUsed()
 {
     for (int i = 0; i < this.resourceSources.Length; i++)
     {
         if (this.resourceSources[i].state != FlowModule.State.Flowing)
         {
             MsgController.ShowMsg((this.resourceSources[i].state != FlowModule.State.NoSource) ? ("Out of " + Resource.GetResourceName(this.resourceSources[i].resourceType).ToLower()) : ("No " + Resource.GetResourceName(this.resourceSources[i].resourceType).ToLower() + " source"));
             return;
         }
     }
     this.on.boolValue = !this.on.boolValue;
     MsgController.ShowMsg("Rover wheel " + ((!this.on.boolValue) ? "Off" : "On"));
 }
Ejemplo n.º 17
0
 public void DecelerateTime()
 {
     if (this.timewarpPhase != 0)
     {
         this.timewarpPhase--;
         MsgController.ShowMsg(this.warpSpeeds[this.timewarpPhase].ToString() + "x Time acceleration");
         if (this.timewarpPhase == 0 && Ref.timeWarping)
         {
             this.ExitTimeWarpMode();
         }
         return;
     }
     Ref.inputController.instructionsTimewarp.SetActive(false);
 }
Ejemplo n.º 18
0
 public void RequestNextPage()
 {
     if (!this.PreCheck())
     {
         return;
     }
     this.LoadPage(this.currentCatgory, this.pageNumber, delegate
     {
         this.onNextPageLoaded.InvokeEvenets();
     }, delegate(string e)
     {
         MsgController.ShowMsg(string.Empty);
     });
 }
Ejemplo n.º 19
0
 public override void OnPartUsed()
 {
     if (this.separated.boolValue)
     {
         return;
     }
     if (Ref.timeWarping)
     {
         MsgController.ShowMsg("Cannot use part while time warping");
         return;
     }
     this.separated.boolValue = true;
     this.onSeparate.Invoke();
 }
Ejemplo n.º 20
0
 public void AddArchivment(string newArchivment)
 {
     for (int i = 0; i < this.vesselAchievements.Count; i++)
     {
         if (this.vesselAchievements[i] == newArchivment)
         {
             return;
         }
     }
     this.vesselAchievements.Add(newArchivment);
     if (Ref.mainVessel != this)
     {
         return;
     }
     if (newArchivment == "Reached 5 km altitude.")
     {
         return;
     }
     if (newArchivment == "Reached 10 km altitude.")
     {
         return;
     }
     if (newArchivment == "Reached 15 km altitude.")
     {
         return;
     }
     if (newArchivment == "Passed the Karman Line, leaving the /atmosphere and reaching space.")
     {
         newArchivment = "Passed the Karman Line, leaving the atmosphere and reaching space.";
         if (!Saving.LoadSetting(Saving.SettingKey.seenMapInstructions))
         {
             if (!Ref.mapView)
             {
                 Ref.inputController.instructionsMap.SetActive(true);
                 Ref.inputController.CloseDropdownMenu();
             }
             Saving.SaveSetting(Saving.SettingKey.seenMapInstructions, true);
             return;
         }
     }
     if (newArchivment == "Reached low Earth orbit." && !Saving.LoadSetting(Saving.SettingKey.seenTimewarpInstructions))
     {
         Ref.inputController.instructionsTimewarp.SetActive(true);
         Saving.SaveSetting(Saving.SettingKey.seenTimewarpInstructions, true);
     }
     newArchivment = newArchivment.Replace(".", "!");
     MsgController.ShowMsg(Utility.SplitLines(newArchivment), 6f, true);
 }
Ejemplo n.º 21
0
    public void Upload()
    {
        if (!this.CheckConnection())
        {
            return;
        }
        string text = TouchKeyboard.main.GetText(string.Empty);

        if (text == string.Empty)
        {
            return;
        }
        string buildJson = Build.main.GetBuildJson(text);
        UploadRocketRequest uploadRocketRequest = new UploadRocketRequest();

        uploadRocketRequest.toUpload = new CLRocket
        {
            Title       = text,
            Description = "Uploaded before descriptions where supported.",
            JSON        = buildJson
        };
        GameTracker.Tracker.client.AuthedRequest(uploadRocketRequest, delegate(DefaultPacket r)
        {
            SyncContext.RunOnUI(delegate
            {
                if (r.Success)
                {
                    this.onUploaded.InvokeEvenets();
                    MsgController.ShowMsg(SFST.T.Sharing_Upload_Success);
                }
                else
                {
                    ServerErrorPacket serverErrorPacket = r.ToTargetPacket <ServerErrorPacket>();
                    if (serverErrorPacket.Task == "OP_UPLOAD_LIMIT")
                    {
                        this.onUploadFailed.InvokeEvenets();
                        MsgController.ShowMsg(serverErrorPacket.Error);
                    }
                    else
                    {
                        this.onUploadFailed.InvokeEvenets();
                        MsgController.ShowMsg(SFST.T.Sharing_Upload_Failed);
                    }
                }
            });
        });
    }
Ejemplo n.º 22
0
 private bool PreCheck()
 {
     if (!this.CheckConnection())
     {
         return(false);
     }
     if (!GameTracker.Tracker.client.rec.isConnected())
     {
         MsgController.ShowMsg(SFST.T.Sharing_No_Server);
         this.downloadMenu.gameObject.SetActive(false);
         GameTracker.Tracker.client.rec.Delete();
         GameTracker.Tracker.client          = null;
         GameTracker.Tracker.ClientInitiated = false;
         return(false);
     }
     return(true);
 }
Ejemplo n.º 23
0
    public override void OnPartUsed()
    {
        if (this.part.vessel != Ref.mainVessel)
        {
            return;
        }
        if (this.resourceType != Resource.Type.Fuel)
        {
            return;
        }
        bool flag  = Ref.controller.fromTank != null;
        bool flag2 = Ref.controller.toTank != null;

        if ((flag && Ref.controller.fromTank.resourceGroup == this.resourceGroup) || (flag2 && Ref.controller.toTank.resourceGroup == this.resourceGroup) || (flag && flag2))
        {
            this.CancelFuelTranfer();
            return;
        }
        if (!flag)
        {
            if (this.resourceGroup.empty)
            {
                MsgController.ShowMsg("Out of fuel");
                return;
            }
            Ref.controller.fromTank = this;
            Ref.controller.toTank   = null;
            MsgController.ShowMsg("Selected fuel tank for fuel transfer");
            return;
        }
        else
        {
            if (flag2)
            {
                return;
            }
            if (this.resourceGroup.full)
            {
                MsgController.ShowMsg("Cannot transfer fuel into a full tank");
                return;
            }
            Ref.controller.toTank = this;
            return;
        }
    }
Ejemplo n.º 24
0
    private void TransferFuel()
    {
        if (this.fromTank == null || this.toTank == null)
        {
            return;
        }
        if (this.fromTank.part.vessel != Ref.mainVessel || this.toTank.part.vessel != Ref.mainVessel)
        {
            this.fromTank = null;
            this.toTank   = null;
            return;
        }
        if (this.fromTank.resourceGroup.empty)
        {
            MsgController.ShowMsg("Fuel transfer completed");
            this.fromTank = null;
            this.toTank   = null;
            return;
        }
        if (this.toTank.resourceGroup.full)
        {
            MsgController.ShowMsg("Fuel transfer completed");
            this.fromTank = null;
            this.toTank   = null;
            return;
        }
        double num            = (double)((float)this.warpSpeeds[this.timewarpPhase] * Time.deltaTime * 0.5f);
        double resourceAmount = this.fromTank.resourceGroup.resourceAmount;
        double num2           = this.toTank.resourceGroup.resourceSpace - this.toTank.resourceGroup.resourceAmount;

        if (num > resourceAmount)
        {
            num = resourceAmount;
        }
        if (num > num2)
        {
            num = num2;
        }
        this.fromTank.resourceGroup.TakeResource(num);
        this.toTank.resourceGroup.AddResource(num);
        MsgController.ShowMsg("Transfering...");
    }
Ejemplo n.º 25
0
    public bool CheckConnection()
    {
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            MsgController.ShowMsg(SFST.T.Sharing_No_Connection);
            return(false);
        }
        this.latestInfo = MasterInfo.Fetch();
        if (this.latestInfo == null)
        {
            if (Sharing.mgcache0 == null)
            {
                Sharing.mgcache0 = new Action <string>(MsgController.ShowMsg);
            }
            SyncContext.RunOnUI <string>(Sharing.mgcache0, SFST.T.STP_Request_Timeout);
            return(false);
        }
        int num  = VersionHolder.SharingVersion.CompareVersion(this.latestInfo.Version.Sharing.Client);
        int num2 = VersionHolder.ProtocolVersion.CompareVersion(this.latestInfo.Version.Sharing.Protocol);

        if (num == -1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Old_Version);
            return(false);
        }
        if (num == 1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_New_Version);
            return(false);
        }
        if (num2 == -1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Old_Protocol);
            return(false);
        }
        if (num2 == 1)
        {
            MsgController.ShowMsg(SFST.T.Sharing_New_Protocol);
            return(false);
        }
        return(true);
    }
Ejemplo n.º 26
0
 public void StartSaveProcess()
 {
     Ref.SceneType currentScene = Ref.currentScene;
     if (currentScene != Ref.SceneType.Build)
     {
         if (currentScene == Ref.SceneType.Game)
         {
             if (Ref.mainVessel == null)
             {
                 MsgController.ShowMsg("Cannot save while not controlling a rocket");
                 return;
             }
         }
     }
     else if (!Build.main.buildGrid.HasAnyParts())
     {
         return;
     }
     this.onOpenSaveMenu.InvokeEvenets();
 }
Ejemplo n.º 27
0
    public void CompleteSaveProcess()
    {
        string text = TouchKeyboard.main.GetText("Unnamed Save");

        Ref.SceneType currentScene = Ref.currentScene;
        if (currentScene != Ref.SceneType.Build)
        {
            if (currentScene == Ref.SceneType.Game)
            {
                GameSaving.Quicksaves.AddQuicksave(GameSaving.GetGameSaveData(text));
                MsgController.ShowMsg("Game Saved");
            }
        }
        else
        {
            Build.BuildQuicksaves.AddQuicksave(new Build.BuildSave(text, Camera.main.transform.position, Build.main.buildGrid.parts, 0));
            MsgController.ShowMsg("Design Saved");
        }
        this.onCloseSaveMenu.InvokeEvenets();
        this.CloseMenus();
        this.UpdateLoadButtonColor();
    }
Ejemplo n.º 28
0
 public void AccelerateTime()
 {
     Ref.inputController.instructionsTimewarp.SetActive(false);
     if (Ref.mainVesselHeight < this.loadedPlanet.minTimewarpHeightKm * 1000.0 && !Ref.timeWarping)
     {
         if (!Ref.mainVessel.OnSurface)
         {
             MsgController.ShowMsg("Cannot time warp below " + this.loadedPlanet.minTimewarpHeightKm.ToString() + "km");
             return;
         }
         if (Ref.mainVessel.GetGlobalVelocity.magnitude2d >= 0.05000000074505806)
         {
             MsgController.ShowMsg("Cannot time warp while moving on the surface");
             return;
         }
     }
     if (Ref.mainVessel.throttle.throttleOn && Ref.mainVessel.throttle.throttleRaw > 0f)
     {
         foreach (EngineModule engineModule in Ref.mainVessel.partsManager.engineModules)
         {
             if (engineModule.engineOn.boolValue)
             {
                 MsgController.ShowMsg("Cannot time warp while under acceleration");
                 return;
             }
         }
     }
     if (this.timewarpPhase == this.warpSpeeds.Length - 1)
     {
         return;
     }
     this.timewarpPhase++;
     MsgController.ShowMsg(this.warpSpeeds[this.timewarpPhase].ToString() + "x Time acceleration");
     if (!Ref.timeWarping)
     {
         this.EnterTimeWarpMode();
     }
 }
Ejemplo n.º 29
0
 public void ToggleEngine(bool showMsg)
 {
     if (this.IsCovered())
     {
         return;
     }
     if (this.engineOn.boolValue)
     {
         this.engineOn.boolValue = false;
         if (showMsg)
         {
             MsgController.ShowMsg("Engine Off");
         }
         if (this.nozzleMove != null)
         {
             this.nozzleMove.SetTargetTime(0f);
         }
     }
     else
     {
         for (int i = 0; i < this.resourceSources.Length; i++)
         {
             if (this.resourceSources[i].state != FlowModule.State.Flowing)
             {
                 MsgController.ShowMsg((this.resourceSources[i].state != FlowModule.State.NoSource) ? ("Out of " + Resource.GetResourceName(this.resourceSources[i].resourceType).ToLower()) : ("No " + Resource.GetResourceName(this.resourceSources[i].resourceType).ToLower() + " source"));
                 return;
             }
         }
         this.engineOn.boolValue = true;
         if (showMsg)
         {
             MsgController.ShowMsg("Engine On");
         }
     }
     this.UpdateEngineThrottle(base.transform.parent.GetComponentInParent <Vessel>().throttle);
 }
Ejemplo n.º 30
0
    private void Update()
    {
        if (this.regularUpdateTime < Time.time)
        {
            this.RegularUpdate();
            this.regularUpdateTime = Time.time + 0.5f;
        }
        this.globalTime += (double)((float)this.warpSpeeds[this.timewarpPhase] * Time.deltaTime);
        bool   flag = Ref.mainVessel != null && Ref.mainVessel.orbits.Count > 0;
        double num  = (!flag) ? double.PositiveInfinity : Ref.mainVessel.orbits[0].stopTimeWarpTime;

        if (flag)
        {
            Ref.planetManager.UpdatePositionOffset(Ref.mainVessel.GetGlobalPosition.roundTo1000);
        }
        if (this.globalTime > num)
        {
            this.globalTime = num;
            Ref.planetManager.UpdatePositionOffset(Ref.mainVessel.GetGlobalPosition.roundTo1000);
            this.timewarpPhase = 1;
            this.DecelerateTime();
            MsgController.ShowMsg("Cannot time warp below: " + this.loadedPlanet.minTimewarpHeightKm.ToString() + "km");
        }
    }