private ModClient RegisterClient(ClientData clientData)
        {
            int       clientVID = clientData.Item4;
            bool      supported = clientVID <= apiVID && clientVID >= minApiVID;
            ModClient client    = clients.Find(x => (x.name == clientData.Item1));

            if (client == null && supported)
            {
                client = new ModClient(clientData);
                clients.Add(client);
            }
            else
            {
                Action <int, object> GetOrSendFunc = clientData.Item2;

                if (!supported)
                {
                    string error = $"Error: Client version for {clientData.Item1} is not supported. " +
                                   $"API vID: Min: {minApiVID}, Max: {apiVID}; Client vID: {clientVID}";

                    GetOrSendFunc((int)MsgTypes.RegistrationFailed, error);
                    ExceptionHandler.WriteToLogAndConsole($"[RHF] {error}");
                }
                else
                {
                    GetOrSendFunc((int)MsgTypes.RegistrationFailed, "Client already registered.");
                }
            }

            return(client);
        }
Exemplo n.º 2
0
        private void checkTurboCondition()
        {
            // Written, 27.10.2020


            this.turboBlades.transform.localEulerAngles += new Vector3(10, 0f, 0f);
            ModClient.guiInteract("Looks alright");
            MasterAudio.PlaySound3DAndForget("Motor", this.transform, false, 1, null, 0f, "valve_knock");
        }
        private ModClient RegisterClient(ExtendedClientData regMessage)
        {
            ModClient client = RegisterClient(regMessage.Item1);

            if (client != null)
            {
                client.RegisterExtendedAccessors(regMessage.Item2, regMessage.Item3);
            }

            return(client);
        }
Exemplo n.º 4
0
        void Update()
        {
            // Written, 28.10.2020

            if (!this.transform.parent.gameObject.isPlayerHolding())
            {
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 1f, 1 << this.gameObject.layer))
                {
                    if (hit.collider.gameObject == this.gameObject)
                    {
                        this.previousWastegateHit = true;
                        ModClient.guiInteract("Wastegate:" + (this.turboSimulation?.wastegatePsi ?? this.wastegatePsiToAdd).ToString("0.##") + "PSI");
                        if (Input.mouseScrollDelta.y > 0)
                        {
                            if ((this.turboSimulation?.wastegatePsi ?? this.wastegatePsiToAdd) < this.wastegateMaxPsi)
                            {
                                if (this.turboSimulation == null)
                                {
                                    this.wastegatePsiToAdd += this.wastegatePsiIncrease;
                                }
                                else
                                {
                                    this.turboSimulation.addWastegatePsi(this.wastegatePsiIncrease);
                                }
                                MasterAudio.PlaySound3DAndForget("CarBuilding", this.gameObject.transform, false, 1f, null, 0f, "bolt_screw");
                            }
                        }
                        else if (Input.mouseScrollDelta.y < 0)
                        {
                            if ((this.turboSimulation?.wastegatePsi ?? this.wastegatePsiToAdd) > this.wastegateMinPsi)
                            {
                                if (this.turboSimulation == null)
                                {
                                    this.wastegatePsiToAdd -= this.wastegatePsiIncrease;
                                }
                                else
                                {
                                    this.turboSimulation.addWastegatePsi(-this.wastegatePsiIncrease);
                                }
                                MasterAudio.PlaySound3DAndForget("CarBuilding", this.gameObject.transform, false, 1f, null, 0f, "bolt_screw");
                            }
                        }
                    }
                }
            }
            else if (this.previousWastegateHit)
            {
                ModClient.guiInteract(inGuiInteractSymbol: GuiInteractSymbolEnum.None);
                this.previousWastegateHit = false;
            }
        }
Exemplo n.º 5
0
        void Update()
        {
            // Written, 27.10.2020

            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1f, 1 << this.turboBlades.layer))
            {
                ModClient.guiUse = hit.collider?.gameObject == this.turboBlades;
                if (ModClient.guiUse)
                {
                    this.previousTurboBladesHit = true;
                    if (cInput.GetButtonDown("Use"))
                    {
                        this.checkTurboCondition();
                    }
                }
            }
            else if (this.previousTurboBladesHit)
            {
                this.previousTurboBladesHit = false;
                ModClient.guiInteract(inGuiInteractSymbol: GuiInteractSymbolEnum.None);
            }
        }
        /// <summary>
        /// The function of the cruise control unit.
        /// </summary>
        private void ccFunction()
        {
            // Written, 27.09.2018

            if (this.isStockSteeringWheelInstalled)
            {
                RaycastHit hit;

                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1f, 1 << this.gameObject.layer))
                {
                    bool foundObject = false;
                    bool foundParent = false;

                    if (hit.transform?.gameObject?.name == "SATSUMA(557kg, 248)")
                    {
                        foundParent = true;
                        GameObject gameObjectHit;

                        gameObjectHit = hit.collider?.gameObject;

                        if (gameObjectHit != null)
                        {
                            Action actionToPerform = null;

                            if (gameObjectHit == clearButton)
                            {
                                foundObject     = true;
                                actionToPerform = this.onClear;
                            }
                            else
                            {
                                if (gameObjectHit == powerButton)
                                {
                                    foundObject     = true;
                                    actionToPerform = this.onPower;
                                }
                                else
                                {
                                    if (gameObjectHit == resButton)
                                    {
                                        foundObject     = true;
                                        actionToPerform = this.onRes;
                                    }
                                    else
                                    {
                                        if (gameObjectHit == setButton)
                                        {
                                            foundObject     = true;
                                            actionToPerform = this.onSet;
                                        }
                                    }
                                }
                            }
                            if (foundObject)
                            {
                                ModClient.guiInteract(gameObjectHit.name);
                                if (CruiseControlMod.useButtonDown)
                                {
                                    if (hasPower)
                                    {
                                        actionToPerform.Invoke();
                                    }
                                    AudioSource audio = dashButtonAudioSource;
                                    audio.transform.position = gameObjectHit.transform.position;
                                    audio.Play();
                                }
                            }
                        }
                    }
                    if (foundParent && !foundObject) // Only reset if gui use was active. (my attempt at preventing flashing graphics gitch in text.)
                    {
                        ModClient.guiInteract();
                    }
                }
            }
        }