public static void ClearVehicles(VehicleOptions options, bool parked) { if (parked) { if (options == null) { SimulationManager.instance.AddAction(ActionRemoveParkedAll); return; } m_removeParkedInfo = options.prefab; SimulationManager.instance.AddAction(ActionRemoveParked); } else { if (options == null) { SimulationManager.instance.AddAction(ActionRemoveExistingAll); return; } m_removeInfo = options.prefab; SimulationManager.instance.AddAction(ActionRemoveExisting); } }
public static void ClearVehicles(VehicleOptions options, bool parked) { if (parked) { if (options == null) { new EnumerableActionThread(ActionRemoveParkedAll); return; } m_removeParkedInfo = options.prefab; new EnumerableActionThread(ActionRemoveParked); } else { if (options == null) { new EnumerableActionThread(ActionRemoveExistingAll); return; } m_removeInfo = options.prefab; new EnumerableActionThread(ActionRemoveExisting); } }
private DefaultOptions(VehicleInfo prefab) { VehicleOptions options = new VehicleOptions(); options.SetPrefab(prefab); m_enabled = options.enabled; m_addBackEngine = options.addBackEngine; m_maxSpeed = options.maxSpeed; m_acceleration = options.acceleration; m_braking = options.braking; m_turning = options.turning; m_springs = options.springs; m_dampers = options.dampers; m_leanMultiplier = options.leanMultiplier; m_nodMultiplier = options.nodMultiplier; m_useColorVariations = options.useColorVariations; m_color0 = options.color0; m_color1 = options.color1; m_color2 = options.color2; m_color3 = options.color3; m_capacity = options.capacity; m_placementStyle = options.placementStyle; if (prefab.m_trailers != null && prefab.m_trailers.Length > 0) { m_lastTrailer = prefab.m_trailers[prefab.m_trailers.Length - 1].m_info; m_probability = prefab.m_trailers[prefab.m_trailers.Length - 1].m_invertProbability; } }
public int CompareTo(object o) { VehicleOptions options = o as VehicleOptions; if (options == null) { return(1); } int delta = category - options.category; if (delta == 0) { if (steamID != null && options.steamID == null) { delta = 1; } else if (steamID == null && options.steamID != null) { delta = -1; } } if (delta == 0) { return(localizedName.CompareTo(options.localizedName)); } return(delta); }
public static void RestoreAll() { foreach (string name in m_default.Keys) { Restore(m_prefabs[name]); } VehicleOptions.UpdateTransfertVehicles(); }
/// <summary> /// Called when the level (game, map editor, asset editor) is loaded /// </summary> public override void OnLevelLoaded(LoadMode mode) { try { // Is it an actual game ? if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario) { DefaultOptions.Clear(); Logging.Error("AVO Incompatible GameMode " + mode); return; } AdvancedVehicleOptions.isGameLoaded = true; if (instance != null) { GameObject.DestroyImmediate(instance.gameObject); } instance = new GameObject("AdvancedVehicleOptions").AddComponent <AdvancedVehicleOptions>(); try { DefaultOptions.BuildVehicleInfoDictionary(); VehicleOptions.Clear(); Logging.Message("UIMainPanel created"); } catch { Logging.Error("Could not create UIMainPanel"); if (instance != null) { GameObject.Destroy(instance.gameObject); } return; } //new EnumerableActionThread(BrokenAssetsFix); } catch (Exception e) { if (instance != null) { GameObject.Destroy(instance.gameObject); } Logging.LogException(e); } }
/// <summary> /// Called when the level (game, map editor, asset editor) is loaded /// </summary> public override void OnLevelLoaded(LoadMode mode) { try { // Is it an actual game ? if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame) { DefaultOptions.Clear(); return; } AdvancedVehicleOptionsUID.isGameLoaded = true; if (instance != null) { GameObject.DestroyImmediate(instance.gameObject); } instance = new GameObject("AdvancedVehicleOptionsUID").AddComponent <AdvancedVehicleOptionsUID>(); try { DefaultOptions.BuildVehicleInfoDictionary(); VehicleOptions.Clear(); DebugUtils.Log("UIMainPanel created"); } catch { DebugUtils.Log("Could not create UIMainPanel"); if (instance != null) { GameObject.Destroy(instance.gameObject); } return; } //new EnumerableActionThread(BrokenAssetsFix); } catch (Exception e) { if (instance != null) { GameObject.Destroy(instance.gameObject); } DebugUtils.LogException(e); } }
public void DataToOptions() { if (data == null) { return; } options = new VehicleOptions[data.Length]; for (int i = 0; i < data.Length; i++) { if (data[i].name == null) { continue; } options[i] = new VehicleOptions(); options[i].name = data[i].name; options[i].enabled = data[i].enabled; options[i].addBackEngine = data[i].addBackEngine; options[i].maxSpeed = data[i].maxSpeed; options[i].acceleration = data[i].acceleration; options[i].braking = data[i].braking; options[i].turning = data[i].turning; options[i].springs = data[i].springs; options[i].dampers = data[i].dampers; options[i].leanMultiplier = data[i].leanMultiplier; options[i].nodMultiplier = data[i].nodMultiplier; options[i].useColorVariations = data[i].useColorVariations; options[i].color0 = data[i].color0; options[i].color1 = data[i].color1; options[i].color2 = data[i].color2; options[i].color3 = data[i].color3; options[i].capacity = data[i].capacity; options[i].specialcapacity = data[i].specialcapacity; options[i].isLargeVehicle = data[i].isLargeVehicle; } VehicleOptions.UpdateTransfertVehicles(); }
/// <summary> /// Check if there are new vehicles and add them to the options list /// </summary> private static void CompileVehiclesList() { List <VehicleOptions> optionsList = new List <VehicleOptions>(); if (config.options != null) { optionsList.AddRange(config.options); } for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++) { VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(i); if (prefab == null || ContainsPrefab(prefab)) { continue; } // New vehicle VehicleOptions options = new VehicleOptions(); options.SetPrefab(prefab); optionsList.Add(options); } if (config.options != null) { DebugUtils.Log("Found " + (optionsList.Count - config.options.Length) + " new vehicle(s)"); } else { DebugUtils.Log("Found " + optionsList.Count + " new vehicle(s)"); } config.options = optionsList.ToArray(); }
public static void Restore(VehicleInfo prefab) { if (prefab == null) { return; } VehicleOptions options = new VehicleOptions(); options.SetPrefab(prefab); DefaultOptions stored = m_default[prefab.name]; if (stored == null) { return; } options.enabled = stored.m_enabled; options.addBackEngine = stored.m_addBackEngine; options.maxSpeed = stored.m_maxSpeed; options.acceleration = stored.m_acceleration; options.braking = stored.m_braking; options.turning = stored.m_turning; options.springs = stored.m_springs; options.dampers = stored.m_dampers; options.leanMultiplier = stored.m_leanMultiplier; options.nodMultiplier = stored.m_nodMultiplier; options.useColorVariations = stored.m_useColorVariations; options.color0 = stored.m_color0; options.color1 = stored.m_color1; options.color2 = stored.m_color2; options.color3 = stored.m_color3; options.capacity = stored.m_capacity; prefab.m_placementStyle = stored.m_placementStyle; }
public static void CheckForConflicts() { StringBuilder conflicts = new StringBuilder(); foreach (string name in m_default.Keys) { VehicleOptions options = new VehicleOptions(); options.SetPrefab(m_prefabs[name]); DefaultOptions modded = m_modded[name]; DefaultOptions stored = m_default[name]; StringBuilder details = new StringBuilder(); if (modded.m_enabled != stored.m_enabled && options.enabled == stored.m_enabled) { options.enabled = modded.m_enabled; details.Append("enabled, "); } if (modded.m_addBackEngine != stored.m_addBackEngine && options.addBackEngine == stored.m_addBackEngine) { options.addBackEngine = modded.m_addBackEngine; details.Append("back engine, "); } if (modded.m_maxSpeed != stored.m_maxSpeed && options.maxSpeed == stored.m_maxSpeed) { options.maxSpeed = modded.m_maxSpeed; details.Append("max speed, "); } if (modded.m_acceleration != stored.m_acceleration && options.acceleration == stored.m_acceleration) { options.acceleration = modded.m_acceleration; details.Append("acceleration, "); } if (modded.m_braking != stored.m_braking && options.braking == stored.m_braking) { options.braking = modded.m_braking; details.Append("braking, "); } if (modded.m_turning != stored.m_turning && options.turning == stored.m_turning) { options.turning = modded.m_turning; details.Append("turning, "); } if (modded.m_springs != stored.m_springs && options.springs == stored.m_springs) { options.springs = modded.m_springs; details.Append("springs, "); } if (modded.m_dampers != stored.m_dampers && options.dampers == stored.m_dampers) { options.dampers = modded.m_dampers; details.Append("dampers, "); } if (modded.m_leanMultiplier != stored.m_leanMultiplier && options.leanMultiplier == stored.m_leanMultiplier) { options.leanMultiplier = modded.m_leanMultiplier; details.Append("leanMultiplier, "); } if (modded.m_nodMultiplier != stored.m_nodMultiplier && options.nodMultiplier == stored.m_nodMultiplier) { options.nodMultiplier = modded.m_nodMultiplier; details.Append("nodMultiplier, "); } if (modded.m_capacity != stored.m_capacity && options.capacity == stored.m_capacity) { options.capacity = modded.m_capacity; details.Append("capacity, "); } if (details.Length > 0) { details.Length -= 2; conflicts.AppendLine(options.name + ": " + details); } } if (conflicts.Length > 0) { VehicleOptions.UpdateTransfertVehicles(); DebugUtils.Log("Conflicts detected (this message is harmless):" + Environment.NewLine + conflicts); } }