public override int Run(string[] remainingArguments) { var cfg = new VehicleConfig { ConnectionString = _connectionString }; Vehicle = CreateVehicle(cfg); return(RunAsync(Vehicle).Result); }
public override void init() { base.init(); _iData = (VehicleIdentityData)_data.identity; _config = VehicleConfig.get(_iData.id); _unitName = _config.name; _drivers = new int[_config.driverNum]; }
public Vehicle(bool fFerry = false) { VehicleinfoLoad(); foreach (Resource res in Enum.GetValues(typeof(Resource))) { XmlDocument doc = new XmlDocument(); string strPath = cCNXPath + res.ToString() + ".xml"; if (File.Exists(strPath)) { doc.Load(strPath); switch (res) { case Resource.DriverConfig: m_configD = new DriverConfig(doc); break; case Resource.RoutePatternForVehicle: m_configRP = new RoutePatternConfig(doc); break; case Resource.ServiceAlertForVehicle: m_configSA = new ServiceAlertConfig(doc); break; case Resource.VehicleConfig: m_configV = new VehicleConfig(doc); break; } } switch (res) { case Resource.DriverConfig: break; case Resource.RoutePatternForVehicle: break; case Resource.ServiceAlertForVehicle: break; case Resource.VehicleConfig: m_nRouteNoFmt = m_configV.RouteNoFmt; m_strNSDStopping = m_configV.NSDStopping; m_strNSDStoppingConcat = m_configV.NSDStoppingConcat; break; } } m_fFerry = fFerry; }
private void Start() { gm = FindObjectOfType <GameManager>(); spawner = FindObjectOfType <Spawner>(); conf = FindObjectOfType <VehicleConfig>(); health = gm.vehicleHealth; // viewRadius = gm.viewRadius; velocity = new Vector3(Random.Range(-gm.getWindowWidth(), gm.getWindowWidth()), Random.Range(-gm.getWindowHeight(), gm.getWindowHeight()), 0); position = transform.position; findTarget(); }
public Main() { // Old version check if (File.Exists("scripts\\JC3RebelDrop.dll") || File.Exists("scripts\\JC3RebelDrop.ini")) { Notification.Show("~r~Old Just Cause 3 Rebel Drops installation detected. Aborted rewrite loading. Remove JC3RebelDrop.dll and JC3RebelDrop.ini to resolve this issue."); return; } // Setup Util.VerifyFileStructure(); if (PlaySound) { AudioManager.InitSounds(); } VehConfig = VehicleConfig.Load(); WepConfig = WeaponConfig.Load(); foreach (string file in Directory.GetFiles(Globals.CustomVehicleDir, "*.json")) { CustomVehicleConfigs.Add(CustomVehicleConfig.LoadFromFile(file)); } foreach (string file in Directory.GetFiles(Globals.CustomVehicleDir, "*.xml")) { CustomVehicleConfigs.Add(CustomVehicleConfig.LoadFromFile(file)); } foreach (string file in Directory.GetFiles(Globals.CustomWeaponDir, "*.json")) { CustomWeaponConfigs.Add(CustomWeaponConfig.LoadFromFile(file)); } foreach (string file in Directory.GetFiles(Globals.CustomWeaponDir, "*.xml")) { CustomWeaponConfigs.Add(CustomWeaponConfig.LoadFromFile(file)); } Config = ModConfig.Load(); MenuManager.Init(); // Event handling Tick += OnTick; KeyDown += (o, e) => { if (e.KeyCode == Config.DropMenu) // Our menu on/off switch { MenuManager.ShowMenu(); } }; Notification.Show("~y~Just Cause Rebel Drops~w~ successfully loaded!"); }
public IHttpActionResult SaveVehicleConfig(VehicleConfig vehicleConfig) { try { var result = new VehicleConfigBO().SaveVehicleConfig(vehicleConfig); if (result) { return(Ok(UTILITY.SUCCESSMSG)); } else { return(BadRequest()); } } catch (Exception ex) { return(InternalServerError(ex)); } }
private static void LoadVehicleConfigs() { if (!Directory.Exists(VehicleConfigsFolder)) { Directory.CreateDirectory(VehicleConfigsFolder); } Dictionary <Model, ConditionEntry[]> extraConditions = null; foreach (string fileName in Directory.EnumerateFiles(VehicleConfigsFolder, "*.xml", SearchOption.TopDirectoryOnly)) { try { string modelName = Path.GetFileNameWithoutExtension(fileName); Game.LogTrivial($"Loading config for {modelName}..."); VehicleConfig cfg = Util.Deserialize <VehicleConfig>(fileName); Model m = new Model(modelName); if (cfg.ExtraConditions != null && cfg.ExtraConditions.Length > 0) { if (extraConditions == null) { extraConditions = new Dictionary <Model, ConditionEntry[]>(); } extraConditions.Add(m, cfg.ExtraConditions); } VehicleConfigsByModel.Add(m, cfg); Game.LogTrivial($"Loaded config for {modelName}"); } catch (System.InvalidOperationException ex) { Game.LogTrivial($"Can't load {Path.GetFileName(fileName)}: {ex}"); } catch (System.Xml.XmlException ex) { Game.LogTrivial($"Can't load {Path.GetFileName(fileName)}: {ex}"); } } Conditions.Conditions.LoadConditions(extraConditions); }
public bool SaveVehicleConfig(VehicleConfig newItem) { return(vehicleconfigDAL.Save(newItem)); }
public virtual void Setup(UserInterfaceSetup ui, RosBridgeConnector connector, VehicleConfig config) { Connector = connector; UI = ui; var bridge = connector.Bridge; ui.PositionReset.RobotController = CarController; ui.SensorEffectsToggle.onValueChanged.AddListener(enabled => ToggleSensorEffect(enabled)); // ui.WheelScale.onValueChanged.AddListener(value => // { // try // { // CarController.SetWheelScale(float.Parse(value)); // } // catch (System.Exception) // { // Debug.Log("ROS Wheel Force Scaler: Please input valid number!"); // } // }); // Cameras.ForEach(c => // { // var pp = c.GetComponent<PostProcessingListener>(); // if (pp != null) // { // ui.CameraSaturation.onValueChanged.AddListener(x => // { // pp.SetSaturationValue(x); // }); // } // }); ui.HighQualityRendering.onValueChanged.AddListener(enabled => { FollowCamera.GetComponent <PostProcessingBehaviour>().enabled = enabled; CameraMan?.SetHighQualityRendering(enabled); }); ui.TrafficToggle.onValueChanged.AddListener(enabled => { if (enabled) { FindObjectOfType <TrafSpawner>()?.ReSpawnTrafficCars(); } else { FindObjectOfType <TrafSpawner>()?.KillTrafficCars(); } //hack to sync toggle value among cars UIs { foreach (var otherUI in FindObjectsOfType <UserInterfaceSetup>()) { if (otherUI == ui) { continue; } var oldEvent = otherUI.TrafficToggle.onValueChanged; otherUI.TrafficToggle.onValueChanged = new UnityEngine.UI.Toggle.ToggleEvent(); otherUI.TrafficToggle.isOn = enabled; otherUI.TrafficToggle.onValueChanged = oldEvent; } } }); ui.PedestriansToggle.onValueChanged.AddListener(enabled => { if (enabled) { FindObjectOfType <PedestrianManager>()?.SpawnNPCPedestrians(); } else { FindObjectOfType <PedestrianManager>()?.KillNPCPedestrians(); } //hack to sync toggle value among car UIs { foreach (var otherUI in FindObjectsOfType <UserInterfaceSetup>()) { if (otherUI == ui) { continue; } var oldEvent = otherUI.PedestriansToggle.onValueChanged; otherUI.PedestriansToggle.onValueChanged = new UnityEngine.UI.Toggle.ToggleEvent(); otherUI.PedestriansToggle.isOn = enabled; otherUI.PedestriansToggle.onValueChanged = oldEvent; } } }); ui.SteerwheelFeedback.onValueChanged.AddListener(enabled => { var steerwheels = FindObjectsOfType <SteeringWheelInputController>(); foreach (var steerwheel in steerwheels) { steerwheel.useFeedback = enabled; } }); foreach (var item in NeedsBridge) { if (item == null) { continue; } var a = item as Ros.IRosClient; a.OnRosBridgeAvailable(bridge); } ui.AddTweakables(Tweakables); if (config != null) { ui.ToggleTweakable(Tweakables, "Lidar", config.enable_lidar); ui.ToggleTweakable(Tweakables, "GPS", config.enable_gps); ui.ToggleTweakable(Tweakables, "IMU", config.enable_imu); ui.ToggleTweakable(Tweakables, "Main Camera", config.enable_main_camera); ui.ToggleTweakable(Tweakables, "Telephoto Camera", config.enable_telephoto_camera); ui.HighQualityRendering.isOn = config.enable_high_quality_rendering; ui.SensorEffectsToggle.isOn = config.enable_sensor_effects; } }
public override int getFightUnitID() { return(VehicleConfig.get(id).fightUnitID); }
public void SpawnVehicle(Vector3 position, Quaternion rotation, RosBridgeConnector connector, VehicleConfig staticConfig, float height = 0.0f) { var agentImage = Instantiate(AgentUI, AgentList); agentImage.transform.FindDeepChild("Address").GetComponent <Text>().text = connector.PrettyAddress; var button = agentImage.GetComponent <Button>(); button.onClick.AddListener(() => { UserInterfaceSetup.ChangeFocusUI(connector); SteeringWheelInputController.ChangeFocusSteerWheel(connector.Agent.GetComponentInChildren <SteeringWheelInputController>()); }); var agentSetup = connector.agentType; GameObject bot = Instantiate(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject : agentSetup.gameObject, position, rotation); // TODO better system AnalyticsManager.Instance?.EgoStartEvent(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject.name : agentSetup.gameObject.name); var uiObject = Instantiate(UserInterfaceAgent); uiObject.GetComponent <RfbClient>().Address = connector.Address; var ui = uiObject.transform; ui.GetComponent <UserInterfaceSetup>().agent = bot; if (bot.name.Contains("duckiebot")) { HelpScreenUpdate helpScreen = uiObject.GetComponent <HelpScreenUpdate>(); helpScreen.Help = helpScreen.DuckieHelp; helpScreen.agentsText = helpScreen.duckieText; } // offset for multiple vehicle UI RectTransform rect = uiObject.GetComponent <UserInterfaceSetup>().MainPanel; if (rect != null) { rect.offsetMax = new Vector2(0, rect.offsetMax.y - height); } connector.UiObject = uiObject; connector.UiButton = agentImage; connector.BridgeStatus = uiObject.GetComponent <UserInterfaceSetup>().BridgeStatus; bot.GetComponent <AgentSetup>().Setup(ui.GetComponent <UserInterfaceSetup>(), connector, staticConfig); bot.GetComponent <AgentSetup>().FollowCamera.gameObject.SetActive(false); button.image.sprite = bot.GetComponent <AgentSetup>().agentUISprite; //uiObject.enabled = i == 0; var colors = button.colors; //colors.normalColor = i == 0 ? new Color(1, 1, 1) : new Color(0.8f, 0.8f, 0.8f); button.colors = colors; var name = new GameObject(); name.transform.parent = AgentListCanvas.transform.FindDeepChild("Panel").transform; connector.UiName = name.AddComponent <Text>(); connector.UiName.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); connector.UiName.text = connector.PrettyAddress; connector.UiName.fontSize = 16; connector.UiName.fontStyle = FontStyle.Bold; connector.UiName.horizontalOverflow = HorizontalWrapMode.Overflow; connector.UiName.verticalOverflow = VerticalWrapMode.Overflow; connector.Agent = bot; }
/// <summary> /// Verifies that all of the mod's files are there /// </summary> public static void VerifyFileStructure() { if (!Directory.Exists(Globals.ResourceDir)) { Directory.CreateDirectory(Globals.ResourceDir); } if (!Directory.Exists(Globals.CustomWeaponDir)) { Directory.CreateDirectory(Globals.CustomWeaponDir); } if (!Directory.Exists(Globals.CustomVehicleDir)) { Directory.CreateDirectory(Globals.CustomVehicleDir); } if (!File.Exists(Globals.ConfigFile)) { ModConfig config = new ModConfig(); File.WriteAllText(Globals.ConfigFile, JsonConvert.SerializeObject(config, Formatting.Indented)); } if (!File.Exists(Globals.VehicleFile)) { VehicleConfig vehicles = new VehicleConfig(); vehicles.CivilianVehicles.AddRange(Globals.DefaultAir); vehicles.CivilianVehicles.AddRange(Globals.DefaultLand); vehicles.CivilianVehicles.AddRange(Globals.DefaultSea); vehicles.MilitaryVehicles.AddRange(Globals.DefaultMilAir); vehicles.MilitaryVehicles.AddRange(Globals.DefaultMilLand); vehicles.MilitaryVehicles.AddRange(Globals.DefaultMilSea); File.WriteAllText(Globals.VehicleFile, JsonConvert.SerializeObject(vehicles, Formatting.Indented)); } if (!File.Exists(Globals.WeaponFile)) { WeaponConfig weapons = new WeaponConfig(); weapons.HeavyWeapons.AddRange(Globals.DefaultHeavy); weapons.PrimaryWeapons.AddRange(Globals.DefaultPrimary); weapons.SideWeapons.AddRange(Globals.DefaultSecondary); File.WriteAllText(Globals.WeaponFile, JsonConvert.SerializeObject(weapons, Formatting.Indented)); } if (!File.Exists(Globals.HitSound)) { Main.PlaySound = false; } if (!File.Exists(Globals.CallSound)) { Main.PlaySound = false; } if (!File.Exists(Globals.CustomVehicleDir + "\\CustomTemplate.json.n")) { File.WriteAllText(Globals.CustomVehicleDir + "\\CustomTemplate.json.n", JsonConvert.SerializeObject(new CustomVehicleConfig() { CategoryName = "Example", Vehicles = new List <DropVehicle>() { new DropVehicle() { DisplayName = "Mallard Example", ModelName = "stunt", Type = VehicleType.Plane } } }, Formatting.Indented)); } if (!File.Exists(Globals.CustomVehicleDir + "\\CustomTemplate.xml.n")) { XmlSerializer serializer = new XmlSerializer(typeof(CustomVehicleConfig)); FileStream stream = new FileStream(Globals.CustomVehicleDir + "\\CustomTemplate.xml.n", FileMode.OpenOrCreate); serializer.Serialize(stream, new CustomVehicleConfig() { CategoryName = "Example", Vehicles = new List <DropVehicle>() { new DropVehicle() { DisplayName = "Mallard Example", ModelName = "stunt", Type = VehicleType.Plane } } }); stream.Close(); } if (!File.Exists(Globals.CustomWeaponDir + "\\CustomTemplate.json.n")) { File.WriteAllText(Globals.CustomWeaponDir + "\\CustomTemplate.json.n", JsonConvert.SerializeObject(new CustomWeaponConfig() { CategoryName = "Example", Weapons = new List <Weapon>() { new Weapon() { DisplayName = "Carbine Rifle", Hash = GTA.PickupType.WeaponCarbineRifle, Type = WeaponCategory.Sidearm } } }, Formatting.Indented)); } if (!File.Exists(Globals.CustomWeaponDir + "\\CustomTemplate.xml.n")) { XmlSerializer serializer = new XmlSerializer(typeof(CustomWeaponConfig)); FileStream stream = new FileStream(Globals.CustomWeaponDir + "\\CustomTemplate.xml.n", FileMode.OpenOrCreate); serializer.Serialize(stream, new CustomWeaponConfig() { CategoryName = "Example", Weapons = new List <Weapon>() { new Weapon() { DisplayName = "Carbine Rifle", Hash = GTA.PickupType.WeaponCarbineRifle, Type = WeaponCategory.Sidearm } } }); stream.Close(); } }
protected override IVehicle CreateVehicle(VehicleConfig config) { return(new Vehicle(config)); }
public VehicleConfig GetVehicleConfig(VehicleConfig item) { return((VehicleConfig)vehicleconfigDAL.GetItem <VehicleConfig>(item)); }
public virtual void Setup(UserInterfaceSetup ui, RosBridgeConnector connector, VehicleConfig config) { // needed for npc foreach (Transform child in transform) { if (child.CompareTag("MainCamera")) { mainCamera = child.GetComponent <Camera>(); } } Connector = connector; UI = ui; var bridge = connector.Bridge; ui.agentController = agentController; ui.SensorEffectsToggle.onValueChanged.AddListener(enabled => ToggleSensorEffect(enabled)); // ui.WheelScale.onValueChanged.AddListener(value => // { // try // { // CarController.SetWheelScale(float.Parse(value)); // } // catch (System.Exception) // { // Debug.Log("ROS Wheel Force Scaler: Please input valid number!"); // } // }); // Cameras.ForEach(c => // { // var pp = c.GetComponent<PostProcessingListener>(); // if (pp != null) // { // ui.CameraSaturation.onValueChanged.AddListener(x => // { // pp.SetSaturationValue(x); // }); // } // }); ui.LowQualityRendering.onValueChanged.AddListener(useLowQuality => { FollowCamera.GetComponent <PostProcessingBehaviour>().enabled = !useLowQuality; CameraMan?.SetHighQualityRendering(!useLowQuality); }); ui.LowQualityRendering.onValueChanged.Invoke(ui.LowQualityRendering.isOn); ui.TrafficToggle.onValueChanged.AddListener(enabled => { FindObjectOfType <NPCManager>()?.ToggleNPCS(enabled); //hack to sync toggle value among cars UIs { foreach (var otherUI in FindObjectsOfType <UserInterfaceSetup>()) { if (otherUI == ui) { continue; } var oldEvent = otherUI.TrafficToggle.onValueChanged; otherUI.TrafficToggle.onValueChanged = new UnityEngine.UI.Toggle.ToggleEvent(); otherUI.TrafficToggle.isOn = enabled; otherUI.TrafficToggle.onValueChanged = oldEvent; } } }); ui.TrafficPhysicsModeToggle.onValueChanged.AddListener(enabled => { FindObjectOfType <NPCManager>()?.ToggleNPCPhysicsMode(enabled); //hack to sync toggle value among cars UIs { foreach (var otherUI in FindObjectsOfType <UserInterfaceSetup>()) { if (otherUI == ui) { continue; } var oldEvent = otherUI.TrafficPhysicsModeToggle.onValueChanged; otherUI.TrafficPhysicsModeToggle.onValueChanged = new UnityEngine.UI.Toggle.ToggleEvent(); otherUI.TrafficPhysicsModeToggle.isOn = enabled; otherUI.TrafficPhysicsModeToggle.onValueChanged = oldEvent; } } }); ui.PedestriansToggle.onValueChanged.AddListener(enabled => { if (enabled) { FindObjectOfType <PedestrianManager>()?.SpawnPedestrians(); } else { FindObjectOfType <PedestrianManager>()?.KillPedestrians(); } //hack to sync toggle value among car UIs { foreach (var otherUI in FindObjectsOfType <UserInterfaceSetup>()) { if (otherUI == ui) { continue; } var oldEvent = otherUI.PedestriansToggle.onValueChanged; otherUI.PedestriansToggle.onValueChanged = new UnityEngine.UI.Toggle.ToggleEvent(); otherUI.PedestriansToggle.isOn = enabled; otherUI.PedestriansToggle.onValueChanged = oldEvent; } } }); ui.SteerwheelFeedback.onValueChanged.AddListener(enabled => { var steerwheels = FindObjectsOfType <SteeringWheelInputController>(); foreach (var steerwheel in steerwheels) { steerwheel.useFeedback = enabled; } }); foreach (var item in NeedsBridge) { if (item == null) { continue; } var a = item as Comm.BridgeClient; a.OnBridgeAvailable(bridge); } ui.AddTweakables(Tweakables); if (config != null) { ui.ToggleTweakable(Tweakables, "Lidar", config.enable_lidar); ui.ToggleTweakable(Tweakables, "GPS", config.enable_gps); ui.ToggleTweakable(Tweakables, "IMU", config.enable_imu); ui.ToggleTweakable(Tweakables, "Main Camera", config.enable_main_camera); ui.ToggleTweakable(Tweakables, "Telephoto Camera", config.enable_telephoto_camera); ui.LowQualityRendering.isOn = !config.enable_high_quality_rendering; ui.SensorEffectsToggle.isOn = config.enable_sensor_effects; } if (config != null) { if (StaticConfigManager.Instance.staticConfig.initialized && ROSAgentManager.Instance.currentMode == StartModeTypes.StaticConfig) { ui.CheckStaticConfigTraffic(); } } // CES CarInputController cc = GetComponent <CarInputController>(); if (cc != null) { cc[InputEvent.TOGGLE_SENSOR_EFFECTS].Press += ToggleSensorEffect; cc[InputEvent.TOGGLE_TRAFFIC].Press += ToggleTraffic; cc[InputEvent.TOGGLE_UI].Press += ToggleUI; } }
private void OnTripStatus(object parm) { Debug.WriteLine(string.Format("{0} {1}", DateTime.Now.ToString("HH:mm:ss.fff"), "OnTripStatus")); RoutePatternConfig configRP = null; ServiceAlertConfig configSA = null; VehicleConfig configV = null; Interlocked.Exchange <RoutePatternConfig>(ref configRP, m_configRP); Interlocked.Exchange <ServiceAlertConfig>(ref configSA, m_configSA); Interlocked.Exchange <VehicleConfig>(ref configV, m_configV); bool bContinue = true, bDispose = false; Trip trip = null; TripStatus ts = (TripStatus)parm; Timeout timeoutFix = new Timeout(TimeSpan.FromMinutes(2)), timeoutOnRoute = new Timeout(TimeSpan.FromSeconds(500)); do { if (ts != null) { if (ts.NoTrip) { trip = null; } else if (!ts.OffRoute) { timeoutOnRoute.Reset(); if (trip == null || ts.RouteTag != trip.RouteTag || ts.RP < trip.RP || ts.TripNo != trip.TripNo || ts.ServiceStart != trip.ServiceStart) { trip = Trip.Create(this, ts.RouteTag, ts.RP, ts.TripNo, ts.ServiceStart, m_configRP, m_configSA, m_configV, m_fFerry); } else { trip.ProgressRP(ts.RP); } EnableSignalPriority(ts.SignalPriority); } else if (trip != null) { trip.OffRoute = true; EnableSignalPriority(false); } } if (trip != null) { GPSFix fix = m_Fix; bool bEndTrip = false; if (timeoutOnRoute.HasExpired) { bEndTrip = true; } else if (fix == null || !UTM.IsValidLL4Zone(configV.UTMZoneNo, configV.UTMZoneLetter, fix.Lat, fix.Long)) { bEndTrip = timeoutFix.HasExpired; } else { timeoutFix.Reset(); //if( m_fFerry || !trip.OffRoute ) // bEndTrip = !trip.UpdatePosition( UTM.LL2UTM( configV.UTMZoneNo, fix.Lat, fix.Long ), fix.Speed, fix.SpeedWeighted ); } if (bEndTrip) { trip = null; } else { Thread.Sleep(999); } } lock ( m_qTS ) { if (m_qTS.Count == 0) { ts = null; } else { ts = m_qTS.Dequeue(); if (ts == null) { bDispose = true; } } if (bDispose || (trip == null && ts == null)) { bContinue = m_bTSThreadPoolActive = false; } } }while(bContinue); if (!bDispose) { QueueRequest(new RequestEventArgs(RequestType.DisplayNextStop, null)); QueueRequest(new RequestEventArgs(RequestType.DisplayNextStopExtra, null)); if (configV.HeadSignDefault != null) { QueueRequest(new RequestEventArgs(RequestType.HeadSign, configV.HeadSignDefault)); } EnableSignalPriority(false); } }
public bool DeleteVehicleConfig(VehicleConfig item) { return(vehicleconfigDAL.Delete(item)); }
// Returns false if vehicle is not supported. private bool GetSupportedVehicleInformation(BaseCombatEntity entity, out VehicleConfig config, out string noDecayPerm, out float timeSinceLastUsed, out BaseCombatEntity vehicle) { config = null; noDecayPerm = string.Empty; timeSinceLastUsed = 0; vehicle = entity; var hab = entity as HotAirBalloon; if (!ReferenceEquals(hab, null)) { config = _pluginConfig.Vehicles.HotAirBalloon; noDecayPerm = Permission_NoDecay_HotAirBalloon; timeSinceLastUsed = Time.time - hab.lastBlastTime; return(true); } var kayak = entity as Kayak; if (!ReferenceEquals(kayak, null)) { config = _pluginConfig.Vehicles.Kayak; noDecayPerm = Permission_NoDecay_Kayak; timeSinceLastUsed = kayak.timeSinceLastUsed; return(true); } // Must go before MiniCopter. var scrapHeli = entity as ScrapTransportHelicopter; if (!ReferenceEquals(scrapHeli, null)) { config = _pluginConfig.Vehicles.ScrapTransportHelicopter; noDecayPerm = Permission_NoDecay_ScrapHeli; timeSinceLastUsed = Time.time - scrapHeli.lastEngineOnTime; return(true); } var minicopter = entity as MiniCopter; if (!ReferenceEquals(minicopter, null)) { config = _pluginConfig.Vehicles.Minicopter; noDecayPerm = Permission_NoDecay_MiniCopter; timeSinceLastUsed = Time.time - minicopter.lastEngineOnTime; return(true); } // Must go before MotorRowboat. var rhib = entity as RHIB; if (!ReferenceEquals(rhib, null)) { config = _pluginConfig.Vehicles.RHIB; noDecayPerm = Permission_NoDecay_RHIB; timeSinceLastUsed = rhib.timeSinceLastUsedFuel; return(true); } var horse = entity as RidableHorse; if (!ReferenceEquals(horse, null)) { config = _pluginConfig.Vehicles.RidableHorse; noDecayPerm = Permission_NoDecay_RidableHorse; timeSinceLastUsed = Time.time - horse.lastInputTime; return(true); } var rowboat = entity as MotorRowboat; if (!ReferenceEquals(rowboat, null)) { config = _pluginConfig.Vehicles.Rowboat; noDecayPerm = Permission_NoDecay_Rowboat; timeSinceLastUsed = rowboat.timeSinceLastUsedFuel; return(true); } var vehicleModule = entity as BaseVehicleModule; if (!ReferenceEquals(vehicleModule, null)) { config = _pluginConfig.Vehicles.ModularCar; noDecayPerm = Permission_NoDecay_ModularCar; var car = vehicleModule.Vehicle as ModularCar; if (car == null) { return(false); } timeSinceLastUsed = Time.time - car.lastEngineOnTime; vehicle = car; return(true); } // Must go before BaseSubmarine. var duoSub = entity as SubmarineDuo; if (!ReferenceEquals(duoSub, null)) { config = _pluginConfig.Vehicles.DuoSubmarine; noDecayPerm = Permission_NoDecay_DuoSub; timeSinceLastUsed = duoSub.timeSinceLastUsed; return(true); } var soloSub = entity as BaseSubmarine; if (!ReferenceEquals(soloSub, null)) { config = _pluginConfig.Vehicles.SoloSubmarine; noDecayPerm = Permission_NoDecay_SoloSub; timeSinceLastUsed = soloSub.timeSinceLastUsed; return(true); } var snowmobile = entity as Snowmobile; if (!ReferenceEquals(snowmobile, null)) { if (snowmobile.ShortPrefabName == SnowmobileShortPrefabName) { config = _pluginConfig.Vehicles.Snowmobile; noDecayPerm = Permission_NoDecay_Snowmobile; timeSinceLastUsed = snowmobile.timeSinceLastUsed; return(snowmobile); } if (snowmobile.ShortPrefabName == TomahaShortPrefabName) { config = _pluginConfig.Vehicles.Tomaha; noDecayPerm = Permission_NoDecay_Tomaha; timeSinceLastUsed = snowmobile.timeSinceLastUsed; return(snowmobile); } } return(false); }
public DataSet VConfig(VehicleConfig vc) { LogTraceWriter traceWriter = new LogTraceWriter(); traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "SaveVehicleConfig credentials...."); //DataTable Tbl = new DataTable(); //connect to database SqlConnection conn = new SqlConnection(); //connetionString="Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password" conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "VehicleConfiguration"; cmd.Connection = conn; SqlParameter gsaa = new SqlParameter(); gsaa.ParameterName = "@needRoutes"; gsaa.SqlDbType = SqlDbType.Int; gsaa.Value = (vc.needRoutes == null) ? 0 : 1; cmd.Parameters.Add(gsaa); SqlParameter gsab = new SqlParameter(); gsab.ParameterName = "@needRoles"; gsab.SqlDbType = SqlDbType.Int; gsab.Value = (vc.needRoles == null) ? 0 : 1; cmd.Parameters.Add(gsab); SqlParameter gsac = new SqlParameter(); gsac.ParameterName = "@needfleetowners"; gsac.SqlDbType = SqlDbType.Int; gsac.Value = (vc.needfleetowners == null) ? 0 : 1; cmd.Parameters.Add(gsac); SqlParameter nvr = new SqlParameter(); nvr.ParameterName = "@needvehicleRegno"; nvr.SqlDbType = SqlDbType.Int; nvr.Value = (vc.needvehicleRegno == null) ? 0 : 1; cmd.Parameters.Add(nvr); SqlParameter nvl = new SqlParameter(); nvl.ParameterName = "@needVehicleLayout"; nvl.SqlDbType = SqlDbType.Int; nvl.Value = (vc.needVehicleLayout == null) ? 0 : 1; cmd.Parameters.Add(nvl); SqlParameter nst = new SqlParameter(); nst.ParameterName = "@needServiceType"; nst.SqlDbType = SqlDbType.Int; nst.Value = (vc.needServiceType == null) ? 0 : 1; cmd.Parameters.Add(nst); SqlParameter ncn = new SqlParameter(); ncn.ParameterName = "@needCompanyName"; ncn.SqlDbType = SqlDbType.Int; ncn.Value = (vc.needCompanyName == null) ? 0 : 1; cmd.Parameters.Add(ncn); SqlParameter gsk = new SqlParameter(); gsk.ParameterName = "@needvehicleType"; gsk.SqlDbType = SqlDbType.Int; gsk.Value = (vc.needvehicleType == null) ? 0 : 1; cmd.Parameters.Add(gsk); //@needHireVehicle SqlParameter nhv = new SqlParameter(); nhv.ParameterName = "@needHireVehicle"; nhv.SqlDbType = SqlDbType.Int; nhv.Value = (vc.needHireVehicle == null) ? 0 : 1; cmd.Parameters.Add(nhv); //@needbtpos SqlParameter nbtpos = new SqlParameter(); nbtpos.ParameterName = "@needbtpos"; nbtpos.SqlDbType = SqlDbType.Int; nbtpos.Value = (vc.needbtpos == null) ? 0 : 1; cmd.Parameters.Add(nbtpos); //@cmpId SqlParameter cmpId = new SqlParameter(); cmpId.ParameterName = "@cmpId"; cmpId.SqlDbType = SqlDbType.Int; cmpId.Value = (vc.cmpId == null) ? -1 : vc.cmpId; cmd.Parameters.Add(cmpId); //@fleetownerId SqlParameter foid = new SqlParameter(); foid.ParameterName = "@fleetownerId"; foid.SqlDbType = SqlDbType.Int; foid.Value = (vc.fleetownerId == null) ? -1 : vc.fleetownerId; cmd.Parameters.Add(foid); //needfleetownerroutes SqlParameter forid = new SqlParameter(); forid.ParameterName = "@needFleetOwnerRoutes"; forid.SqlDbType = SqlDbType.Int; forid.Value = (vc.needfleetownerroutes == null) ? -1 : vc.needfleetownerroutes; cmd.Parameters.Add(forid); SqlParameter vmid = new SqlParameter(); vmid.ParameterName = "@needvehicleMake"; vmid.SqlDbType = SqlDbType.Int; vmid.Value = (vc.needvehicleMake == null) ? 0 : 1; cmd.Parameters.Add(vmid); SqlParameter vgid = new SqlParameter(); vgid.ParameterName = "@needVehicleGroup"; vgid.SqlDbType = SqlDbType.Int; vgid.Value = (vc.needVehicleGroup == null) ? 0 : 1; cmd.Parameters.Add(vgid); SqlParameter vdid = new SqlParameter(); vdid.ParameterName = "@needDocuments"; vdid.SqlDbType = SqlDbType.Int; vdid.Value = (vc.needDocuments == null) ? 0 : 1; cmd.Parameters.Add(vdid); DataSet ds = new DataSet(); SqlDataAdapter db = new SqlDataAdapter(cmd); db.Fill(ds); traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "SaveVehicleConfig Credentials completed."); // Tbl = ds.Tables[0]; // int found = 0; return(ds); }
public override void onReloadConfig() { _config = VehicleConfig.get(_iData.id); _unitName = _config.name; }
protected override IVehicle CreateVehicle(VehicleConfig config) { Task.Factory.StartNew(_ => KeyListen(), _cancel.Token); Console.CancelKeyPress += Console_CancelKeyPress; return(new Vehicle(config)); }
protected abstract IVehicle CreateVehicle(VehicleConfig config);