From 26ae6f443234f853ac7198014301d5c5275ecf1f Mon Sep 17 00:00:00 2001 From: bttf92 Date: Mon, 27 Sep 2021 23:32:12 +0200 Subject: [PATCH] Various improvements - Bumped SHVDN to 3.3.1 - Bumped LemonUI to 1.5.1 - Use new FusionLibrary stuff - Removed obsolete code - Fixed some bugs --- .gitmodules | 6 - BackToTheFutureV.sln | 20 --- BackToTheFutureV/BackToTheFutureV.csproj | 70 ++------- BackToTheFutureV/GUI/SIDScaleform.cs | 2 +- BackToTheFutureV/Main.cs | 2 +- BackToTheFutureV/Menu/ControlsMenu.cs | 28 ++-- BackToTheFutureV/Menu/CustomMenu.cs | 36 ++--- BackToTheFutureV/Menu/CustomMenu2.cs | 22 +-- BackToTheFutureV/Menu/EventsSettingsMenu.cs | 6 +- BackToTheFutureV/Menu/GarageMenu.cs | 20 +-- BackToTheFutureV/Menu/MainMenu.cs | 18 +-- BackToTheFutureV/Menu/MenuHandler.cs | 8 +- BackToTheFutureV/Menu/PhotoMenu.cs | 22 +-- BackToTheFutureV/Menu/PresetsMenu.cs | 8 +- BackToTheFutureV/Menu/RCMenu.cs | 12 +- BackToTheFutureV/Menu/SettingsMenu.cs | 22 +-- BackToTheFutureV/Menu/SoundsSettingsMenu.cs | 8 +- BackToTheFutureV/Menu/TCDMenu.cs | 20 +-- BackToTheFutureV/Menu/TimeMachineMenu.cs | 4 +- .../Players/EmitterSparkPlayer.cs | 4 +- BackToTheFutureV/Players/FireTrail.cs | 141 ++++++------------ BackToTheFutureV/Players/FireTrailsHandler.cs | 4 +- .../Players/MrFusionRefillPlayer.cs | 6 +- .../Players/PlutoniumRefillPlayer.cs | 12 +- BackToTheFutureV/Players/SparkPlayer.cs | 2 +- .../Players/WheelAnimationPlayer.cs | 22 +-- .../Players/WormholeAnimationPlayer.cs | 36 ++--- BackToTheFutureV/Settings/ModSettings.cs | 4 +- BackToTheFutureV/Story/MissionHandler.cs | 2 +- .../Story/Missions/ClocktowerMission.cs | 135 ++++++----------- .../Clone/TimeMachineCloneHandler.cs | 2 +- .../Handlers/BaseHandlers/ConstantsHandler.cs | 6 +- .../Handlers/BaseHandlers/ModsHandler.cs | 3 + .../Handlers/BaseHandlers/ParticlesHandler.cs | 66 ++++---- .../Handlers/BaseHandlers/PropsHandler.cs | 8 +- .../Handlers/ClockHandler.cs | 2 +- .../Handlers/FluxCapacitorHandler.cs | 2 +- .../Handlers/FlyingHandler.cs | 13 +- .../Handlers/FreezeHandler.cs | 18 +-- .../Handlers/FuelHandler.cs | 2 +- .../TimeMachineClasses/Handlers/RCHandler.cs | 2 +- .../Handlers/RailroadHandler.cs | 4 +- .../Handlers/StarterHandler.cs | 4 +- .../Handlers/TCD3DRowHandler.cs | 6 +- .../TimeMachineClasses/Handlers/TCDHandler.cs | 10 +- .../RC/RemoteTimeMachine.cs | 2 +- .../RC/RemoteTimeMachineHandler.cs | 4 +- .../TimeMachineClasses/TimeMachine.cs | 62 +++----- .../TimeMachineClasses/TimeMachineHandler.cs | 6 +- BackToTheFutureV/Utility/GarageHandler.cs | 6 +- BackToTheFutureV/Utility/InternalInventory.cs | 2 +- BackToTheFutureV/Utility/ModelHandler.cs | 4 +- BackToTheFutureV/Utility/TextHandler.cs | 2 +- .../Utility/Wayback/WaybackSystem.cs | 2 +- BackToTheFutureV/Vehicles/DMC12/DMC12.cs | 32 ++-- .../Vehicles/DMC12/DMC12Handler.cs | 6 +- BackToTheFutureV/Vehicles/DMC12/DMC12Mods.cs | 28 ++-- .../Vehicles/Train/CustomTrain.cs | 6 +- .../Vehicles/Train/CustomTrainHandler.cs | 6 +- BackToTheFutureV/packages.config | 2 + FusionLibrary | 1 - KlangRageAudioLibrary | 1 - 62 files changed, 417 insertions(+), 605 deletions(-) create mode 100644 BackToTheFutureV/packages.config delete mode 160000 FusionLibrary delete mode 160000 KlangRageAudioLibrary diff --git a/.gitmodules b/.gitmodules index 045cee1f..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "KlangRageAudioLibrary"] - path = KlangRageAudioLibrary - url = https://github.com/bttfv/KlangRageAudioLibrary -[submodule "FusionLibrary"] - path = FusionLibrary - url = https://github.com/bttfv/FusionLibrary diff --git a/BackToTheFutureV.sln b/BackToTheFutureV.sln index 900ff021..594cf14a 100644 --- a/BackToTheFutureV.sln +++ b/BackToTheFutureV.sln @@ -5,10 +5,6 @@ VisualStudioVersion = 16.0.30503.244 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackToTheFutureV", "BackToTheFutureV\BackToTheFutureV.csproj", "{7BE2F39B-E0F1-4F7D-B674-BC595E4AF50D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KlangRageAudioLibrary", "KlangRageAudioLibrary\KlangRageAudioLibrary.csproj", "{E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FusionLibrary", "FusionLibrary\FusionLibrary.csproj", "{F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,22 +21,6 @@ Global {7BE2F39B-E0F1-4F7D-B674-BC595E4AF50D}.Release|Any CPU.Build.0 = Release|Any CPU {7BE2F39B-E0F1-4F7D-B674-BC595E4AF50D}.Release|x64.ActiveCfg = Release|Any CPU {7BE2F39B-E0F1-4F7D-B674-BC595E4AF50D}.Release|x64.Build.0 = Release|Any CPU - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Debug|x64.ActiveCfg = Debug|x64 - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Debug|x64.Build.0 = Debug|x64 - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Release|Any CPU.Build.0 = Release|Any CPU - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Release|x64.ActiveCfg = Release|x64 - {E52DB215-0AA9-453A-B5F3-91F3FF35C1D9}.Release|x64.Build.0 = Release|x64 - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Debug|x64.ActiveCfg = Debug|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Debug|x64.Build.0 = Debug|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Release|Any CPU.Build.0 = Release|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Release|x64.ActiveCfg = Release|Any CPU - {F5AAD1BD-63CA-4A12-97A8-F0D876AB4462}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BackToTheFutureV/BackToTheFutureV.csproj b/BackToTheFutureV/BackToTheFutureV.csproj index d3c87bf0..e330e528 100644 --- a/BackToTheFutureV/BackToTheFutureV.csproj +++ b/BackToTheFutureV/BackToTheFutureV.csproj @@ -46,7 +46,6 @@ x64 7.3 prompt - MinimumRecommendedRules.ruleset true @@ -58,59 +57,22 @@ x64 7.3 prompt - MinimumRecommendedRules.ruleset - - - true - bin\Release %28Test%29\ - TRACE - true - true - full - AnyCPU - 7.3 - prompt - - - true - bin\x64\Release %28Test%29\ - TRACE - true - true - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\Debug %28Test%29\ - DEBUG;TRACE - true - full - AnyCPU - 7.3 - prompt - - - true - bin\x64\Debug %28Test%29\ - DEBUG;TRACE - true - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset $(GTAPath)\scripts\BackToTheFutureV.HUD.Core.dll + + False + $(GTAPath)\scripts\FusionLibrary.dll + False - ..\KlangRageAudioLibrary\irrKlang\irrKlang.NET4.dll + $(GTAPath)\scripts\irrKlang.NET4.dll + + + False + $(GTAPath)\scripts\KlangRageAudioLibrary.dll @@ -234,25 +196,15 @@ - - - {f5aad1bd-63ca-4a12-97a8-f0d876ab4462} - FusionLibrary - - - {e52db215-0aa9-453a-b5f3-91f3ff35c1d9} - KlangRageAudioLibrary - - - 1.4.0 + 1.5.1 3.8.0.1641 - 3.1.0 + 3.3.1 diff --git a/BackToTheFutureV/GUI/SIDScaleform.cs b/BackToTheFutureV/GUI/SIDScaleform.cs index b65aa2ad..cd6da9a2 100644 --- a/BackToTheFutureV/GUI/SIDScaleform.cs +++ b/BackToTheFutureV/GUI/SIDScaleform.cs @@ -10,7 +10,7 @@ internal class SIDScaleform : ScaleformGui private PropertiesHandler Properties => TimeMachineHandler.ClosestTimeMachine.Properties; private static PointF SID3DLocation = new PointF() { X = 0.626f, Y = 0.626f }; - private static float SID3DScale = 1.284f; + private static readonly float SID3DScale = 1.284f; public SIDScaleform(bool is2D) : base(is2D ? "bttf_2d_sid" : "bttf_3d_sid") { diff --git a/BackToTheFutureV/Main.cs b/BackToTheFutureV/Main.cs index a8ed7c9a..a8da594b 100644 --- a/BackToTheFutureV/Main.cs +++ b/BackToTheFutureV/Main.cs @@ -71,7 +71,7 @@ private unsafe void Main_Tick(object sender, EventArgs e) ModelHandler.RequestModels(); //Disable fake shake of the cars. - Function.Call((Hash)0x84FD40F56075E816, 0); + Function.Call(Hash._​SET_​CAR_​HIGH_​SPEED_​BUMP_​SEVERITY_​MULTIPLIER, 0); if (ModSettings.PersistenceSystem) { diff --git a/BackToTheFutureV/Menu/ControlsMenu.cs b/BackToTheFutureV/Menu/ControlsMenu.cs index e2c2b625..17a18602 100644 --- a/BackToTheFutureV/Menu/ControlsMenu.cs +++ b/BackToTheFutureV/Menu/ControlsMenu.cs @@ -10,24 +10,24 @@ namespace BackToTheFutureV { internal class ControlsMenu : BTTFVMenu { - private NativeCheckboxItem UseControlForMainMenu; - private NativeListItem MainMenu; + private readonly NativeCheckboxItem UseControlForMainMenu; + private readonly NativeListItem MainMenu; - private NativeCheckboxItem CombinationsForInteractionMenu; - private NativeListItem InteractionMenu1; - private NativeListItem InteractionMenu2; + private readonly NativeCheckboxItem CombinationsForInteractionMenu; + private readonly NativeListItem InteractionMenu1; + private readonly NativeListItem InteractionMenu2; - private NativeCheckboxItem LongPressForHover; - private NativeListItem Hover; - private NativeListItem HoverBoost; - private NativeListItem HoverVTOL; - private NativeListItem HoverAltitudeHold; + private readonly NativeCheckboxItem LongPressForHover; + private readonly NativeListItem Hover; + private readonly NativeListItem HoverBoost; + private readonly NativeListItem HoverVTOL; + private readonly NativeListItem HoverAltitudeHold; - private NativeListItem TCToggle; - private NativeListItem CutsceneToggle; - private NativeListItem InputToggle; + private readonly NativeListItem TCToggle; + private readonly NativeListItem CutsceneToggle; + private readonly NativeListItem InputToggle; - private NativeItem Reset; + private readonly NativeItem Reset; private bool _doNotUpdate; diff --git a/BackToTheFutureV/Menu/CustomMenu.cs b/BackToTheFutureV/Menu/CustomMenu.cs index 0f5233d7..07b3df6f 100644 --- a/BackToTheFutureV/Menu/CustomMenu.cs +++ b/BackToTheFutureV/Menu/CustomMenu.cs @@ -13,19 +13,19 @@ internal class CustomMenu : BTTFVMenu { public bool ForceNew = false; - private NativeListItem _wormholeType; - private NativeListItem _reactorType; - private NativeListItem _wheelsType; - private NativeCheckboxItem _hoverUnderbody; - private NativeCheckboxItem _hoodBox; - private NativeCheckboxItem _hook; - private NativeCheckboxItem _threeDigits; - private NativeListItem _plate; - private NativeListItem _exhaust; - private NativeListItem _suspensions; - private NativeListItem _hood; - private NativeItem _saveConf; - private NativeItem _confirm; + private readonly NativeListItem _wormholeType; + private readonly NativeListItem _reactorType; + private readonly NativeListItem _wheelsType; + private readonly NativeCheckboxItem _hoverUnderbody; + private readonly NativeCheckboxItem _hoodBox; + private readonly NativeCheckboxItem _hook; + private readonly NativeCheckboxItem _threeDigits; + private readonly NativeListItem _plate; + private readonly NativeListItem _exhaust; + private readonly NativeListItem _suspensions; + private readonly NativeListItem _hood; + private readonly NativeItem _saveConf; + private readonly NativeItem _confirm; private TimeMachine _tempTimeMachine; @@ -193,10 +193,10 @@ private bool ConvertFromModState(ModState value) public override void Menu_Shown(object sender, EventArgs e) { if (MenuHandler.MainMenu.Visible) - MenuHandler.MainMenu.Close(); + MenuHandler.MainMenu.Visible = false; if (MenuHandler.TimeMachineMenu.Visible) - MenuHandler.TimeMachineMenu.Close(); + MenuHandler.TimeMachineMenu.Visible = false; if (ForceNew || (FusionUtils.PlayerVehicle == null || !FusionUtils.PlayerVehicle.IsTimeMachine())) { @@ -211,7 +211,7 @@ public override void Menu_Shown(object sender, EventArgs e) if (_tempTimeMachine.Constants.FullDamaged) { - Close(); + Visible = false; return; } @@ -234,7 +234,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) if (sender == _wormholeType | sender == _confirm) { GarageHandler.WaitForCustomMenu = false; - Close(); + Visible = false; } else if (sender == _saveConf) { @@ -275,7 +275,7 @@ public override void Tick() { if (FusionUtils.PlayerVehicle != _tempTimeMachine) { - Close(); + Visible = false; return; } diff --git a/BackToTheFutureV/Menu/CustomMenu2.cs b/BackToTheFutureV/Menu/CustomMenu2.cs index 1360326e..32aaa069 100644 --- a/BackToTheFutureV/Menu/CustomMenu2.cs +++ b/BackToTheFutureV/Menu/CustomMenu2.cs @@ -9,14 +9,14 @@ namespace BackToTheFutureV { internal class CustomMenu2 : BTTFVMenu { - private NativeListItem _wormholeType; - private NativeListItem _wheelsType; - private NativeCheckboxItem _hook; - private NativeCheckboxItem _threeDigits; - private NativeListItem _plate; - private NativeListItem _exhaust; - private NativeListItem _suspensions; - private NativeListItem _hood; + private readonly NativeListItem _wormholeType; + private readonly NativeListItem _wheelsType; + private readonly NativeCheckboxItem _hook; + private readonly NativeCheckboxItem _threeDigits; + private readonly NativeListItem _plate; + private readonly NativeListItem _exhaust; + private readonly NativeListItem _suspensions; + private readonly NativeListItem _hood; private TimeMachine TimeMachine => TimeMachineHandler.CurrentTimeMachine; @@ -166,10 +166,10 @@ private void LoadVehicleMods() public override void Menu_Shown(object sender, EventArgs e) { if (MenuHandler.MainMenu.Visible) - MenuHandler.MainMenu.Close(); + MenuHandler.MainMenu.Visible = false; if (MenuHandler.TimeMachineMenu.Visible) - MenuHandler.TimeMachineMenu.Close(); + MenuHandler.TimeMachineMenu.Visible = false; _hook.Enabled = TimeMachine.Mods.IsDMC12; _plate.Enabled = TimeMachine.Mods.IsDMC12; @@ -209,7 +209,7 @@ public override void Tick() { if (FusionUtils.PlayerVehicle != TimeMachine) { - Close(); + Visible = false; return; } diff --git a/BackToTheFutureV/Menu/EventsSettingsMenu.cs b/BackToTheFutureV/Menu/EventsSettingsMenu.cs index 0c280755..762cf346 100644 --- a/BackToTheFutureV/Menu/EventsSettingsMenu.cs +++ b/BackToTheFutureV/Menu/EventsSettingsMenu.cs @@ -6,9 +6,9 @@ namespace BackToTheFutureV { internal class EventsSettingsMenu : BTTFVMenu { - private NativeCheckboxItem LightningStrikeEvent; - private NativeCheckboxItem EngineStallEvent; - private NativeCheckboxItem TurbulenceEvent; + private readonly NativeCheckboxItem LightningStrikeEvent; + private readonly NativeCheckboxItem EngineStallEvent; + private readonly NativeCheckboxItem TurbulenceEvent; public EventsSettingsMenu() : base("Events") { diff --git a/BackToTheFutureV/Menu/GarageMenu.cs b/BackToTheFutureV/Menu/GarageMenu.cs index 63cd9fd1..20b2b831 100644 --- a/BackToTheFutureV/Menu/GarageMenu.cs +++ b/BackToTheFutureV/Menu/GarageMenu.cs @@ -12,17 +12,17 @@ namespace BackToTheFutureV { internal class GarageMenu : BTTFVMenu { - private NativeItem transformInto; - private NativeItem hoverConvert; - private NativeItem installMrFusion; - private NativeItem buyPlutonium; - private NativeItem repairTC; - private NativeItem repairFC; - private NativeItem repairEngine; + private readonly NativeItem transformInto; + private readonly NativeItem hoverConvert; + private readonly NativeItem installMrFusion; + private readonly NativeItem buyPlutonium; + private readonly NativeItem repairTC; + private readonly NativeItem repairFC; + private readonly NativeItem repairEngine; public static AudioPlayer[] GarageSounds { get; } = { Main.CommonAudioEngine.Create("general/garage/tireChange.wav", Presets.No3D), Main.CommonAudioEngine.Create("general/garage/drill1.wav", Presets.No3D), Main.CommonAudioEngine.Create("general/garage/drill2.wav", Presets.No3D), Main.CommonAudioEngine.Create("general/garage/drill3.wav", Presets.No3D) }; - private NativeSubmenuItem customMenu; + private readonly NativeSubmenuItem customMenu; public GarageMenu() : base("Garage") { @@ -61,7 +61,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) //TimeMachineHandler.Create(FusionUtils.PlayerVehicle).Properties.ReactorCharge = 0; Game.Player.Money -= 500000; GarageHandler.Transform = true; - Close(); + Visible = false; } if (sender == hoverConvert) @@ -175,7 +175,7 @@ public override void Tick() { if (!FusionUtils.PlayerVehicle.NotNullAndExists()) { - Close(); + Visible = false; return; } diff --git a/BackToTheFutureV/Menu/MainMenu.cs b/BackToTheFutureV/Menu/MainMenu.cs index 6d2b87f5..77957f08 100644 --- a/BackToTheFutureV/Menu/MainMenu.cs +++ b/BackToTheFutureV/Menu/MainMenu.cs @@ -12,16 +12,16 @@ namespace BackToTheFutureV { internal class MainMenu : BTTFVMenu { - private NativeListItem spawnBTTF; + private readonly NativeListItem spawnBTTF; - private NativeItem convertIntoTimeMachine; + private readonly NativeItem convertIntoTimeMachine; - private NativeSubmenuItem rcMenu; - private NativeSubmenuItem outatimeMenu; + private readonly NativeSubmenuItem rcMenu; + private readonly NativeSubmenuItem outatimeMenu; - private NativeItem deleteCurrent; - private NativeItem deleteOthers; - private NativeItem deleteAll; + private readonly NativeItem deleteCurrent; + private readonly NativeItem deleteOthers; + private readonly NativeItem deleteAll; public MainMenu() : base("Main") { @@ -90,7 +90,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) if (spawnBTTF.SelectedIndex == 0) { FusionUtils.PlayerPed.Task.WarpIntoVehicle(DMC12Handler.CreateDMC12(FusionUtils.PlayerPed.Position, FusionUtils.PlayerPed.Heading), VehicleSeat.Driver); - Close(); + Visible = false; return; } @@ -158,7 +158,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) ExternalHUD.SetOff(); } - Close(); + Visible = false; } public override void Menu_OnItemCheckboxChanged(NativeCheckboxItem sender, EventArgs e, bool Checked) diff --git a/BackToTheFutureV/Menu/MenuHandler.cs b/BackToTheFutureV/Menu/MenuHandler.cs index 4b7d53d8..2cba1473 100644 --- a/BackToTheFutureV/Menu/MenuHandler.cs +++ b/BackToTheFutureV/Menu/MenuHandler.cs @@ -41,16 +41,16 @@ public static void Tick() if (RemoteTimeMachineHandler.IsRemoteOn) { - TimeMachineMenu.Open(); + TimeMachineMenu.Visible = true; return; } else if (CustomNativeMenu.ObjectPool.AreAnyVisible) return; if (TimeMachineHandler.CurrentTimeMachine != null) - TimeMachineMenu.Open(); + TimeMachineMenu.Visible = true; else - MainMenu.Open(); + MainMenu.Visible = true; } } } @@ -68,7 +68,7 @@ public static void KeyDown(KeyEventArgs e) CustomNativeMenu.ObjectPool.HideAll(); - MainMenu.Open(); + MainMenu.Visible = true; } } } diff --git a/BackToTheFutureV/Menu/PhotoMenu.cs b/BackToTheFutureV/Menu/PhotoMenu.cs index eac88364..671a30a3 100644 --- a/BackToTheFutureV/Menu/PhotoMenu.cs +++ b/BackToTheFutureV/Menu/PhotoMenu.cs @@ -7,15 +7,15 @@ namespace BackToTheFutureV { internal class PhotoMenu : BTTFVMenu { - private NativeCheckboxItem Wormhole; - private NativeCheckboxItem Coils; - private NativeCheckboxItem Ice; - private NativeCheckboxItem FluxCapacitor; - private NativeCheckboxItem EngineStall; - private NativeCheckboxItem SIDMax; - private NativeItem LightningStrike; - private NativeSliderItem StrikeDelay; - private NativeCheckboxItem HideHUD; + private readonly NativeCheckboxItem Wormhole; + private readonly NativeCheckboxItem Coils; + private readonly NativeCheckboxItem Ice; + private readonly NativeCheckboxItem FluxCapacitor; + private readonly NativeCheckboxItem EngineStall; + private readonly NativeCheckboxItem SIDMax; + private readonly NativeItem LightningStrike; + private readonly NativeSliderItem StrikeDelay; + private readonly NativeCheckboxItem HideHUD; private TimeMachine TimeMachine => TimeMachineHandler.CurrentTimeMachine; @@ -43,7 +43,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) if (sender == LightningStrike) { TimeMachine.Events.StartLightningStrike?.Invoke(StrikeDelay.Value); - Close(); + Visible = false; } } @@ -90,7 +90,7 @@ public override void Tick() { if (TimeMachineHandler.CurrentTimeMachine == null) { - Close(); + Visible = false; return; } diff --git a/BackToTheFutureV/Menu/PresetsMenu.cs b/BackToTheFutureV/Menu/PresetsMenu.cs index 97a5e761..2693aec0 100644 --- a/BackToTheFutureV/Menu/PresetsMenu.cs +++ b/BackToTheFutureV/Menu/PresetsMenu.cs @@ -10,7 +10,7 @@ namespace BackToTheFutureV { internal class PresetsMenu : BTTFVMenu { - private InstrumentalMenu _instrumentalMenu; + private readonly InstrumentalMenu _instrumentalMenu; public PresetsMenu() : base("Presets") { @@ -30,7 +30,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) else TimeMachineHandler.Create(sender.Title, SpawnFlags.NoPosition | SpawnFlags.NoOccupants | SpawnFlags.NoProperties | SpawnFlags.NoVelocity | SpawnFlags.WarpPlayer); - Close(); + Visible = false; } public override void Menu_Shown(object sender, EventArgs e) @@ -70,9 +70,9 @@ public override void Tick() if (Game.IsControlJustPressed(Control.PhoneExtraOption)) { - Close(); + Visible = false; - MenuHandler.CustomMenuPresets.Open(); + MenuHandler.CustomMenuPresets.Visible = true; } } diff --git a/BackToTheFutureV/Menu/RCMenu.cs b/BackToTheFutureV/Menu/RCMenu.cs index 4664e318..a1043517 100644 --- a/BackToTheFutureV/Menu/RCMenu.cs +++ b/BackToTheFutureV/Menu/RCMenu.cs @@ -11,10 +11,10 @@ namespace BackToTheFutureV { internal class RCMenu : BTTFVMenu { - private NativeListItem timeMachinesList; - private NativeCheckboxItem FuelChamberDescription; - private NativeCheckboxItem TimeCircuitsOnDescription; - private NativeItem DestinationTimeDescription; + private readonly NativeListItem timeMachinesList; + private readonly NativeCheckboxItem FuelChamberDescription; + private readonly NativeCheckboxItem TimeCircuitsOnDescription; + private readonly NativeItem DestinationTimeDescription; private TimeMachine CurrentTimeMachine => timeMachinesList.SelectedItem; private Camera CarCam { get; set; } @@ -48,7 +48,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) { if (CanBeSelected) { - Close(); + Visible = false; RemoteTimeMachineHandler.StartRemoteControl(CurrentTimeMachine); } @@ -111,7 +111,7 @@ public void StopPreviewing() public override void Tick() { if (FusionUtils.PlayerVehicle != null) - Close(); + Visible = false; } public override void Menu_OnItemValueChanged(NativeSliderItem sender, EventArgs e) diff --git a/BackToTheFutureV/Menu/SettingsMenu.cs b/BackToTheFutureV/Menu/SettingsMenu.cs index 6504e914..f1299474 100644 --- a/BackToTheFutureV/Menu/SettingsMenu.cs +++ b/BackToTheFutureV/Menu/SettingsMenu.cs @@ -7,17 +7,17 @@ namespace BackToTheFutureV { internal class SettingsMenu : BTTFVMenu { - private NativeCheckboxItem cinematicSpawn; - private NativeCheckboxItem useInputToggle; - private NativeCheckboxItem forceFlyMode; - private NativeCheckboxItem LandingSystem; - private NativeCheckboxItem InfiniteFuel; - private NativeCheckboxItem PersistenceSystem; - private NativeCheckboxItem WaybackSystem; - private NativeCheckboxItem RandomTrains; - private NativeCheckboxItem RealTime; - private NativeCheckboxItem GlowingWormholeEmitter; - private NativeCheckboxItem GlowingPlutoniumReactor; + private readonly NativeCheckboxItem cinematicSpawn; + private readonly NativeCheckboxItem useInputToggle; + private readonly NativeCheckboxItem forceFlyMode; + private readonly NativeCheckboxItem LandingSystem; + private readonly NativeCheckboxItem InfiniteFuel; + private readonly NativeCheckboxItem PersistenceSystem; + private readonly NativeCheckboxItem WaybackSystem; + private readonly NativeCheckboxItem RandomTrains; + private readonly NativeCheckboxItem RealTime; + private readonly NativeCheckboxItem GlowingWormholeEmitter; + private readonly NativeCheckboxItem GlowingPlutoniumReactor; public SettingsMenu() : base("Settings") { diff --git a/BackToTheFutureV/Menu/SoundsSettingsMenu.cs b/BackToTheFutureV/Menu/SoundsSettingsMenu.cs index 16493d5a..2d546eef 100644 --- a/BackToTheFutureV/Menu/SoundsSettingsMenu.cs +++ b/BackToTheFutureV/Menu/SoundsSettingsMenu.cs @@ -6,10 +6,10 @@ namespace BackToTheFutureV { internal class SoundsSettingsMenu : BTTFVMenu { - private NativeCheckboxItem playFluxCapacitorSound; - private NativeCheckboxItem playDiodeSound; - private NativeCheckboxItem playSpeedoBeep; - private NativeCheckboxItem playEngineSounds; + private readonly NativeCheckboxItem playFluxCapacitorSound; + private readonly NativeCheckboxItem playDiodeSound; + private readonly NativeCheckboxItem playSpeedoBeep; + private readonly NativeCheckboxItem playEngineSounds; public SoundsSettingsMenu() : base("Sounds") { diff --git a/BackToTheFutureV/Menu/TCDMenu.cs b/BackToTheFutureV/Menu/TCDMenu.cs index 14bfda23..b8ca87ad 100644 --- a/BackToTheFutureV/Menu/TCDMenu.cs +++ b/BackToTheFutureV/Menu/TCDMenu.cs @@ -7,16 +7,16 @@ namespace BackToTheFutureV { internal class TCDMenu : BTTFVMenu { - private NativeListItem tcdBackground; - private NativeItem changeTCD; - private NativeItem resetToDefaultTCD; + private readonly NativeListItem tcdBackground; + private readonly NativeItem changeTCD; + private readonly NativeItem resetToDefaultTCD; - private NativeItem changeRCGUI; + private readonly NativeItem changeRCGUI; - private NativeCheckboxItem hideSID; - private NativeCheckboxItem useExternalTCD; - private NativeCheckboxItem useNetworkTCD; - private NativeCheckboxItem hideIngameTCD; + private readonly NativeCheckboxItem hideSID; + private readonly NativeCheckboxItem useExternalTCD; + private readonly NativeCheckboxItem useNetworkTCD; + private readonly NativeCheckboxItem hideIngameTCD; public TCDMenu() : base("TCD") { @@ -56,7 +56,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) { TcdEditer.SetEditMode(true); - Close(); + Visible = false; } if (sender == resetToDefaultTCD) @@ -75,7 +75,7 @@ public override void Menu_OnItemActivated(NativeItem sender, EventArgs e) { RCGUIEditer.SetEditMode(true); - Close(); + Visible = false; } } diff --git a/BackToTheFutureV/Menu/TimeMachineMenu.cs b/BackToTheFutureV/Menu/TimeMachineMenu.cs index be84116c..5f3e369a 100644 --- a/BackToTheFutureV/Menu/TimeMachineMenu.cs +++ b/BackToTheFutureV/Menu/TimeMachineMenu.cs @@ -43,7 +43,7 @@ public override void Menu_Shown(object sender, EventArgs e) { if (TimeMachineHandler.CurrentTimeMachine == null) { - Close(); + Visible = false; return; } @@ -82,7 +82,7 @@ public override void Tick() { if (TimeMachineHandler.CurrentTimeMachine == null) { - Close(); + Visible = false; return; } diff --git a/BackToTheFutureV/Players/EmitterSparkPlayer.cs b/BackToTheFutureV/Players/EmitterSparkPlayer.cs index 38b96d20..219aa2b3 100644 --- a/BackToTheFutureV/Players/EmitterSparkPlayer.cs +++ b/BackToTheFutureV/Players/EmitterSparkPlayer.cs @@ -12,9 +12,9 @@ internal class EmitterSparkPlayer : Players.Player private Vector3 _destination; - private AnimateProp _spark; + private readonly AnimateProp _spark; - private SparkType _sparkType; + private readonly SparkType _sparkType; private float _speed; diff --git a/BackToTheFutureV/Players/FireTrail.cs b/BackToTheFutureV/Players/FireTrail.cs index 9913a54f..1d68940a 100644 --- a/BackToTheFutureV/Players/FireTrail.cs +++ b/BackToTheFutureV/Players/FireTrail.cs @@ -2,7 +2,7 @@ using GTA; using GTA.Math; using System; -using System.Collections.Generic; +using static FusionLibrary.FusionEnums; namespace BackToTheFutureV { @@ -52,30 +52,19 @@ internal class FireTrail new Vector3(-0.7550426f, 3.894026f, 0.1759465f) }; - private List _fireTrailPtfxs = new List(); + private readonly ParticlePlayerHandler _fireTrailPtfxs = new ParticlePlayerHandler(); - private int _nextSpawn; - private int _currentSpawnIndex; - private int _appearTime; + private readonly int _appearTime; + private readonly int _disappearTime; private float _currentStrength; - private float _currentFadeIn; - private float _disappearAt = -1; - private float _disappearTime; - private float _fireSize; - private bool _is99; - private bool _hasSpawned; - private bool _useBlueFadein; + private bool _fadeAway; - public FireTrail(Vehicle vehicle, bool is99, float disappearTime, int appearTime, bool useBlueFadein, int maxLength) + public FireTrail(Vehicle vehicle, bool is99, int disappearTime, int appearTime, int maxLength) { - _is99 = is99; _disappearTime = disappearTime; _appearTime = appearTime; - _useBlueFadein = useBlueFadein; - - _fireSize = 1.2f; if (!is99) { @@ -103,20 +92,8 @@ public FireTrail(Vehicle vehicle, bool is99, float disappearTime, int appearTime } // Create and configure fire particle - PtfxPlayer leftWheelPtfx = new PtfxPlayer("core", "fire_petrol_one", leftPosOffset, vehicle.Rotation, _fireSize, true, false); - PtfxPlayer rightWheelPtfx = new PtfxPlayer("core", "fire_petrol_one", rightPosOffset, vehicle.Rotation, _fireSize, true, false); - - _currentStrength = 1f; - _currentFadeIn = useBlueFadein ? 0.15f : 0f; - - _fireTrailPtfxs.Add(leftWheelPtfx); - _fireTrailPtfxs.Add(rightWheelPtfx); - foreach (PtfxPlayer ptfx in _fireTrailPtfxs) - { - ptfx.SetEvolutionParam("strength", 1f); - ptfx.SetEvolutionParam("dist", 0f); - ptfx.SetEvolutionParam("fadein", _currentFadeIn); - } + _fireTrailPtfxs.Add("core", "fire_petrol_one", ParticleType.Looped, leftPosOffset, vehicle.Rotation, 1.2f); + _fireTrailPtfxs.Add("core", "fire_petrol_one", ParticleType.Looped, rightPosOffset, vehicle.Rotation, 1.2f); } } else @@ -131,87 +108,61 @@ public FireTrail(Vehicle vehicle, bool is99, float disappearTime, int appearTime leftPosOffset = vehicle.GetOffsetPosition(leftPosOffset); rightPosOffset = vehicle.GetOffsetPosition(rightPosOffset); - PtfxPlayer leftWheelPtfx = new PtfxPlayer("core", "fire_petrol_one", leftPosOffset, vehicle.Rotation, _fireSize, true, false); - PtfxPlayer rightWheelPtfx = new PtfxPlayer("core", "fire_petrol_one", rightPosOffset, vehicle.Rotation, _fireSize, true, false); - - _currentStrength = 1f; - - _fireTrailPtfxs.Add(leftWheelPtfx); - _fireTrailPtfxs.Add(rightWheelPtfx); - foreach (PtfxPlayer ptfx in _fireTrailPtfxs) - { - ptfx.SetEvolutionParam("strength", 1); - ptfx.SetEvolutionParam("dist", 0f); - ptfx.SetEvolutionParam("fadein", 0f); - } + _fireTrailPtfxs.Add("core", "fire_petrol_one", ParticleType.Looped, leftPosOffset, vehicle.Rotation, 1.2f); + _fireTrailPtfxs.Add("core", "fire_petrol_one", ParticleType.Looped, rightPosOffset, vehicle.Rotation, 1.2f); } } - if (_appearTime == -1) - { - _hasSpawned = true; - _currentSpawnIndex = 0; - _fireTrailPtfxs.ForEach(x => x.Play()); - } - else + GTA.UI.Screen.ShowSubtitle($"{maxLength} {_fireTrailPtfxs.ParticlePlayers.Count}"); + + _currentStrength = 1f; + + _fireTrailPtfxs.SetEvolutionParam("strength", _currentStrength); + _fireTrailPtfxs.SetEvolutionParam("dist", 0f); + _fireTrailPtfxs.SetEvolutionParam("fadein", 0f); + + _fireTrailPtfxs.SequenceInterval = _appearTime; + + _fireTrailPtfxs.OnParticleSequenceCompleted += _fireTrailPtfxs_OnParticleSequenceCompleted; + + _fireTrailPtfxs.Play(); + + if (_appearTime == 0) { - _hasSpawned = false; - _currentSpawnIndex = 0; - } + _fireTrailPtfxs.SequenceInterval = 1; + _fireTrailPtfxs.StopInSequence(); + _fadeAway = true; + } } - public void Tick() + private void _fireTrailPtfxs_OnParticleSequenceCompleted(bool isStop) { - if (_fireTrailPtfxs.Count > 0) - { - if (!_hasSpawned && Game.GameTime > _nextSpawn) - { - if (_currentSpawnIndex > (_fireTrailPtfxs.Count - 1)) - { - _hasSpawned = true; - _currentSpawnIndex = 0; - } - else - { - _fireTrailPtfxs[_currentSpawnIndex].Play(); + if (!isStop) + _fadeAway = true; + } - _currentSpawnIndex++; - _nextSpawn = Game.GameTime + _appearTime; - } - return; - } + public void Tick() + { + if (!_fireTrailPtfxs.IsPlaying || !_fadeAway) + return; - float amountToSub = (1f * Game.LastFrameTime) / (_disappearTime * 0.75f); - _currentStrength -= amountToSub; + if (_currentStrength > 0) + { + _currentStrength -= Game.LastFrameTime * (1f / _disappearTime); if (_currentStrength < 0) _currentStrength = 0; - _fireTrailPtfxs.ForEach(x => x.SetEvolutionParam("strength", _currentStrength)); - - if (_useBlueFadein) - { - amountToSub = (0.15f * Game.LastFrameTime) / _disappearTime; - _currentFadeIn -= amountToSub; - - if (_currentFadeIn < 0) - _currentFadeIn = 0; - - _fireTrailPtfxs.ForEach(x => x.SetEvolutionParam("fadein", _currentFadeIn)); - } - - if (_currentStrength <= 0 && _disappearAt == -1) - _disappearAt = Game.GameTime + 5000; - else if (_currentStrength <= 0 && Game.GameTime > _disappearAt) - Stop(); + _fireTrailPtfxs.SetEvolutionParam("strength", _currentStrength); } + + if (_currentStrength == 0) + Stop(false); } - public void Stop() + public void Stop(bool instant = true) { - _fireTrailPtfxs.ForEach(x => x.RemovePtfx(x.Handle)); - _fireTrailPtfxs.ForEach(x => x.Dispose()); - _fireTrailPtfxs.Clear(); + _fireTrailPtfxs.Stop(instant); } } } \ No newline at end of file diff --git a/BackToTheFutureV/Players/FireTrailsHandler.cs b/BackToTheFutureV/Players/FireTrailsHandler.cs index 3067312b..b4fb377b 100644 --- a/BackToTheFutureV/Players/FireTrailsHandler.cs +++ b/BackToTheFutureV/Players/FireTrailsHandler.cs @@ -6,7 +6,7 @@ namespace BackToTheFutureV { internal class FireTrailsHandler { - private static List fireTrails = new List(); + private static readonly List fireTrails = new List(); static FireTrailsHandler() { @@ -15,7 +15,7 @@ static FireTrailsHandler() public static FireTrail SpawnForTimeMachine(TimeMachine timeMachine) { - FireTrail fireTrail = new FireTrail(timeMachine.Vehicle, timeMachine.Constants.FireTrailsIs99, timeMachine.Constants.FireTrailsDisappearTime, timeMachine.Constants.FireTrailsAppearTime, timeMachine.Constants.FireTrailsUseBlue, timeMachine.Constants.FireTrailsLength); + FireTrail fireTrail = new FireTrail(timeMachine.Vehicle, timeMachine.Constants.FireTrailsIs99, timeMachine.Constants.FireTrailsDisappearTime, timeMachine.Constants.FireTrailsAppearTime, timeMachine.Constants.FireTrailsLength); fireTrails.Add(fireTrail); return fireTrail; diff --git a/BackToTheFutureV/Players/MrFusionRefillPlayer.cs b/BackToTheFutureV/Players/MrFusionRefillPlayer.cs index 74633179..fefc0463 100644 --- a/BackToTheFutureV/Players/MrFusionRefillPlayer.cs +++ b/BackToTheFutureV/Players/MrFusionRefillPlayer.cs @@ -16,12 +16,12 @@ internal class MrFusionRefillPlayer : Players.Player public MrFusionRefillPlayer(TimeMachine timeMachine) : base(timeMachine) { _mrFusion = new AnimateProp(ModelHandler.BTTFMrFusion, Vehicle, "mr_fusion"); - _mrFusion[AnimationType.Rotation][AnimationStep.First][Coordinate.X].Setup(true, false, -70, 0, 1, 140, 1); + _mrFusion[AnimationType.Rotation][AnimationStep.First][Coordinate.X].Setup(true, false, -70, 0, 1, 140, 1, false); _mrFusion.OnAnimCompleted += _mrFusion_OnAnimCompleted; _mrFusion.SpawnProp(); _mrFusionHandle = new AnimateProp(ModelHandler.BTTFMrFusionHandle, Vehicle, "mr_fusion_handle"); - _mrFusionHandle[AnimationType.Rotation][AnimationStep.First][Coordinate.X].Setup(true, true, 0, 30, 1, 140, 1); + _mrFusionHandle[AnimationType.Rotation][AnimationStep.First][Coordinate.X].Setup(true, true, 0, 30, 1, 140, 1, false); _mrFusionHandle.OnAnimCompleted += _mrFusionHandle_OnAnimCompleted; _mrFusionHandle.SpawnProp(); @@ -41,7 +41,7 @@ private void _mrFusionHandle_OnAnimCompleted(AnimationStep animationStep) _mrFusion.Play(); else { - Particles.MrFusionSmoke?.StopNaturally(); + Particles.MrFusionSmoke?.Stop(); IsPlaying = false; OnPlayerCompleted?.Invoke(); diff --git a/BackToTheFutureV/Players/PlutoniumRefillPlayer.cs b/BackToTheFutureV/Players/PlutoniumRefillPlayer.cs index 8f970d8d..eeff944a 100644 --- a/BackToTheFutureV/Players/PlutoniumRefillPlayer.cs +++ b/BackToTheFutureV/Players/PlutoniumRefillPlayer.cs @@ -7,10 +7,10 @@ namespace BackToTheFutureV { internal class PlutoniumRefillPlayer : Players.Player { - private AnimateProp plutoniumCap; + private readonly AnimateProp plutoniumCap; - private AudioPlayer open; - private AudioPlayer close; + private readonly AudioPlayer open; + private readonly AudioPlayer close; public PlutoniumRefillPlayer(TimeMachine timeMachine) : base(timeMachine) { @@ -21,9 +21,9 @@ public PlutoniumRefillPlayer(TimeMachine timeMachine) : base(timeMachine) close.SourceBone = "bttf_reactorcap"; plutoniumCap = new AnimateProp(ModelHandler.BTTFReactorCap, Vehicle, "bttf_reactorcap"); - plutoniumCap[AnimationType.Rotation][AnimationStep.First][Coordinate.Z].Setup(true, false, -90, 0, 1, 240, 1); - plutoniumCap[AnimationType.Offset][AnimationStep.Second][Coordinate.Z].Setup(true, true, 0, 0.05f, 1, 0.16f, 1); - plutoniumCap[AnimationType.Offset][AnimationStep.Third][Coordinate.Y].Setup(true, true, 0, 0.08f, 1, 0.16f, 1); + plutoniumCap[AnimationType.Rotation][AnimationStep.First][Coordinate.Z].Setup(true, false, -90, 0, 1, 240, 1, false); + plutoniumCap[AnimationType.Offset][AnimationStep.Second][Coordinate.Z].Setup(true, true, 0, 0.05f, 1, 0.16f, 1, false); + plutoniumCap[AnimationType.Offset][AnimationStep.Third][Coordinate.Y].Setup(true, true, 0, 0.08f, 1, 0.16f, 1, false); plutoniumCap.OnAnimCompleted += PlutoniumCap_OnAnimCompleted; plutoniumCap.SpawnProp(); } diff --git a/BackToTheFutureV/Players/SparkPlayer.cs b/BackToTheFutureV/Players/SparkPlayer.cs index a5466470..3adb4511 100644 --- a/BackToTheFutureV/Players/SparkPlayer.cs +++ b/BackToTheFutureV/Players/SparkPlayer.cs @@ -17,7 +17,7 @@ public SparkPlayer(TimeMachine timeMachine, IEnumerable frames) : base( _spark = new AnimateProp(Constants.SparkModel, Vehicle, _frames[0], Vector3.Zero); } - private AnimateProp _spark; + private readonly AnimateProp _spark; private readonly List _frames = new List(); diff --git a/BackToTheFutureV/Players/WheelAnimationPlayer.cs b/BackToTheFutureV/Players/WheelAnimationPlayer.cs index 1a335b05..01f5594f 100644 --- a/BackToTheFutureV/Players/WheelAnimationPlayer.cs +++ b/BackToTheFutureV/Players/WheelAnimationPlayer.cs @@ -16,10 +16,10 @@ internal class WheelAnimationPlayer : Players.Player private bool AreWheelsOpen; - private AnimatePropsHandler AllProps = new AnimatePropsHandler(); + private readonly AnimatePropsHandler AllProps = new AnimatePropsHandler(); - private AnimatePropsHandler GlowWheels = new AnimatePropsHandler(); - private AnimatePropsHandler Wheels = new AnimatePropsHandler(); + private readonly AnimatePropsHandler GlowWheels = new AnimatePropsHandler(); + private readonly AnimatePropsHandler Wheels = new AnimatePropsHandler(); private static readonly Vector3 strutOffsetFromWheel = new Vector3(0.2247245f, -0.004109263f, 0.09079965f); private static readonly Vector3 diskOffsetFromStrut = new Vector3(-0.23691f, 0.002096051f, -0.1387549f); @@ -37,16 +37,16 @@ public WheelAnimationPlayer(TimeMachine timeMachine) : base(timeMachine) switch (wheel.WheelID) { - case WheelId.FrontLeft: + case VehicleWheelBoneId.WheelLeftFront: strutOffset = strutOffsetFromWheel.GetSingleOffset(Coordinate.Z, Mods.IsDMC12 ? 0 : 0.04f); break; - case WheelId.FrontRight: + case VehicleWheelBoneId.WheelRightFront: strutOffset = strutOffsetFromWheel.GetSingleOffset(Coordinate.Z, Mods.IsDMC12 ? 0 : 0.04f).InvertCoordinate(Coordinate.X); break; - case WheelId.RearLeft: + case VehicleWheelBoneId.WheelLeftRear: strutOffset = strutOffsetFromWheel.GetSingleOffset(Coordinate.Z, 0.02f); break; - case WheelId.RearRight: + case VehicleWheelBoneId.WheelRightRear: strutOffset = strutOffsetFromWheel.GetSingleOffset(Coordinate.Z, 0.02f).InvertCoordinate(Coordinate.X); break; } @@ -55,17 +55,17 @@ public WheelAnimationPlayer(TimeMachine timeMachine) : base(timeMachine) AnimateProp strut = new AnimateProp(ModelHandler.Strut, Vehicle, strutOffset, wheel.Left ? Vector3.Zero : new Vector3(0, 0, 180)); if (wheel.Left) - strut[AnimationType.Offset][AnimationStep.First][Coordinate.X].Setup(true, false, strutOffset.X - MAX_POSITION_OFFSET, strutOffset.X, 1, 0.30f, 1); + strut[AnimationType.Offset][AnimationStep.First][Coordinate.X].Setup(true, false, strutOffset.X - MAX_POSITION_OFFSET, strutOffset.X, 1, 0.30f, 1, false); else - strut[AnimationType.Offset][AnimationStep.First][Coordinate.X].Setup(true, true, strutOffset.X, strutOffset.X + MAX_POSITION_OFFSET, 1, 0.30f, 1); + strut[AnimationType.Offset][AnimationStep.First][Coordinate.X].Setup(true, true, strutOffset.X, strutOffset.X + MAX_POSITION_OFFSET, 1, 0.30f, 1, false); strut.SpawnProp(); AnimateProp disk = new AnimateProp(ModelHandler.Disk, strut, diskOffsetFromStrut, new Vector3(0, MAX_ROTATION_OFFSET, 0)); - disk[AnimationType.Rotation][AnimationStep.Second][Coordinate.Y].Setup(true, false, 0, MAX_ROTATION_OFFSET, 1, 120, 1); + disk[AnimationType.Rotation][AnimationStep.Second][Coordinate.Y].Setup(true, false, 0, MAX_ROTATION_OFFSET, 1, 120, 1, false); disk.SpawnProp(); AnimateProp piston = new AnimateProp(ModelHandler.Piston, disk, pistonOffsetFromDisk, new Vector3(0, -MAX_ROTATION_OFFSET, 0)); - piston[AnimationType.Rotation][AnimationStep.Second][Coordinate.Y].Setup(true, true, -MAX_ROTATION_OFFSET, 0, 1, 120, 1); + piston[AnimationType.Rotation][AnimationStep.Second][Coordinate.Y].Setup(true, true, -MAX_ROTATION_OFFSET, 0, 1, 120, 1, false); piston.SpawnProp(); Model wheelModel = wheel.Front ? Constants.WheelModel : Constants.WheelRearModel; diff --git a/BackToTheFutureV/Players/WormholeAnimationPlayer.cs b/BackToTheFutureV/Players/WormholeAnimationPlayer.cs index 81da78de..1cb11a7a 100644 --- a/BackToTheFutureV/Players/WormholeAnimationPlayer.cs +++ b/BackToTheFutureV/Players/WormholeAnimationPlayer.cs @@ -143,11 +143,11 @@ public WormholeAnimationPlayer(TimeMachine timeMachine) : base(timeMachine) private int _nextFlicker; private int _nextSpark; - private List _sparks; + private readonly List _sparks; - private EmitterSparkPlayer _wheSpark; - private EmitterSparkPlayer _leftSpark; - private EmitterSparkPlayer _rightSpark; + private readonly EmitterSparkPlayer _wheSpark; + private readonly EmitterSparkPlayer _leftSpark; + private readonly EmitterSparkPlayer _rightSpark; private bool _playWormhole; @@ -260,7 +260,7 @@ public override void Stop() Mods.OffCoils = ModState.On; - Particles.Sparks?.StopNonLooped(); + Particles.Sparks?.Stop(); _sparks?.ForEach(x => x?.Stop()); @@ -270,9 +270,9 @@ public override void Stop() _rightSpark.Stop(); - Particles.WheelsFire?.ForEach(x => x?.Stop()); + Particles.WheelsFire?.Stop(); - Particles.WheelsSparks?.ForEach(x => x?.Stop()); + Particles.WheelsSparks?.Stop(); Scaleforms.WormholeRT?.DeleteProp(); } @@ -289,30 +289,16 @@ public override void Tick() if (Properties.IsFueled || Properties.PhotoWormholeActive) HandleSparks(); - if (Mods.WormholeType != WormholeType.BTTF2 && !Properties.IsFlying) - Particles.WheelsFire.ForEach(x => - { - if (!x.IsPlaying) - x.Play(); - - x.Tick(); - }); + if (Mods.WormholeType != WormholeType.BTTF2 && !Properties.IsFlying && !Particles.WheelsFire.IsPlaying) + Particles.WheelsFire.Play(); if (Mods.WormholeType == WormholeType.BTTF3) { - if (!Properties.IsFlying) - Particles.WheelsSparks.ForEach(x => - { - if (!x.IsPlaying) - x.Play(); - - x.Tick(); - }); + if (!Properties.IsFlying && !Particles.WheelsSparks.IsPlaying) + Particles.WheelsSparks.Play(); if (!Particles.Sparks.IsPlaying) Particles.Sparks?.Play(); - - Particles.Sparks?.Tick(); } // Some wormhole sparks logic. diff --git a/BackToTheFutureV/Settings/ModSettings.cs b/BackToTheFutureV/Settings/ModSettings.cs index f794f234..f6c4ab2c 100644 --- a/BackToTheFutureV/Settings/ModSettings.cs +++ b/BackToTheFutureV/Settings/ModSettings.cs @@ -11,7 +11,7 @@ namespace BackToTheFutureV internal class ModSettings { - private static Version LastCompatibleVersion = new Version(2, 0, 0, 0); + private static readonly Version LastCompatibleVersion = new Version(2, 0, 0, 0); public static OnGUIChange OnGUIChange { get; set; } public static PointF RCGUIPosition { get; set; } = new PointF(0.901f, 0.879f); @@ -47,7 +47,7 @@ internal class ModSettings public static bool RealTime { get; set; } = false; private static ScriptSettings settings; - private static CultureInfo info = CultureInfo.CreateSpecificCulture("en-US"); + private static readonly CultureInfo info = CultureInfo.CreateSpecificCulture("en-US"); public static void LoadSettings() { diff --git a/BackToTheFutureV/Story/MissionHandler.cs b/BackToTheFutureV/Story/MissionHandler.cs index a01226a6..702c2be2 100644 --- a/BackToTheFutureV/Story/MissionHandler.cs +++ b/BackToTheFutureV/Story/MissionHandler.cs @@ -5,7 +5,7 @@ namespace BackToTheFutureV { internal static class MissionHandler { - private static List _missions = new List(); + private static readonly List _missions = new List(); public static ClocktowerMission ClocktowerMission = new ClocktowerMission(); diff --git a/BackToTheFutureV/Story/Missions/ClocktowerMission.cs b/BackToTheFutureV/Story/Missions/ClocktowerMission.cs index d835baaa..1b51c24c 100644 --- a/BackToTheFutureV/Story/Missions/ClocktowerMission.cs +++ b/BackToTheFutureV/Story/Missions/ClocktowerMission.cs @@ -5,7 +5,6 @@ using GTA.Native; using KlangRageAudioLibrary; using System; -using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using static BackToTheFutureV.InternalEnums; @@ -32,30 +31,25 @@ internal class ClocktowerMission : Mission private Rope MastRope; private AnimatePropsHandler Lightnings; - private PtfxEntityPlayer Spark; - private List sparkRope = new List(); - private List fireRope = new List(); + private ParticlePlayer Spark; + private readonly ParticlePlayerHandler sparkRope = new ParticlePlayerHandler(); + private readonly ParticlePlayerHandler fireRope = new ParticlePlayerHandler(); private int step = 0; - private int currentIndex = 0; private int gameTime; private TimeMachine CurrentTimeMachine => TimeMachineHandler.CurrentTimeMachine; - private CustomCamera CustomCamera; + private readonly CustomCameraHandler CustomCamera = new CustomCameraHandler(); private AudioPlayer Thunder; public const Hash LightningRunStreet = unchecked((Hash)(-119993883)); - private FrameTimeHelper ptfxHelper = new FrameTimeHelper(60); - private Vector3 checkPos = new Vector3(41.5676f, 6585.7378f, 30.3686f); private bool setup; - //private int startTime; - static ClocktowerMission() { lightningOffset = (lightningOffset * -1).GetSingleOffset(Coordinate.Z, poleModel.Dimensions.frontTopRight.Z); @@ -76,12 +70,11 @@ public override void Abort() public override void KeyDown(KeyEventArgs key) { - //if (key.KeyCode == Keys.L) - // IsPlaying = true; + if (key.KeyCode == Keys.U) + IsPlaying = true; - //if (key.KeyCode == Keys.O) - // FusionUtils.PlayerPed.PositionNoOffset = polePosition; - //FusionUtils.CurrentTime = new DateTime(1955, 11, 12, 22, 3, 0); + if (key.KeyCode == Keys.O) + FusionUtils.CurrentTime = new DateTime(1955, 11, 12, 22, 3, 0); } public override void Tick() @@ -109,7 +102,7 @@ public override void Tick() if (raycastResult.DidHit && raycastResult.HitEntity == CurrentTimeMachine) { - if (CurrentTimeMachine.Mods.Hook == HookState.On && CurrentTimeMachine.Properties.AreTimeCircuitsOn && CurrentTimeMachine.Constants.Over88MphSpeed && !CurrentTimeMachine.Properties.HasBeenStruckByLightning && sparkRope.Count(x => x.IsPlaying) >= 100) + if (CurrentTimeMachine.Mods.Hook == HookState.On && CurrentTimeMachine.Properties.AreTimeCircuitsOn && CurrentTimeMachine.Constants.Over88MphSpeed && !CurrentTimeMachine.Properties.HasBeenStruckByLightning && sparkRope.ParticlePlayers.Count(x => x.IsPlaying) >= 100) { if (ModSettings.WaybackSystem) WaybackSystem.CurrentPlayerRecording.LastRecord.Vehicle.Event |= WaybackVehicleEvent.LightningRun; @@ -126,7 +119,7 @@ public override void Tick() { case 0: if (CurrentTimeMachine.NotNullAndExists() && CurrentTimeMachine.Vehicle.GetMPHSpeed() >= 80) - CustomCamera?.Show(); + CustomCamera?.Show(0); Thunder.SourceEntity = FusionUtils.PlayerPed; Thunder.Play(); @@ -138,82 +131,52 @@ public override void Tick() gameTime = Game.GameTime + 100; break; case 1: - //if (currentIndex == 0) - // startTime = Game.GameTime; - if (Lightnings.IsSequencePlaying) Lightnings.Delete(); if (Spark.IsPlaying) Spark.Stop(); - ptfxHelper.Tick(); - - for (int i = 0; i < ptfxHelper.Count; i++) + if (!sparkRope.IsPlaying) + sparkRope.Play(); + else if (sparkRope.SequenceComplete) { - if (currentIndex == sparkRope.Count) - { - //GTA.UI.Screen.ShowSubtitle($"{Game.GameTime - startTime}"); - - ptfxHelper.Reset(); - - currentIndex = 0; - step++; - gameTime = Game.GameTime + 1000; - break; - } - - sparkRope[currentIndex].Play(); - currentIndex++; + step++; + gameTime = Game.GameTime + 1000; } break; case 2: - sparkRope.ForEach(x => x.StopNaturally()); + sparkRope.Stop(); step++; gameTime = Game.GameTime + 250; break; case 3: - ptfxHelper.Tick(); - for (int i = 0; i < ptfxHelper.Count; i++) + if (!fireRope.IsPlaying) + fireRope.Play(); + else if (fireRope.SequenceComplete) { - if (currentIndex == fireRope.Count) - { - ptfxHelper.Reset(); - - currentIndex = 0; - step++; - gameTime = Game.GameTime + 5000; - break; - } - - if (FusionUtils.Random.NextDouble() >= 0.5f) - fireRope[currentIndex].Play(); - - currentIndex++; + step++; + gameTime = Game.GameTime + 1000; } break; - case 4: - if (currentIndex == fireRope.Count) - { - CustomCamera?.Stop(); + case 4: + fireRope.StopInSequence(); - currentIndex = 0; - step = 0; - IsPlaying = false; + step++; + break; + case 5: + + if (fireRope.IsPlaying) break; - } - fireRope[currentIndex].StopNaturally(); - currentIndex++; - gameTime = Game.GameTime + 20; + IsPlaying = false; + step = 0; break; } - - Spark?.Tick(); } private void Setup() @@ -246,56 +209,56 @@ private void Setup() foreach (CustomModel x in ModelHandler.Lightnings) Lightnings.Add(new AnimateProp(x, Pole, lightningOffset, Vector3.Zero)); - Spark = new PtfxEntityPlayer("core", "ent_brk_sparking_wires_sp", Pole, Vector3.Zero, Vector3.Zero, 8f, true, true, 500); + Spark = new ParticlePlayer("core", "ent_brk_sparking_wires_sp", ParticleType.ForceLooped, Pole, Vector3.Zero, Vector3.Zero, 8f) { Interval = 500 }; - CustomCamera = new CustomCamera(RightStreetPole, new Vector3(11.93889f, 11.07275f, 4.756693f), new Vector3(11.65637f, 10.13232f, 4.56657f), 64); + CustomCamera.Add(RightStreetPole, new Vector3(11.93889f, 11.07275f, 4.756693f), new Vector3(11.65637f, 10.13232f, 4.56657f), 64); Thunder = Main.CommonAudioEngine.Create("general/thunder.wav", Presets.No3D); Vector3 curPos = polePosition; - sparkRope.Add(new PtfxPlayer("scr_reconstructionaccident", "scr_sparking_generator", curPos, Vector3.Zero, 2, true)); + sparkRope.Add("scr_reconstructionaccident", "scr_sparking_generator", ParticleType.Looped, curPos, Vector3.Zero, 2); do { curPos += curPos.GetDirectionTo(leftRope) * 0.25f; - sparkRope.Add(new PtfxPlayer("scr_reconstructionaccident", "scr_sparking_generator", curPos, Vector3.Zero, 2, true)); + sparkRope.Add("scr_reconstructionaccident", "scr_sparking_generator", ParticleType.Looped, curPos, Vector3.Zero, 2); } while (curPos.DistanceTo(leftRope) > 0.1f); do { curPos += curPos.GetDirectionTo(rightRope) * 0.25f; - sparkRope.Add(new PtfxPlayer("scr_reconstructionaccident", "scr_sparking_generator", curPos, Vector3.Zero, 2, true)); + sparkRope.Add("scr_reconstructionaccident", "scr_sparking_generator", ParticleType.Looped, curPos, Vector3.Zero, 2); } while (curPos.DistanceTo(rightRope) > 0.1f); + sparkRope.UseFrameTimeHelper = true; + curPos = polePosition.GetSingleOffset(Coordinate.Z, -0.1f); leftRope = leftRope.GetSingleOffset(Coordinate.Z, -0.1f); rightRope = rightRope.GetSingleOffset(Coordinate.Z, -0.1f); - fireRope.Add(new PtfxPlayer("core", "fire_petroltank_heli", curPos, curPos.GetDirectionTo(leftRope).DirectionToRotation(0), 0.4f, true)); - fireRope.Last().SetEvolutionParam("strength", 1); - fireRope.Last().SetEvolutionParam("dist", 0); - fireRope.Last().SetEvolutionParam("fadein", 0); + fireRope.Add("core", "fire_petroltank_heli", ParticleType.Looped, curPos, curPos.GetDirectionTo(leftRope).DirectionToRotation(0), 0.4f); do { curPos += curPos.GetDirectionTo(leftRope) * 0.5f; - fireRope.Add(new PtfxPlayer("core", "fire_petroltank_heli", curPos, curPos.GetDirectionTo(leftRope).DirectionToRotation(0), 0.4f, true)); - fireRope.Last().SetEvolutionParam("strength", 1); - fireRope.Last().SetEvolutionParam("dist", 0); - fireRope.Last().SetEvolutionParam("fadein", 0); + fireRope.Add("core", "fire_petroltank_heli", ParticleType.Looped, curPos, curPos.GetDirectionTo(leftRope).DirectionToRotation(0), 0.4f); } while (curPos.DistanceTo(leftRope) > 0.1f); do { curPos += curPos.GetDirectionTo(rightRope) * 0.5f; - fireRope.Add(new PtfxPlayer("core", "fire_petroltank_heli", curPos, rightRope.GetDirectionTo(curPos).DirectionToRotation(0), 0.4f, true)); - fireRope.Last().SetEvolutionParam("strength", 1); - fireRope.Last().SetEvolutionParam("dist", 0); - fireRope.Last().SetEvolutionParam("fadein", 0); + fireRope.Add("core", "fire_petroltank_heli", ParticleType.Looped, curPos, rightRope.GetDirectionTo(curPos).DirectionToRotation(0), 0.4f); } while (curPos.DistanceTo(rightRope) > 0.1f); + fireRope.SetEvolutionParam("strength", 1); + fireRope.SetEvolutionParam("dist", 0); + fireRope.SetEvolutionParam("fadein", 0); + + fireRope.UseFrameTimeHelper = true; + fireRope.ChanceOfSpawn = 0.5f; + setup = true; } @@ -310,8 +273,8 @@ protected override void OnEnd() StreetRope?.Delete(); MastRope?.Delete(); - sparkRope?.ForEach(x => x?.Stop()); - fireRope?.ForEach(x => x?.Stop()); + sparkRope?.Stop(); + fireRope?.Stop(); IsPlaying = false; setup = false; diff --git a/BackToTheFutureV/TimeMachineClasses/Clone/TimeMachineCloneHandler.cs b/BackToTheFutureV/TimeMachineClasses/Clone/TimeMachineCloneHandler.cs index 715a59ae..3410a79c 100644 --- a/BackToTheFutureV/TimeMachineClasses/Clone/TimeMachineCloneHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Clone/TimeMachineCloneHandler.cs @@ -23,7 +23,7 @@ public void SpawnAll() x.Spawn(SpawnFlags.CheckExists); } - private static string _saveFile = "./scripts/BackToTheFutureV/TimeMachines.dmc12"; + private static readonly string _saveFile = "./scripts/BackToTheFutureV/TimeMachines.dmc12"; public static void Delete() { diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ConstantsHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ConstantsHandler.cs index 9c77addf..5b2fdbbf 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ConstantsHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ConstantsHandler.cs @@ -166,11 +166,9 @@ public int MaxReactorCharge } } - public int FireTrailsAppearTime => (FireTrailsIs99 || Properties.IsFlying) ? -1 : 0; + public int FireTrailsAppearTime => (FireTrailsIs99 || Properties.IsFlying) ? 0 : 1; - public float FireTrailsDisappearTime => (FireTrailsIs99 || Properties.IsFlying) ? 1 : 15; - - public bool FireTrailsUseBlue => Mods.WormholeType == WormholeType.BTTF1; + public int FireTrailsDisappearTime => (FireTrailsIs99 || Properties.IsFlying) ? 2 : 5; public bool FireTrailsIs99 => Properties.IsFlying && Properties.HasBeenStruckByLightning; diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ModsHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ModsHandler.cs index 6b9250bb..33177d05 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ModsHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ModsHandler.cs @@ -1,5 +1,6 @@ using FusionLibrary; using GTA; +using GTA.Native; using static BackToTheFutureV.InternalEnums; namespace BackToTheFutureV @@ -177,6 +178,8 @@ public void SyncMods() if (WormholeType == WormholeType.BTTF3) TimeMachine.Events?.OnWormholeTypeChanged?.Invoke(); + + Wheels.Burst = true; } else { diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ParticlesHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ParticlesHandler.cs index 651ec2f9..e6a38bc7 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ParticlesHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/ParticlesHandler.cs @@ -1,58 +1,58 @@ using FusionLibrary; using GTA.Math; -using System.Collections.Generic; using System.Windows.Forms; +using static FusionLibrary.FusionEnums; namespace BackToTheFutureV { internal class ParticlesHandler : HandlerPrimitive { //Hover Mode - public List HoverModeSmoke = new List(); + public ParticlePlayerHandler HoverModeSmoke = new ParticlePlayerHandler(); //Ice - public PtfxEntityPlayer IceVentLeftSmoke; - public PtfxEntityPlayer IceVentRightSmoke; - public PtfxEntityPlayer IceSmoke; - public PtfxEntityBonePlayer[] IceWaterDrops; - public PtfxEntityBonePlayer MrFusionSmoke; + public ParticlePlayer IceVentLeftSmoke; + public ParticlePlayer IceVentRightSmoke; + public ParticlePlayer IceSmoke; + public ParticlePlayer[] IceWaterDrops; + public ParticlePlayer MrFusionSmoke; //Time travel - public PtfxEntityPlayer LightExplosion; - public PtfxEntityPlayer TimeTravelEffect; - public List WheelsFire; - public List WheelsSparks; + public ParticlePlayer LightExplosion; + public ParticlePlayer TimeTravelEffect; + public ParticlePlayerHandler WheelsFire; + public ParticlePlayerHandler WheelsSparks; //Reenter - public PtfxEntityPlayer Flash; + public ParticlePlayer Flash; //Sparks - public PtfxEntityBonePlayer LightningSparks; - public PtfxEntityPlayer Sparks; + public ParticlePlayer LightningSparks; + public ParticlePlayer Sparks; public ParticlesHandler(TimeMachine timeMachine) : base(timeMachine) { //Hover Mode foreach (CVehicleWheel wheel in Mods.Wheels) - HoverModeSmoke.Add(new PtfxEntityPlayer("cut_trevor1", "cs_meth_pipe_smoke", Vehicle, wheel.Position, new Vector3(-90, 0, 0), 7f)); + HoverModeSmoke.Add("cut_trevor1", "cs_meth_pipe_smoke", ParticleType.NonLooped, Vehicle, wheel.Position, new Vector3(-90, 0, 0), 7f); - LightExplosion = new PtfxEntityPlayer("scr_josh3", "scr_josh3_light_explosion", Vehicle, Vector3.Zero, Vector3.Zero, 4f); - TimeTravelEffect = new PtfxEntityPlayer("core", "veh_exhaust_spacecraft", Vehicle, new Vector3(0, 4, 0), Vector3.Zero, 8f, true); - Flash = new PtfxEntityPlayer("core", "ent_anim_paparazzi_flash", Vehicle, Vector3.Zero, Vector3.Zero, 50f); - Sparks = new PtfxEntityPlayer("scr_paletoscore", "scr_paleto_box_sparks", Props.InvisibleProp, Vector3.Zero, Vector3.Zero, 1.5f, true, true, 300); - WheelsFire = SetupWheelPTFXs("veh_xs_vehicle_mods", "veh_nitrous", new Vector3(0, -0.25f, -0.15f), new Vector3(0, 0, 0), 1.3f); - WheelsSparks = SetupWheelPTFXs("des_bigjobdrill", "ent_ray_big_drill_start_sparks", new Vector3(0, 0, 0.18f), new Vector3(90f, 0, 0), 1f, true); + LightExplosion = new ParticlePlayer("scr_josh3", "scr_josh3_light_explosion", ParticleType.NonLooped, Vehicle, Vector3.Zero, Vector3.Zero, 4f); + TimeTravelEffect = new ParticlePlayer("core", "veh_exhaust_spacecraft", ParticleType.Looped, Vehicle, new Vector3(0, 4, 0), Vector3.Zero, 8f); + Flash = new ParticlePlayer("core", "ent_anim_paparazzi_flash", ParticleType.NonLooped, Vehicle, Vector3.Zero, Vector3.Zero, 50f); + Sparks = new ParticlePlayer("scr_paletoscore", "scr_paleto_box_sparks", ParticleType.ForceLooped, Props.InvisibleProp, Vector3.Zero, Vector3.Zero, 1.5f) { Interval = 300 }; + WheelsFire = SetupWheelPTFXs("veh_xs_vehicle_mods", "veh_nitrous", ParticleType.Looped, new Vector3(0, -0.25f, -0.15f), new Vector3(0, 0, 0), 1.3f); + WheelsSparks = SetupWheelPTFXs("des_bigjobdrill", "ent_ray_big_drill_start_sparks", ParticleType.ForceLooped, new Vector3(0, 0, 0.18f), new Vector3(90f, 0, 0), 1f); if (!Mods.IsDMC12) return; //Ice - IceVentLeftSmoke = new PtfxEntityPlayer("scr_familyscenem", "scr_meth_pipe_smoke", Vehicle, new Vector3(0.5f, -2f, 0.7f), new Vector3(10f, 0, 180f), 10f, false, false); - IceVentRightSmoke = new PtfxEntityPlayer("scr_familyscenem", "scr_meth_pipe_smoke", Vehicle, new Vector3(-0.5f, -2f, 0.7f), new Vector3(10f, 0, 180f), 10f, false, false); - IceSmoke = new PtfxEntityPlayer("core", "ent_amb_dry_ice_area", Vehicle, new Vector3(0, 0, 0.5f), Vector3.Zero, 3f, true); - MrFusionSmoke = new PtfxEntityBonePlayer("core", "ent_amb_dry_ice_area", Vehicle, "mr_fusion", Vector3.Zero, Vector3.Zero, 0.5f, true); + IceVentLeftSmoke = new ParticlePlayer("scr_familyscenem", "scr_meth_pipe_smoke", ParticleType.NonLooped, Vehicle, new Vector3(0.5f, -2f, 0.7f), new Vector3(10f, 0, 180f), 10f); + IceVentRightSmoke = new ParticlePlayer("scr_familyscenem", "scr_meth_pipe_smoke", ParticleType.NonLooped, Vehicle, new Vector3(-0.5f, -2f, 0.7f), new Vector3(10f, 0, 180f), 10f); + IceSmoke = new ParticlePlayer("core", "ent_amb_dry_ice_area", ParticleType.Looped, Vehicle, new Vector3(0, 0, 0.5f), Vector3.Zero, 3f); + MrFusionSmoke = new ParticlePlayer("core", "ent_amb_dry_ice_area", ParticleType.Looped, Vehicle, "mr_fusion", Vector3.Zero, Vector3.Zero, 0.5f); - IceWaterDrops = new PtfxEntityBonePlayer[3 * 2]; + IceWaterDrops = new ParticlePlayer[3 * 2]; for (int i = 0, c = 0; i < IceWaterDrops.Length / 2; i++) { @@ -61,23 +61,23 @@ public ParticlesHandler(TimeMachine timeMachine) : base(timeMachine) string dummyName = k == 0 ? "ice_drop_left" : "ice_drop_right"; dummyName += i + 1; - IceWaterDrops[c] = new PtfxEntityBonePlayer("scr_apartment_mp", "scr_apa_jacuzzi_drips", Vehicle, dummyName, Vector3.Zero, Vector3.Zero, 3f, true); + IceWaterDrops[c] = new ParticlePlayer("scr_apartment_mp", "scr_apa_jacuzzi_drips", ParticleType.Looped, Vehicle, dummyName, Vector3.Zero, Vector3.Zero, 3f); c++; } } //Sparks - LightningSparks = new PtfxEntityBonePlayer("core", "ent_ray_finale_vault_sparks", Vehicle, "bttf_reactorcap", new Vector3(0, 0, 0.1f), Vector3.Zero, 3, true); + LightningSparks = new ParticlePlayer("core", "ent_ray_finale_vault_sparks", ParticleType.Looped, Vehicle, "bttf_reactorcap", new Vector3(0, 0, 0.1f), Vector3.Zero, 3); } - private List SetupWheelPTFXs(string particleAssetName, string particleName, Vector3 wheelOffset, Vector3 wheelRot, float size = 3f, bool doLoopHandling = false) + private ParticlePlayerHandler SetupWheelPTFXs(string particleAssetName, string particleName, ParticleType particleType, Vector3 wheelOffset, Vector3 wheelRot, float size = 3f) { - List ret = new List(); + ParticlePlayerHandler ret = new ParticlePlayerHandler(); foreach (CVehicleWheel wheel in Mods.Wheels) { wheel.Reset(); - ret.Add(new PtfxEntityPlayer(particleAssetName, particleName, Vehicle, wheel.GetRelativeOffsetPosition(wheelOffset), wheelRot, size, true, doLoopHandling)); + ret.Add(particleAssetName, particleName, particleType, Vehicle, wheel.GetRelativeOffsetPosition(wheelOffset), wheelRot, size); } return ret; @@ -87,8 +87,8 @@ public override void Dispose() { LightExplosion?.Dispose(); TimeTravelEffect?.Dispose(); - WheelsFire?.ForEach(x => x?.Dispose()); - WheelsSparks?.ForEach(x => x?.Dispose()); + WheelsFire?.Dispose(); + WheelsSparks?.Dispose(); } public override void KeyDown(KeyEventArgs e) diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/PropsHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/PropsHandler.cs index eac297d3..e301b463 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/PropsHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/BaseHandlers/PropsHandler.cs @@ -9,7 +9,7 @@ namespace BackToTheFutureV { internal class PropsHandler : HandlerPrimitive { - private AnimateProp BTTFDecals; + private readonly AnimateProp BTTFDecals; //Hover Mode public AnimatePropsHandler HoverModeWheelsGlow; @@ -149,7 +149,7 @@ public PropsHandler(TimeMachine timeMachine) : base(timeMachine) TFCOn = new AnimateProp(ModelHandler.TFCOn, Vehicle); TFCOff = new AnimateProp(ModelHandler.TFCOff, Vehicle); TFCHandle = new AnimateProp(ModelHandler.TFCHandle, Vehicle, new Vector3(-0.03805999f, -0.0819466f, 0.5508024f), Vector3.Zero); - TFCHandle[AnimationType.Rotation][AnimationStep.First][Coordinate.Y].Setup(true, false, -45, 0, 1, 135, 1); + TFCHandle[AnimationType.Rotation][AnimationStep.First][Coordinate.Y].Setup(true, false, -45, 0, 1, 135, 1, false); TFCHandle.SpawnProp(); //TCD @@ -167,7 +167,7 @@ public PropsHandler(TimeMachine timeMachine) : base(timeMachine) //License plate LicensePlate = new AnimateProp(ModelHandler.LicensePlate, Vehicle, Vehicle.GetPositionOffset(Vehicle.RearPosition).GetSingleOffset(Coordinate.Z, 0.0275f), new Vector3(30, -90, 90)); - LicensePlate[AnimationType.Rotation][AnimationStep.First][Coordinate.Z].Setup(true, true, 90, 360 * 2 + 90, 1, 1440, 1); + LicensePlate[AnimationType.Rotation][AnimationStep.First][Coordinate.Z].Setup(true, true, 90, 360 * 2 + 90, 1, 1440, 1, false); LicensePlate.SaveAnimation(); //Bulova clock @@ -177,7 +177,7 @@ public PropsHandler(TimeMachine timeMachine) : base(timeMachine) BulovaClockMinute = new AnimateProp(ModelHandler.BulovaClockMinute, Vehicle, "bulova_clock_ring_hands"); BulovaClockMinute.SpawnProp(); BulovaClockRing = new AnimateProp(ModelHandler.BulovaClockRing, Vehicle, "bulova_clock"); - BulovaClockRing[AnimationType.Rotation][AnimationStep.First][Coordinate.Y].Setup(false, true, -10, 10, 1, 360, 1); + BulovaClockRing[AnimationType.Rotation][AnimationStep.First][Coordinate.Y].Setup(false, true, -10, 10, 1, 360, 1, false); BulovaClockRing.SpawnProp(); } diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/ClockHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/ClockHandler.cs index b391cc98..ea45be20 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/ClockHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/ClockHandler.cs @@ -78,7 +78,7 @@ public override void KeyDown(KeyEventArgs e) public override void Tick() { - if (Properties.AlarmSet && FusionUtils.CurrentTime.Between(new DateTime(1955, 11, 12, 21, 30, 00), new DateTime(1955, 11, 12, 22, 3, 45)) && Properties.AlarmTime.Between(new DateTime(1955, 11, 12, 21, 30, 00), new DateTime(1955, 11, 12, 22, 3, 45)) && Vehicle.GetStreetHash() == ClocktowerMission.LightningRunStreet && !Properties.IsEngineStalling && Vehicle.GetMPHSpeed() == 0 && FusionUtils.Random.NextDouble() > 0.3f) + if (Properties.AlarmSet && FusionUtils.CurrentTime.Between(new DateTime(1955, 11, 12, 21, 30, 00), new DateTime(1955, 11, 12, 22, 3, 50)) && Properties.AlarmTime.Between(new DateTime(1955, 11, 12, 21, 30, 00), new DateTime(1955, 11, 12, 22, 3, 50)) && Vehicle.GetStreetInfo().Street == ClocktowerMission.LightningRunStreet && !Properties.IsEngineStalling && Vehicle.GetMPHSpeed() == 0 && FusionUtils.Random.NextDouble() > 0.3f) Events.SetEngineStall?.Invoke(true); if (Properties.SyncWithCurTime) diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/FluxCapacitorHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/FluxCapacitorHandler.cs index 4649aa01..45673efe 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/FluxCapacitorHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/FluxCapacitorHandler.cs @@ -9,7 +9,7 @@ namespace BackToTheFutureV { internal class FluxCapacitorHandler : HandlerPrimitive { - private LightHandler FluxBlueLight; + private readonly LightHandler FluxBlueLight; public FluxCapacitorHandler(TimeMachine timeMachine) : base(timeMachine) { diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/FlyingHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/FlyingHandler.cs index 8cd34d41..3923a5a5 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/FlyingHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/FlyingHandler.cs @@ -28,14 +28,14 @@ internal class FlyingHandler : HandlerPrimitive private bool _reload; - private Hash _defaultHorn; + private readonly Hash _defaultHorn; public FlyingHandler(TimeMachine timeMachine) : base(timeMachine) { if (Mods.HoverUnderbody == ModState.On) OnHoverUnderbodyToggle(); - _defaultHorn = Function.Call(Hash._GET_VEHICLE_HORN_HASH, Vehicle); + _defaultHorn = Function.Call(Hash.GET_VEHICLE_DEFAULT_HORN, Vehicle); _flyModeInput = new NativeInput(ModControls.Hover); _flyModeInput.OnControlLongPressed += OnFlyModeControlJustLongPressed; @@ -205,18 +205,15 @@ public void SetFlyMode(bool open, bool instant = false) else Players.HoverModeWheels?.Play(open); - // undocced native, changes delxuo transformation - // from land to hover - // (DOES NOT CHANGE FLY MODE!) if (!Properties.IsLanding) - Function.Call((Hash)0x438b3d7ca026fe91, Vehicle, Properties.IsFlying ? 1f : 0f); + Function.Call(Hash._SET_VEHICLE_HOVER_TRANSFORM_PERCENTAGE, Vehicle, Properties.IsFlying ? 1f : 0f); else TextHandler.ShowHelp("VTOLTip", true, new ControlInfo(ModControls.HoverVTOL).Button); if (Properties.IsFlying && !instant) { Sounds.HoverModeOn?.Play(); - Particles?.HoverModeSmoke?.ForEach(x => x?.Play()); + Particles?.HoverModeSmoke?.Play(); } else if (!Properties.IsFlying && !instant) { @@ -298,7 +295,7 @@ public override void Tick() if (Vehicle.HeightAboveGround < 2 && !_landingSmoke) { - Particles?.HoverModeSmoke?.ForEach(x => x?.Play()); + Particles?.HoverModeSmoke?.Play(); _landingSmoke = true; } diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/FreezeHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/FreezeHandler.cs index 4ec655ea..99856214 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/FreezeHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/FreezeHandler.cs @@ -18,7 +18,7 @@ internal class FreezeHandler : HandlerPrimitive private float _smokeIndex; private float _iceDisappearVal; - private float _timeToDisappear = 180f; // 360 = 6 minutes + private readonly float _timeToDisappear = 180f; // 360 = 6 minutes private bool _resuming; @@ -85,10 +85,10 @@ public override void Tick() if (newIce <= 0.15f) { - Particles?.IceSmoke?.StopNaturally(); + Particles?.IceSmoke?.Stop(); - foreach (PtfxEntityBonePlayer waterDrop in Particles?.IceWaterDrops) - waterDrop?.StopNaturally(); + foreach (ParticlePlayer waterDrop in Particles?.IceWaterDrops) + waterDrop?.Stop(); Sounds.Ice?.Stop(); Properties.IsDefrosting = false; @@ -121,7 +121,7 @@ public override void Tick() // Spawn the ice particles Particles?.IceSmoke?.Play(); - foreach (PtfxEntityBonePlayer waterDrop in Particles?.IceWaterDrops) + foreach (ParticlePlayer waterDrop in Particles?.IceWaterDrops) { UpdateDoorIce(waterDrop.BoneName.Contains("left") ? VehicleDoorIndex.FrontLeftDoor @@ -176,7 +176,7 @@ public override void Tick() break; } } - private void UpdateDoorIce(VehicleDoorIndex doorIndex, PtfxEntityBonePlayer waterDrop) + private void UpdateDoorIce(VehicleDoorIndex doorIndex, ParticlePlayer waterDrop) { if (waterDrop.IsPlaying) return; @@ -199,10 +199,10 @@ public override void Stop() Sounds.Ice?.Stop(!Vehicle.IsVisible); Sounds.IceVents?.Stop(!Vehicle.IsVisible); - foreach (PtfxEntityBonePlayer waterDrop in Particles?.IceWaterDrops) - waterDrop.StopNaturally(); + foreach (ParticlePlayer waterDrop in Particles?.IceWaterDrops) + waterDrop.Stop(); - Particles?.IceSmoke?.StopNaturally(); + Particles?.IceSmoke?.Stop(); } public override void Dispose() diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/FuelHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/FuelHandler.cs index 00133bc1..862d7c53 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/FuelHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/FuelHandler.cs @@ -20,7 +20,7 @@ internal class FuelHandler : HandlerPrimitive private float _reactorGlowingTime = 0; private float _refuelTime = 0; - private NativeInput InteractPressed; + private readonly NativeInput InteractPressed; private TaskSequence refuelSequence; diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/RCHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/RCHandler.cs index 2c09cd03..4b1a270c 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/RCHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/RCHandler.cs @@ -17,7 +17,7 @@ internal class RcHandler : HandlerPrimitive private Camera _camera; private Blip _blip; - private NativeInput rcHandbrake; + private readonly NativeInput rcHandbrake; private bool _forcedHandbrake = false; private bool _boostStarted = false; diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/RailroadHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/RailroadHandler.cs index 1a57035f..f18ffa81 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/RailroadHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/RailroadHandler.cs @@ -138,6 +138,7 @@ private void customTrain_OnVehicleAttached() customTrain.IsAutomaticBrakeOn = true; Properties.IsOnTracks = true; + Mods.Wheels.Burst = false; if (_isReentryOn) { @@ -214,7 +215,7 @@ public override void Tick() if (_attachDelay < Game.GameTime && Mods.Wheel == WheelType.RailroadInvisible && !Properties.IsFlying) { - if (FusionUtils.GetWheelsPositions(Vehicle).TrueForAll(x => FusionUtils.IsWheelOnTracks(x, Vehicle))) + if (Vehicle.IsOnTracks()) { customTrain?.DeleteTrain(); Start(TimeMachine.Properties.TimeTravelPhase == TimeTravelPhase.Reentering); @@ -231,6 +232,7 @@ public void Stop(int delay = 0) { _isReentryOn = false; Properties.IsOnTracks = false; + Mods.Wheels.Burst = true; if (delay > 0) _attachDelay = Game.GameTime + delay; diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/StarterHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/StarterHandler.cs index 26831ec8..f47af733 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/StarterHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/StarterHandler.cs @@ -14,14 +14,14 @@ internal class StarterHandler : HandlerPrimitive private int _restartAt; private int _nextCheck; - private TimedEventHandler timedEventManager; + private readonly TimedEventHandler timedEventManager; private bool _lightsOn; private bool _highbeamsOn; private float _lightsBrightness; - private int _deloreanMaxFuelLevel = 65; + private readonly int _deloreanMaxFuelLevel = 65; public StarterHandler(TimeMachine timeMachine) : base(timeMachine) { diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/TCD3DRowHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/TCD3DRowHandler.cs index 6775555b..b4478a3f 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/TCD3DRowHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/TCD3DRowHandler.cs @@ -11,7 +11,7 @@ namespace BackToTheFutureV { internal class TCD3DRowHandler : HandlerPrimitive { - private static Dictionary offsets = new Dictionary() + private static readonly Dictionary offsets = new Dictionary() { { "red", new Vector3(-0.01477456f, 0.3175744f, 0.6455771f) }, { "yellow", new Vector3(-0.01964803f, 0.2769623f, 0.565388f) }, @@ -28,8 +28,8 @@ internal class TCD3DRowHandler : HandlerPrimitive private int showPropsAt; private int showMonthAt; - private AnimateProp amProp; - private AnimateProp pmProp; + private readonly AnimateProp amProp; + private readonly AnimateProp pmProp; public TCD3DRowHandler(string slotType, TimeMachine timeMachine) : base(timeMachine) { diff --git a/BackToTheFutureV/TimeMachineClasses/Handlers/TCDHandler.cs b/BackToTheFutureV/TimeMachineClasses/Handlers/TCDHandler.cs index 58d57c8a..2f15e25b 100644 --- a/BackToTheFutureV/TimeMachineClasses/Handlers/TCDHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/Handlers/TCDHandler.cs @@ -10,7 +10,7 @@ namespace BackToTheFutureV { internal class TCDHandler : HandlerPrimitive { - private static DateTime errorDate = new DateTime(1885, 1, 1, 0, 0, 0); + private static readonly DateTime errorDate = new DateTime(1885, 1, 1, 0, 0, 0); private static readonly Dictionary _probabilities = new Dictionary() { @@ -42,14 +42,14 @@ internal class TCDHandler : HandlerPrimitive private int nextCheckGlitch; - private TimedEventHandler glitchEvents = new TimedEventHandler(); + private readonly TimedEventHandler glitchEvents = new TimedEventHandler(); private bool softGlitch; private bool doGlitch; - private TCD3DRowHandler destinationSlot; - private TCD3DRowHandler presentSlot; - private TCD3DRowHandler previousSlot; + private readonly TCD3DRowHandler destinationSlot; + private readonly TCD3DRowHandler presentSlot; + private readonly TCD3DRowHandler previousSlot; private bool currentState; diff --git a/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachine.cs b/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachine.cs index cfedd638..7328c5bc 100644 --- a/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachine.cs +++ b/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachine.cs @@ -18,7 +18,7 @@ internal class RemoteTimeMachine private int _timer; private bool _hasPlayedWarningSound; - private static AudioPlayer WarningSound; + private static readonly AudioPlayer WarningSound; static RemoteTimeMachine() { diff --git a/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachineHandler.cs b/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachineHandler.cs index ecfcee01..26025670 100644 --- a/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachineHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/RC/RemoteTimeMachineHandler.cs @@ -16,7 +16,7 @@ internal class RemoteTimeMachineHandler public static bool IsRemoteOn => RemoteControlling != null; private static TimerBarCollection TimerBarCollection { get; } - private static TimerBarProgress SignalBar; + private static readonly TimerBarProgress SignalBar; public static List RemoteTimeMachines { get; private set; } = new List(); public static int RemoteTimeMachineCount => RemoteTimeMachines.Count; @@ -123,7 +123,7 @@ public static void DeleteAll() File.Delete(_saveFile); } - private static string _saveFile = "./scripts/BackToTheFutureV/RemoteTimeMachines.dmc12"; + private static readonly string _saveFile = "./scripts/BackToTheFutureV/RemoteTimeMachines.dmc12"; public static void Save() { diff --git a/BackToTheFutureV/TimeMachineClasses/TimeMachine.cs b/BackToTheFutureV/TimeMachineClasses/TimeMachine.cs index c152138d..e1ba7911 100644 --- a/BackToTheFutureV/TimeMachineClasses/TimeMachine.cs +++ b/BackToTheFutureV/TimeMachineClasses/TimeMachine.cs @@ -42,8 +42,8 @@ public TimeMachineCamera CustomCamera private readonly Dictionary registeredHandlers = new Dictionary(); - private VehicleBone boneLf; - private VehicleBone boneRf; + private readonly VehicleBone boneLf; + private readonly VehicleBone boneRf; private Vector3 leftSuspesionOffset; private Vector3 rightSuspesionOffset; @@ -70,7 +70,7 @@ public TimeMachine(Vehicle vehicle, WormholeType wormholeType) Vehicle.IsPersistent = true; - Vehicle.Decorator().DotNotDelete = true; + Vehicle.Decorator().DoNotDelete = true; TimeMachineHandler.AddTimeMachine(this); @@ -244,7 +244,7 @@ public void Tick() if (Properties.IsWayback && TimeMachineHandler.CurrentTimeMachine == this) Properties.IsWayback = false; - Function.Call(Hash._SET_VEHICLE_ENGINE_TORQUE_MULTIPLIER, Vehicle, Decorators.TorqueMultiplier); + Function.Call(Hash.SET_VEHICLE_CHEAT_POWER_INCREASE, Vehicle, Decorators.TorqueMultiplier); if (Mods.HoverUnderbody == ModState.Off && Mods.IsDMC12) VehicleControl.SetDeluxoTransformation(Vehicle, 0f); @@ -256,20 +256,6 @@ public void Tick() Vehicle.IsRadioEnabled = false; - if (Mods.Wheel == WheelType.RailroadInvisible) - { - if (Properties.IsOnTracks) - { - if (Mods.Wheels.Burst) - Mods.Wheels.Burst = false; - } - else - { - if (!Mods.Wheels.Burst) - Mods.Wheels.Burst = true; - } - } - if (Mods.IsDMC12) { //In certain situations car can't be entered after hover transformation, here is forced enter task. @@ -307,38 +293,38 @@ public void Tick() switch (Mods.SuspensionsType) { case SuspensionsType.LiftFrontLowerRear: - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, -0.25f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, -0.25f); break; case SuspensionsType.LiftFront: - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, 0.75f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, 0.50f); break; case SuspensionsType.LiftRear: - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, 0.75f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, 0.50f); break; case SuspensionsType.LiftFrontAndRear: - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, 0.75f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, 0.75f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, 0.50f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, 0.50f); break; case SuspensionsType.LowerFront: - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, -0.25f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, -0.25f); break; case SuspensionsType.LowerRear: - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, -0.25f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, -0.25f); break; case SuspensionsType.LowerFrontAndRear: - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, -0.25f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, -0.25f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, -0.25f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, -0.25f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, -0.25f); break; } diff --git a/BackToTheFutureV/TimeMachineClasses/TimeMachineHandler.cs b/BackToTheFutureV/TimeMachineClasses/TimeMachineHandler.cs index b207b28f..93958b13 100644 --- a/BackToTheFutureV/TimeMachineClasses/TimeMachineHandler.cs +++ b/BackToTheFutureV/TimeMachineClasses/TimeMachineHandler.cs @@ -22,9 +22,9 @@ internal class TimeMachineHandler private static List AllTimeMachines { get; } = new List(); public static List TimeMachines => AllTimeMachines.Except(StoryTimeMachines).ToList(); - private static List _timeMachinesToAdd = new List(); - private static Dictionary _timeMachinesToRemove = new Dictionary(); - private static Dictionary _timeMachinesToRemoveWaitSounds = new Dictionary(); + private static readonly List _timeMachinesToAdd = new List(); + private static readonly Dictionary _timeMachinesToRemove = new Dictionary(); + private static readonly Dictionary _timeMachinesToRemoveWaitSounds = new Dictionary(); public static int TimeMachineCount => TimeMachines.Count(); diff --git a/BackToTheFutureV/Utility/GarageHandler.cs b/BackToTheFutureV/Utility/GarageHandler.cs index 48fdcdbf..44aecbc8 100644 --- a/BackToTheFutureV/Utility/GarageHandler.cs +++ b/BackToTheFutureV/Utility/GarageHandler.cs @@ -128,7 +128,7 @@ internal static class GarageHandler public static GarageStatus Status { get; private set; } = GarageStatus.Idle; - private static AudioPlayer garageSound = Main.CommonAudioEngine.Create("story/garage.wav", Presets.No3D); + private static readonly AudioPlayer garageSound = Main.CommonAudioEngine.Create("story/garage.wav", Presets.No3D); private static bool isTimeMachine; @@ -237,7 +237,7 @@ public static void Tick() Function.Call(Hash.SET_VEHICLE_ENGINE_ON, Vehicle, false, false, true); //SetupCamera(garageInfo.CreateInsideCamera()); - MenuHandler.GarageMenu.Open(); + MenuHandler.GarageMenu.Visible = true; garageInfo.Lock(); Status = GarageStatus.Busy; @@ -249,7 +249,7 @@ public static void Tick() break; FusionUtils.HideGUI = false; - TimeMachineHandler.CurrentTimeMachine?.Particles.IceSmoke?.StopNaturally(); + TimeMachineHandler.CurrentTimeMachine?.Particles.IceSmoke?.Stop(); DestroyCamera(); Status = GarageStatus.Idle; diff --git a/BackToTheFutureV/Utility/InternalInventory.cs b/BackToTheFutureV/Utility/InternalInventory.cs index 2cef044e..187bb5b4 100644 --- a/BackToTheFutureV/Utility/InternalInventory.cs +++ b/BackToTheFutureV/Utility/InternalInventory.cs @@ -7,7 +7,7 @@ namespace BackToTheFutureV { internal class InternalInventory { - private static List InternalInventories = new List(); + private static readonly List InternalInventories = new List(); public static InternalInventory Current => InternalInventories.DefaultIfEmpty(new InternalInventory()).SingleOrDefault(x => x.Ped == FusionUtils.PlayerPed.Model); public Model Ped { get; } diff --git a/BackToTheFutureV/Utility/ModelHandler.cs b/BackToTheFutureV/Utility/ModelHandler.cs index fa1ee3f3..ae9e9661 100644 --- a/BackToTheFutureV/Utility/ModelHandler.cs +++ b/BackToTheFutureV/Utility/ModelHandler.cs @@ -99,7 +99,7 @@ internal class ModelHandler : CustomModelHandler public static CustomModel DeluxoModel = new CustomModel("deluxo"); - private static string[] tcdTypes = new string[3] + private static readonly string[] tcdTypes = new string[3] { "red", "green", @@ -127,7 +127,7 @@ public static void RequestModels() for (int i = 1; i <= 11; i++) CoilSeparated.Add(new CustomModel($"bttf3_coils_glowing_{i}")); - GetAllModels(typeof(ModelHandler)).ForEach(x => PreloadModel(x)); + GetAllModels(typeof(ModelHandler)).ForEach(x => x.Request()); } } } diff --git a/BackToTheFutureV/Utility/TextHandler.cs b/BackToTheFutureV/Utility/TextHandler.cs index a269725d..47e99ee5 100644 --- a/BackToTheFutureV/Utility/TextHandler.cs +++ b/BackToTheFutureV/Utility/TextHandler.cs @@ -4,7 +4,7 @@ namespace BackToTheFutureV { public static class TextHandler { - private static CustomText CustomText = new CustomText("BTTFV_Text_{0}"); + private static readonly CustomText CustomText = new CustomText("BTTFV_Text_{0}"); public static string GetLocalizedText(string entry) { diff --git a/BackToTheFutureV/Utility/Wayback/WaybackSystem.cs b/BackToTheFutureV/Utility/Wayback/WaybackSystem.cs index 063a17a3..bc31708f 100644 --- a/BackToTheFutureV/Utility/Wayback/WaybackSystem.cs +++ b/BackToTheFutureV/Utility/Wayback/WaybackSystem.cs @@ -9,7 +9,7 @@ namespace BackToTheFutureV { internal class WaybackSystem { - private static List Machines = new List(); + private static readonly List Machines = new List(); public static WaybackMachine CurrentPlayerRecording => Machines.SingleOrDefault(x => x.Status == WaybackStatus.Recording && x.IsPlayer); diff --git a/BackToTheFutureV/Vehicles/DMC12/DMC12.cs b/BackToTheFutureV/Vehicles/DMC12/DMC12.cs index f4c6a826..ca00fe03 100644 --- a/BackToTheFutureV/Vehicles/DMC12/DMC12.cs +++ b/BackToTheFutureV/Vehicles/DMC12/DMC12.cs @@ -18,20 +18,20 @@ internal class DMC12 public bool Disposed { get; private set; } - private AnimateProp rpmNeedle; - private AnimateProp speedNeedle; - private AnimateProp fuelNeedle; - private AnimateProp tempNeedle; - private AnimateProp oilNeedle; - private AnimateProp voltNeedle; - private AnimateProp doorIndicator; - private AnimateProp leftFan; - private AnimateProp rightFan; - - private AnimateProp suspensionLeftFront; - private AnimateProp suspensionLeftRear; - private AnimateProp suspensionRightFront; - private AnimateProp suspensionRightRear; + private readonly AnimateProp rpmNeedle; + private readonly AnimateProp speedNeedle; + private readonly AnimateProp fuelNeedle; + private readonly AnimateProp tempNeedle; + private readonly AnimateProp oilNeedle; + private readonly AnimateProp voltNeedle; + private readonly AnimateProp doorIndicator; + private readonly AnimateProp leftFan; + private readonly AnimateProp rightFan; + + private readonly AnimateProp suspensionLeftFront; + private readonly AnimateProp suspensionLeftRear; + private readonly AnimateProp suspensionRightFront; + private readonly AnimateProp suspensionRightRear; private float voltLevel = 50f; @@ -57,7 +57,7 @@ public DMC12(Vehicle vehicle) Vehicle.IsPersistent = true; - Vehicle.Decorator().DotNotDelete = true; + Vehicle.Decorator().DoNotDelete = true; Mods = new DMC12Mods(Vehicle); @@ -209,7 +209,7 @@ public void Tick() suspensionRightRear?.Delete(); } - if (FusionUtils.IsAnyDoorOpen(Vehicle)) + if (Vehicle.IsAnyDoorOpen()) doorIndicator.SpawnProp(); else doorIndicator.Delete(); diff --git a/BackToTheFutureV/Vehicles/DMC12/DMC12Handler.cs b/BackToTheFutureV/Vehicles/DMC12/DMC12Handler.cs index fbef33ab..8004dce7 100644 --- a/BackToTheFutureV/Vehicles/DMC12/DMC12Handler.cs +++ b/BackToTheFutureV/Vehicles/DMC12/DMC12Handler.cs @@ -11,9 +11,9 @@ namespace BackToTheFutureV { internal class DMC12Handler { - private static List _deloreans = new List(); - private static List _deloreansToAdd = new List(); - private static Dictionary _deloreansToRemove = new Dictionary(); + private static readonly List _deloreans = new List(); + private static readonly List _deloreansToAdd = new List(); + private static readonly Dictionary _deloreansToRemove = new Dictionary(); public static void Abort() { diff --git a/BackToTheFutureV/Vehicles/DMC12/DMC12Mods.cs b/BackToTheFutureV/Vehicles/DMC12/DMC12Mods.cs index 9a19ee5a..018f28c5 100644 --- a/BackToTheFutureV/Vehicles/DMC12/DMC12Mods.cs +++ b/BackToTheFutureV/Vehicles/DMC12/DMC12Mods.cs @@ -1,8 +1,8 @@ using FusionLibrary; +using FusionLibrary.Extensions; using GTA; using GTA.Native; using static BackToTheFutureV.InternalEnums; -using static FusionLibrary.FusionEnums; namespace BackToTheFutureV { @@ -20,6 +20,8 @@ public DMC12Mods(Vehicle vehicle) if (IsDMC12) { + Function.Call(Hash._SET_HYDRAULIC_RAISED, Vehicle, false); + Vehicle.ToggleExtra(10, true); Vehicle.Mods.PrimaryColor = VehicleColor.BrushedAluminium; @@ -82,22 +84,20 @@ public DMC12Mods(Vehicle vehicle) switch (value) { case SuspensionsType.Stock: - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, 0f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, 0f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, 0f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, 0f); - Function.Call((Hash)0x1201E8A3290A3B98, Vehicle, false); - Function.Call((Hash)0x28B18377EB6E25F6, Vehicle, false); + Function.Call(Hash._SET_CAMBERED_WHEELS_DISABLED, Vehicle, false); break; default: - Function.Call((Hash)0x1201E8A3290A3B98, Vehicle, true); - Function.Call((Hash)0x28B18377EB6E25F6, Vehicle, true); - - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontLeft, 0f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.FrontRight, 0f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearLeft, 0f); - FusionUtils.LiftUpWheel(Vehicle, WheelId.RearRight, 0f); + Function.Call(Hash._SET_CAMBERED_WHEELS_DISABLED, Vehicle, true); + + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftFront, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightFront, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelLeftRear, 0f); + Vehicle.LiftUpWheel(VehicleWheelBoneId.WheelRightRear, 0f); break; } } diff --git a/BackToTheFutureV/Vehicles/Train/CustomTrain.cs b/BackToTheFutureV/Vehicles/Train/CustomTrain.cs index dce9ba7c..a5e3cd81 100644 --- a/BackToTheFutureV/Vehicles/Train/CustomTrain.cs +++ b/BackToTheFutureV/Vehicles/Train/CustomTrain.cs @@ -23,7 +23,7 @@ internal class CustomTrain public Vector3 Position { get => Train.Position; set => Function.Call(Hash.SET_MISSION_TRAIN_COORDS, Train, value.X, value.Y, value.Z); } public int CarriageCount { get; } - private int _variation; + private readonly int _variation; private float _cruiseSpeed; private bool _setSpeed; private float _speed; @@ -64,12 +64,12 @@ public CustomTrain(Vector3 position, bool direction, int variation, int carriage Train.IsPersistent = true; - Train.Decorator().DotNotDelete = true; + Train.Decorator().DoNotDelete = true; for (int i = 0; i <= CarriageCount; i++) { Carriage(i).IsPersistent = true; - Carriage(i).Decorator().DotNotDelete = true; + Carriage(i).Decorator().DoNotDelete = true; } ToDestroy = false; diff --git a/BackToTheFutureV/Vehicles/Train/CustomTrainHandler.cs b/BackToTheFutureV/Vehicles/Train/CustomTrainHandler.cs index 19afc980..abd3ab66 100644 --- a/BackToTheFutureV/Vehicles/Train/CustomTrainHandler.cs +++ b/BackToTheFutureV/Vehicles/Train/CustomTrainHandler.cs @@ -7,8 +7,8 @@ namespace BackToTheFutureV { internal static class CustomTrainHandler { - private static List trainHandlers = new List(); - private static List trainHandlersToRemove = new List(); + private static readonly List trainHandlers = new List(); + private static readonly List trainHandlersToRemove = new List(); public static CustomTrain CreateFreightTrain(Vehicle vehicle, bool direction) { @@ -21,7 +21,7 @@ public static CustomTrain CreateFreightTrain(Vehicle vehicle, bool direction) public static CustomTrain CreateInvisibleTrain(Vehicle vehicle, bool direction) { - trainHandlers.Add(new CustomTrain(vehicle.GetOffsetPosition(new Vector3(0, -10, 0)), direction, 25, 1)); + trainHandlers.Add(new CustomTrain(vehicle.GetOffsetPosition(new Vector3(0, -10, 0)), direction, 27, 1)); trainHandlers.Last().SetCollision(false); diff --git a/BackToTheFutureV/packages.config b/BackToTheFutureV/packages.config new file mode 100644 index 00000000..3299dfcf --- /dev/null +++ b/BackToTheFutureV/packages.config @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/FusionLibrary b/FusionLibrary deleted file mode 160000 index 48ca6f2e..00000000 --- a/FusionLibrary +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 48ca6f2ef0ecbbf163a6663e69fa7e57506b5a44 diff --git a/KlangRageAudioLibrary b/KlangRageAudioLibrary deleted file mode 160000 index 66cf3f12..00000000 --- a/KlangRageAudioLibrary +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 66cf3f1242282984addbe0dc1745d6b485b0f587