コード例 #1
0
        /// <summary>
        /// Called after plugins startup
        /// </summary>
        /// <param name="pluginManager"></param>
        public void Init(PluginManager pluginManager)
        {
            // set path/filename for settings file
            AccData.path = PluginManager.GetCommonStoragePath("Viper.PluginCalcLngWheelSlip.json");

            // try to read settings file
            try
            {
                JObject JSONdata = JObject.Parse(File.ReadAllText(@AccData.path));
                AccData.Speed    = (int)JSONdata["Speed_min"];
                AccData.Brake    = (int)JSONdata["Brake_max"];
                AccData.Throttle = (int)JSONdata["Throttle_max"];
                AccData.Vel      = (double)JSONdata["VelX_max"];
                Logging.Current.Info("Plugin Viper.PluginCalcLngWheelSlip - Settings file " + System.Environment.CurrentDirectory + "\\" + AccData.path + " loaded.");
            }
            // if there is no settings file, use the following defaults
            catch
            {
                AccData.Speed    = 20;
                AccData.Brake    = 0;
                AccData.Throttle = 5;
                AccData.Vel      = 0.001;
                Logging.Current.Info("Plugin Viper.PluginCalcLngWheelSlip - Default settings loaded.");
            }


            pluginManager.AddProperty("CalcLngWheelSlip.Computed.LngWheelSlip_FL", this.GetType(), 0);
            pluginManager.AddProperty("CalcLngWheelSlip.Computed.LngWheelSlip_FR", this.GetType(), 0);
            pluginManager.AddProperty("CalcLngWheelSlip.Computed.LngWheelSlip_RL", this.GetType(), 0);
            pluginManager.AddProperty("CalcLngWheelSlip.Computed.LngWheelSlip_RR", this.GetType(), 0);

            pluginManager.AddProperty("CalcLngWheelSlip.Computed.TyreDiameter_FL", this.GetType(), "-");
            pluginManager.AddProperty("CalcLngWheelSlip.Computed.TyreDiameter_FR", this.GetType(), "-");
            pluginManager.AddProperty("CalcLngWheelSlip.Computed.TyreDiameter_RL", this.GetType(), "-");
            pluginManager.AddProperty("CalcLngWheelSlip.Computed.TyreDiameter_RR", this.GetType(), "-");

            pluginManager.AddProperty("CalcLngWheelSlip.TyreDiameterComputed", this.GetType(), false);

            pluginManager.AddAction("CalcLngWheelSlip.CalcTyreDiameter", this.GetType(), (a, b) =>
            {
                this.manualOverride = true;
            });

            pluginManager.AddAction("CalcLngWheelSlip.ResetTyreDiameter", this.GetType(), (a, b) =>
            {
                this.reset = true;
            });
        }