diff --git a/.gitignore b/.gitignore index d9b2f189d..9eea7d01c 100644 --- a/.gitignore +++ b/.gitignore @@ -384,7 +384,6 @@ VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/UserSettings/ VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/VisualPinball.Engine.csproj VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/VisualPinball.Engine.Test.csproj VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/VisualPinball.Unity.Editor.csproj -VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/VisualPinball.Unity.Patcher.csproj VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/VisualPinball.Unity.Test.csproj VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/VisualPinball.Unity.csproj VisualPinball.Unity/VisualPinball.Unity.Test/TestProject~/editmode-results.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fd2a6060..53c311fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,10 @@ Built with Unity 6.5 - Move render pipelines into separate repos ([#259](https://github.com/freezy/VisualPinball.Engine/pull/259)). - Put game-, mesh-, collision- animation data into separate components ([#227](https://github.com/freezy/VisualPinball.Engine/pull/227), [Documentation](https://docs.visualpinball.org/creators-guide/editor/unity-components.html)). +### Removed + +- The legacy VPX table patcher and its import option, including `IPatcher`, `PatcherManager`, the render-pipeline material-adapter APIs, and the `applyPatch` import parameters. + ### Fixed - Disappearing objects due to wrong bounding box ([#441](https://github.com/freezy/VisualPinball.Engine/pull/441)). - Default table import ([#434](https://github.com/freezy/VisualPinball.Engine/pull/434)) diff --git a/VisualPinball.Unity/Documentation~/creators-guide/introduction/features.md b/VisualPinball.Unity/Documentation~/creators-guide/introduction/features.md index 9cf4d23b8..5501ac76d 100644 --- a/VisualPinball.Unity/Documentation~/creators-guide/introduction/features.md +++ b/VisualPinball.Unity/Documentation~/creators-guide/introduction/features.md @@ -79,12 +79,6 @@ Lastly, we can visualize the colliders of any object. This can be useful to debu ![Colliders](unity-colliders.jpg) -## Patching System - -There are common patterns for VPX tables that are obsolete in VPE. For instance, VPE doesn't need a flipper shadow mesh, because it can do dynamic lighting out of the box. For that reason, we have a simple but sophisticated patcher system that allows us to apply changes to a table when imported. - -Of course the changes don't apply to the table data itself but to how we convert it into the Unity scene. You can read more about it [here](https://github.com/freezy/VisualPinball.Engine/tree/master/VisualPinball.Unity/VisualPinball.Unity.Patcher#unity-patching-system). - ## Display Support VPE provides high-quality rendering of dot matrix and segment displays. Displays can be placed anywhere in the scene, multiple at once, and are easily linked to the game logic engine. For DMDs, dot size, shape and color can be customized, and for segment displays it's the segment weight, skew angle and color. \ No newline at end of file diff --git a/VisualPinball.Unity/Documentation~/creators-guide/setup/installing-vpe.md b/VisualPinball.Unity/Documentation~/creators-guide/setup/installing-vpe.md index d27ddac26..d109345a0 100644 --- a/VisualPinball.Unity/Documentation~/creators-guide/setup/installing-vpe.md +++ b/VisualPinball.Unity/Documentation~/creators-guide/setup/installing-vpe.md @@ -67,9 +67,6 @@ Open the package manager by clicking on *Window -> Package Management -> Package There, enter `org.visualpinball.engine.unity.hdrp` and click *Install*. This will take a moment as Unity downloads and compiles all of VPE's dependencies and parses all the assets that we ship in our library. -> [!WARNING] -> Our patcher, which is currently part of the main package, depends on the PinMAME package. Until we move the patcher into a separate package, you will have to install the PinMAME package as well. To do that, click on the plus button again and enter `org.visualpinball.engine.pinmame`, then click on *Add*. - When complete, you should now have a *Pinball* menu in the editor, and you should see the following new packages in the package manager (version numbers will vary):

Unity Input System Warning

diff --git a/VisualPinball.Unity/VisualPinball.Engine.Unity.sln b/VisualPinball.Unity/VisualPinball.Engine.Unity.sln index b56a586ff..810941a99 100644 --- a/VisualPinball.Unity/VisualPinball.Engine.Unity.sln +++ b/VisualPinball.Unity/VisualPinball.Engine.Unity.sln @@ -6,8 +6,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualPinball.Resources", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualPinball.Unity.Test", "VisualPinball.Unity.Test\VisualPinball.Unity.Test.csproj", "{B94E5F7B-C579-4C06-9242-B9A95529DE87}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualPinball.Unity.Patcher", "VisualPinball.Unity.Patcher\VisualPinball.Unity.Patcher.csproj", "{5134A0F7-387C-44AC-9850-55B0D6B564ED}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualPinball.Unity.Editor", "VisualPinball.Unity.Editor\VisualPinball.Unity.Editor.csproj", "{1B54F9E3-119E-4148-8C47-EB7E2C1E562E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualPinball.Engine.Test", "..\VisualPinball.Engine.Test\VisualPinball.Engine.Test.csproj", "{4CAA8C3D-7D51-4AF6-838C-10BC0C855AF8}" @@ -80,18 +78,6 @@ Global {B94E5F7B-C579-4C06-9242-B9A95529DE87}.Release|x86.Build.0 = Release|Any CPU {B94E5F7B-C579-4C06-9242-B9A95529DE87}.Release|Any CPU.ActiveCfg = Release|Any CPU {B94E5F7B-C579-4C06-9242-B9A95529DE87}.Release|Any CPU.Build.0 = Release|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Debug|x64.ActiveCfg = Debug|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Debug|x64.Build.0 = Debug|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Debug|x86.ActiveCfg = Debug|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Debug|x86.Build.0 = Debug|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Release|x64.ActiveCfg = Release|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Release|x64.Build.0 = Release|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Release|x86.ActiveCfg = Release|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Release|x86.Build.0 = Release|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5134A0F7-387C-44AC-9850-55B0D6B564ED}.Release|Any CPU.Build.0 = Release|Any CPU {1B54F9E3-119E-4148-8C47-EB7E2C1E562E}.Debug|x64.ActiveCfg = Debug|Any CPU {1B54F9E3-119E-4148-8C47-EB7E2C1E562E}.Debug|x64.Build.0 = Debug|Any CPU {1B54F9E3-119E-4148-8C47-EB7E2C1E562E}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/IVpxPrefab.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/IVpxPrefab.cs index 49700ea4b..bd5bc7441 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/IVpxPrefab.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/IVpxPrefab.cs @@ -38,8 +38,6 @@ public void SetReferencedData(Table table, IMaterialProvider materialProvider, I public void PersistData(); - public void UpdateTransforms(); - void FreeBinaryData(); } } diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportEngine.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportEngine.cs index 014095123..60ed46081 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportEngine.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportEngine.cs @@ -28,13 +28,13 @@ public static class VpxImportEngine { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public static GameObject ImportIntoScene(string path, GameObject parent = null, bool applyPatch = true, string tableName = null, ConvertOptions options = null) + public static GameObject ImportIntoScene(string path, GameObject parent = null, string tableName = null, ConvertOptions options = null) { var sw = Stopwatch.StartNew(); - return ImportIntoScene(TableLoader.LoadTable(path), Path.GetFileName(path), parent, applyPatch, tableName, sw, options); + return ImportIntoScene(TableLoader.LoadTable(path), Path.GetFileName(path), parent, tableName, sw, options); } - public static GameObject ImportIntoScene(FileTableContainer tableContainer, string filename = "", GameObject parent = null, bool applyPatch = true, string tableName = null, Stopwatch sw = null, ConvertOptions options = null) + public static GameObject ImportIntoScene(FileTableContainer tableContainer, string filename = "", GameObject parent = null, string tableName = null, Stopwatch sw = null, ConvertOptions options = null) { sw ??= Stopwatch.StartNew(); if (tableName == null && !string.IsNullOrEmpty(filename)) { @@ -43,8 +43,8 @@ public static GameObject ImportIntoScene(FileTableContainer tableContainer, stri // load table var loadedIn = sw.ElapsedMilliseconds; - var converter = new VpxSceneConverter(tableContainer, filename, options); - var tableGameObject = converter.Convert(applyPatch, tableName); + var converter = new VpxSceneConverter(tableContainer, options); + var tableGameObject = converter.Convert(tableName); var convertedIn = sw.ElapsedMilliseconds; // if an object was selected in the editor, make it its parent diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizard.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizard.cs index 14fdc9314..7acd3a65e 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizard.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizard.cs @@ -130,12 +130,6 @@ public void OnGUI() GUILayout.Space(settingsMargin); - VpxImportWizardSettings.ApplyPatch = EditorGUILayout.Toggle("Apply Patch", VpxImportWizardSettings.ApplyPatch); - - EditorGUILayout.LabelField("Allows you to disable the automatic patching of a table during the import", labelInfoStyle); - - GUILayout.Space(settingsMargin); - VpxImportWizardSettings.TableName = EditorGUILayout.TextField("Table Name", VpxImportWizardSettings.TableName); EditorGUILayout.LabelField("The name of the gameobject. Empty = default. Tags: %TABLENAME% = table name, %INFONAME% = Table's Info Name", labelInfoStyle); @@ -217,10 +211,8 @@ public void OnGUI() { VpxImportEngine.ImportIntoScene( VpxImportWizardSettings.VpxPath, - null, - VpxImportWizardSettings.ApplyPatch, - VpxImportWizardSettings.TableName, - VpxImportWizardSettings.BuildConvertOptions() + tableName: VpxImportWizardSettings.TableName, + options: VpxImportWizardSettings.BuildConvertOptions() ); } else diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizardSettings.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizardSettings.cs index b399da4ba..3483a5750 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizardSettings.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxImportWizardSettings.cs @@ -23,12 +23,6 @@ namespace VisualPinball.Unity.Editor { public static class VpxImportWizardSettings { - public static bool ApplyPatch - { - get => EditorPrefs.GetBool("ApplyPatch", true); - set => EditorPrefs.SetBool("ApplyPatch", value); - } - public static string VpxPath { get => EditorPrefs.GetString("VpxPath", ""); @@ -122,7 +116,6 @@ public static bool IsPathValid() public static void Reset() { VpxPath = ""; - ApplyPatch = true; TableName = "%TABLENAME%"; ObjectImportFilter = VpxObjectImportFilter.All; ImportTextures = true; diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPlayfieldPrefab.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPlayfieldPrefab.cs index eab00593a..8653c139c 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPlayfieldPrefab.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPlayfieldPrefab.cs @@ -63,9 +63,6 @@ public void PersistData() PrefabUtility.RecordPrefabInstancePropertyModifications(comp); } } - public void UpdateTransforms() - { - } public void FreeBinaryData() => _primitive.Data.FreeBinaryData(); } diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPrefab.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPrefab.cs index 8b3a84e38..7c0263ea6 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPrefab.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxPrefab.cs @@ -71,7 +71,7 @@ public void SetReferencedData(Table table, IMaterialProvider materialProvider, I UpdateTransforms(); } - public void UpdateTransforms() + private void UpdateTransforms() { if (_mainComponent && _mainComponent is IMainRenderableComponent renderComponent) { renderComponent.UpdateTransforms(); diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxSceneConverter.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxSceneConverter.cs index a143fe887..c62951c82 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxSceneConverter.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Import/VpxSceneConverter.cs @@ -86,23 +86,17 @@ public class VpxSceneConverter : ITextureProvider, IMaterialProvider, IMeshProvi private readonly Dictionary _materials = new Dictionary(); private readonly Dictionary _physicalMaterials = new Dictionary(); - private readonly IPatcher _patcher; - private bool _applyPatch = true; - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); /// /// Creates a new converter for a new table /// /// Source table container - /// File name of the file being imported /// Optional convert options - public VpxSceneConverter(FileTableContainer sourceContainer, string fileName = "", ConvertOptions options = null) + public VpxSceneConverter(FileTableContainer sourceContainer, ConvertOptions options = null) { _sourceContainer = sourceContainer; _sourceTable = sourceContainer.Table; - _patcher = PatcherManager.GetPatcher(); - _patcher?.Set(sourceContainer, fileName, this, this); _options = options ?? new ConvertOptions(); } @@ -142,10 +136,8 @@ public VpxSceneConverter(TableComponent tableComponent) CreateFileHierarchy(); } - public GameObject Convert(bool applyPatch = true, string tableName = null) + public GameObject Convert(string tableName = null) { - _applyPatch = applyPatch; - CreateRootHierarchy(tableName); CreateFileHierarchy(); DumpTableScript(); @@ -192,11 +184,6 @@ public GameObject Convert(bool applyPatch = true, string tableName = null) SetUpAudio(); - // patch - if (_applyPatch) { - _patcher?.PostPatch(_tableGo); - } - ApplyPlayfieldVisualMaterial(); return _tableGo; @@ -389,14 +376,6 @@ private Dictionary UpdateGameItems(Dictionary(meshPath); } - // patch - if (_applyPatch) { - _patcher?.ApplyPatches(prefab.GameObject, _tableGo); - if (prefab.GameObject) { // only if not destroyed.. - prefab.UpdateTransforms(); - } - } - // persist changes if (prefab.GameObject) { // only if not destroyed.. prefab.PersistData(); diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/IMaterialAdapter.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/IMaterialAdapter.cs deleted file mode 100644 index 7ee5d941f..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/IMaterialAdapter.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using UnityEngine; - -namespace VisualPinball.Unity -{ - public interface IMaterialAdapter - { - /// - /// Set the material of the gameobject to opaque. - /// - /// - /// - void SetOpaque(GameObject gameObject); - - /// - /// Set the material of the gameobject to double sided. - /// - /// - void SetDoubleSided(GameObject gameObject); - - void SetTransparentDepthPrepassEnabled(GameObject gameObject); - - /// - /// Set the AlphaCutOff value for the material of the gameobject. - /// - /// - void SetAlphaCutOff(GameObject gameObject, float value); - - /// - /// Enable AlphaCutOff for the material of the gameobject. - /// - /// - void SetAlphaCutOffEnabled(GameObject gameObject); - - /// - /// Disable NormalMap for the material of the gameobject. - /// - /// - void SetNormalMapDisabled(GameObject gameObject); - - /// - /// Set the Metallic value for the material of the gameobject. - /// - /// - void SetMetallic(GameObject gameObject, float value); - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/IMaterialAdapter.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/IMaterialAdapter.cs.meta deleted file mode 100644 index 1a1e15a20..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/IMaterialAdapter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 767889165ccd30e4ea5ff0a1a98bafc1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/RenderPipelineConverter.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/RenderPipelineConverter.cs index c842a18ff..0b464c2a4 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/RenderPipelineConverter.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/RenderPipelineConverter.cs @@ -38,12 +38,6 @@ public interface IRenderPipelineConverter /// RenderPipelineType Type { get; } - /// - /// Provides a bunch of helper methods for setting common attributes - /// in materials. - /// - IMaterialAdapter MaterialAdapter { get; } - /// /// Provides access to VPE's game item prefabs. /// diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardMaterialAdapter.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardMaterialAdapter.cs deleted file mode 100644 index 07f5b014a..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardMaterialAdapter.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using NLog; -using UnityEngine; -using Logger = NLog.Logger; - -namespace VisualPinball.Unity -{ - public class StandardMaterialAdapter : IMaterialAdapter - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - public void SetOpaque(GameObject gameObject) - { - Logger.Info("Not implemented for {0}: {1}", gameObject.name, "SetOpaque"); - } - public void SetDoubleSided(GameObject gameObject) - { - throw new System.NotImplementedException(); - } - - public void SetTransparentDepthPrepassEnabled(GameObject gameObject) - { - Logger.Info("Not implemented for {0}: {1}", gameObject.name, "SetTransparentDepthPrepassEnabled"); - } - - public void SetAlphaCutOff(GameObject gameObject, float value) - { - Logger.Info("Not implemented for {0}: {1}", gameObject.name, "SetAlphaCutOff"); - } - - public void SetAlphaCutOffEnabled(GameObject gameObject) - { - Logger.Info("Not implemented for {0}: {1}", gameObject.name, "SetAlphaCutOffEnabled"); - } - - public void SetNormalMapDisabled(GameObject gameObject) - { - Logger.Info("Not implemented for {0}: {1}", gameObject.name, "SetNormalMapDisabled"); - } - - public void SetMetallic(GameObject gameObject, float value) - { - Logger.Info("Not implemented for {0}: {1}", gameObject.name, "SetMetallic"); - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardMaterialAdapter.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardMaterialAdapter.cs.meta deleted file mode 100644 index 0ca4c638b..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardMaterialAdapter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: eb82dd9795de759439ee6a3c6ef05b2e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardRenderPipeline.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardRenderPipeline.cs index 669a097cf..e671d2aec 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardRenderPipeline.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering/Standard/StandardRenderPipeline.cs @@ -26,7 +26,6 @@ public class StandardRenderPipeline : IRenderPipelineConverter public RenderPipelineType Type { get; } = RenderPipelineType.Standard; public IMaterialConverter MaterialConverter { get; } = new StandardMaterialConverter(); - public IMaterialAdapter MaterialAdapter { get; } = new StandardMaterialAdapter(); public ILightConverter LightConverter { get; } = new StandardLightConverter(); public IPrefabProvider PrefabProvider { get; } = new StandardPrefabProvider(); } diff --git a/VisualPinball.Unity/VisualPinball.Unity.Editor/Toolbox/ToolboxEditor.cs b/VisualPinball.Unity/VisualPinball.Unity.Editor/Toolbox/ToolboxEditor.cs index 1332dea4c..f06194ccf 100644 --- a/VisualPinball.Unity/VisualPinball.Unity.Editor/Toolbox/ToolboxEditor.cs +++ b/VisualPinball.Unity/VisualPinball.Unity.Editor/Toolbox/ToolboxEditor.cs @@ -75,7 +75,7 @@ private void OnGUI() if (GUILayout.Button("New Table")) { var tableContainer = new FileTableContainer(); var converter = new VpxSceneConverter(tableContainer); - var rootGameObj = converter.Convert(false); + var rootGameObj = converter.Convert(); Selection.activeGameObject = rootGameObj; Undo.RegisterCreatedObjectUndo(rootGameObj, "New Table"); } diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher.meta deleted file mode 100644 index 66a6bb71d..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0417f4751186443592c45fe75288e081 -timeCreated: 1583488731 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher.meta deleted file mode 100644 index 8bccd3e49..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c3935a99818240a2b8a2c225a5a22ed5 -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item.meta deleted file mode 100644 index af3bdbf7b..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 76c4882e43f144d393640a68b1e35d43 -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/ItemMatchAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/ItemMatchAttribute.cs deleted file mode 100644 index 7b50f30a8..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/ItemMatchAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using UnityEngine; -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - public abstract class ItemMatchAttribute : Attribute - { - /// - /// If set, pass the game object with this name as reference to the patcher. - /// - public string Ref; - - public float FloatParam; - - public abstract bool Matches(FileTableContainer tableContainer, GameObject obj); - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/ItemMatchAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/ItemMatchAttribute.cs.meta deleted file mode 100644 index ff8e1b645..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/ItemMatchAttribute.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ef786f2c87514169bec9cda30740083d -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/NameMatchAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/NameMatchAttribute.cs deleted file mode 100644 index 7d53303a4..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/NameMatchAttribute.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using UnityEngine; -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher -{ - /// - /// Matches an game item by its name. - /// - public class NameMatchAttribute : ItemMatchAttribute - { - public bool IgnoreCase = true; - - private readonly string _name; - - public NameMatchAttribute(string name) - { - _name = name; - } - - public override bool Matches(FileTableContainer tableContainer, GameObject go) - { - if (!go) { - return false; - } - return IgnoreCase - ? string.Equals(go.name, _name, StringComparison.CurrentCultureIgnoreCase) - : go.name == _name; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/NameMatchAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/NameMatchAttribute.cs.meta deleted file mode 100644 index 0c3a87259..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/NameMatchAttribute.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 3379f685dbae4679a4c07ca25105c4a6 -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/RenderPipelineAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/RenderPipelineAttribute.cs deleted file mode 100644 index 6e5156b0b..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/RenderPipelineAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using UnityEngine; -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher.Matcher.Item -{ - /// - /// Matches if the render pipeline is set to a given type. - /// - public class RenderPipelineAttribute : ItemMatchAttribute - { - private readonly RenderPipelineType _type; - - public RenderPipelineAttribute(RenderPipelineType type) - { - _type = type; - } - - public override bool Matches(FileTableContainer tableContainer, GameObject obj) - { - return RenderPipeline.Current.Type == _type; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/RenderPipelineAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/RenderPipelineAttribute.cs.meta deleted file mode 100644 index 174cc964f..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Item/RenderPipelineAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 60df9b98a21aebc4dbafe2ecb517bd7b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table.meta deleted file mode 100644 index 22cd3ab73..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 677647ec59254030bb8aa07838c42c9f -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/AnyMatchAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/AnyMatchAttribute.cs deleted file mode 100644 index 252cd0151..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/AnyMatchAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher -{ - /// - /// Matches all tables. - /// - public class AnyMatchAttribute : TableMatchAttribute - { - public override bool Matches(FileTableContainer tableContainer, string fileName) - { - return true; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/AnyMatchAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/AnyMatchAttribute.cs.meta deleted file mode 100644 index a510a3316..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/AnyMatchAttribute.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a4f7205c3d32431b83043bb64e609833 -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/MetaMatchAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/MetaMatchAttribute.cs deleted file mode 100644 index 015703eeb..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/MetaMatchAttribute.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher -{ - /// - /// Matches by Table Info (in Visual Pinball under the "Table" menu).

- /// - /// All of the provided fields must match. If none provided, it always matches. - ///

- public class MetaMatchAttribute : TableMatchAttribute - { - public string TableName; - public string TableVersion; - public string AuthorName; - - public override bool Matches(FileTableContainer tableContainer, string fileName) - { - if (TableName != null && tableContainer.InfoName != TableName) { - return false; - } - if (TableVersion != null && tableContainer.InfoVersion != TableVersion) { - return false; - } - if (AuthorName != null && tableContainer.InfoAuthorName != AuthorName) { - return false; - } - - return true; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/MetaMatchAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/MetaMatchAttribute.cs.meta deleted file mode 100644 index 663957f9c..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/MetaMatchAttribute.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0ea1ad9032a34b10805f862941593a0b -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/RenderPipelineAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/RenderPipelineAttribute.cs deleted file mode 100644 index 6dd52ca51..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/RenderPipelineAttribute.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher.Matcher.Table -{ - /// - /// Matches if the render pipeline is set to a given type. - /// - public class RenderPipelineAttribute : TableMatchAttribute - { - private readonly RenderPipelineType _type; - - public RenderPipelineAttribute(RenderPipelineType type) - { - _type = type; - } - - public override bool Matches(FileTableContainer tableContainer, string fileName) - { - return RenderPipeline.Current.Type == _type; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/RenderPipelineAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/RenderPipelineAttribute.cs.meta deleted file mode 100644 index f52faa3e2..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/RenderPipelineAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d843e35ea7645aa48b9b28957381b49c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableMatchAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableMatchAttribute.cs deleted file mode 100644 index fbbdbc357..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableMatchAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher -{ - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public abstract class TableMatchAttribute : Attribute - { - public abstract bool Matches(FileTableContainer tableContainer, string fileName); - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableMatchAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableMatchAttribute.cs.meta deleted file mode 100644 index 67075dfb0..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableMatchAttribute.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 126c61e6060f45e9b481cbfd0c6f5bb8 -timeCreated: 1583488750 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableNameMatchAttribute.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableNameMatchAttribute.cs deleted file mode 100644 index 97d3c74b7..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableNameMatchAttribute.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity.Patcher.Matcher.Table -{ - /// - /// Matches by table name (how the table is called in the script).

- ///

- public class TableNameMatchAttribute : TableMatchAttribute - { - private readonly string _name; - - public TableNameMatchAttribute(string name) - { - _name = name; - } - - public override bool Matches(FileTableContainer tableContainer, string fileName) - { - return _name == null || tableContainer.Table.Data.Name == _name; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableNameMatchAttribute.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableNameMatchAttribute.cs.meta deleted file mode 100644 index 0f16e4b8d..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/Table/TableNameMatchAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 460d940b13b909742912dca08c9b7a2c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/TablePatcher.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/TablePatcher.cs deleted file mode 100644 index 4bb8e8376..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/TablePatcher.cs +++ /dev/null @@ -1,530 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Linq; -using UnityEditor; -using UnityEngine; -using VisualPinball.Engine.VPT; -using VisualPinball.Engine.VPT.Light; -using VisualPinball.Engine.VPT.Table; -using VisualPinball.Engine.VPT.Trough; -using VisualPinball.Unity.Editor; -using Light = UnityEngine.Light; -using Object = UnityEngine.Object; -using VpeLight = VisualPinball.Engine.VPT.Light.Light; - -namespace VisualPinball.Unity.Patcher -{ - [Api] - public abstract class TablePatcher - { - public TableContainer TableContainer; - public ITextureProvider TextureProvider; - public IMaterialProvider MaterialProvider; - - /// - /// This method is executed once after all element-specific patches had - /// been applied.

- /// - /// Override this method when you need to create new objects or make global - /// changes to the project. - ///

- /// GameObject of the table. - public virtual void PostPatch(GameObject tableGo) - { - CreateTrough(tableGo, Playfield(tableGo)); - } - - #region GameObject Helpers - - /// - /// Returns the playfield of a given table game object. - /// - /// Table game object - /// - protected static GameObject Playfield(GameObject tableGo) - { - var pf = tableGo.GetComponentInChildren(); - if (pf) { - return pf.gameObject; - } - - Debug.LogWarning($"Cannot find playfield of \"{tableGo.name}\"."); - return tableGo; - - } - - /// - /// Creates an empty game object. - /// - /// Parent of the new game object - /// Name of the new game object - /// - protected static GameObject CreateEmptyGameObject(GameObject parentGo, string name) - { - var newGo = new GameObject(name); - newGo.transform.SetParent(parentGo.transform, false); - return newGo; - } - - protected static GameObject GetOrCreateGameObject(GameObject parentGo, string name) - { - for (var i = 0; i < parentGo.transform.childCount; i++) { - if (parentGo.transform.GetChild(i).gameObject.name == name) { - return parentGo.transform.GetChild(i).gameObject; - } - } - - return CreateEmptyGameObject(parentGo, name); - } - - /// - /// Set a new parent for the given child while keeping the position and rotation. - /// - /// - /// - protected static void Reparent(GameObject child, GameObject parent) - { - var rot = child.transform.rotation; - var pos = child.transform.position; - - // re-parent the child - child.transform.SetParent(parent.transform, false); - - child.transform.rotation = rot; - child.transform.position = pos; - } - - #endregion - - #region Element Helpers - - /// - /// Creates a trough. - /// - /// Table game object, for retrieving references - /// Parent game object of the new trough - /// Name of the new trough - /// Name of the exit kicker - /// Name of the entry switch - protected static TroughComponent CreateTrough(GameObject tableGo, GameObject parentGo, - string name = "Trough", string exitKicker = "BallRelease", string entrySwitch = "Drain") - { - var trough = new Trough(new TroughData { - BallCount = 4, - SwitchCount = 4, - Type = TroughType.ModernMech, - }); - - var troughGo = trough.InstantiateEditorPrefab(parentGo.transform); - var troughComponent = troughGo.GetComponent(); - - var kickers = tableGo.GetComponentsInChildren(); - foreach (var kicker in kickers) { - if (string.Equals(kicker.name, exitKicker, StringComparison.OrdinalIgnoreCase)) { - troughComponent.PlayfieldExitKicker = kicker; - troughComponent.PlayfieldExitKickerItem = kicker.AvailableCoils.First().Id; - } - if (string.Equals(kicker.name, entrySwitch, StringComparison.OrdinalIgnoreCase)) { - troughComponent.PlayfieldEntrySwitch = kicker; - troughComponent.PlayfieldEntrySwitchItem = kicker.AvailableSwitches.First().Id; - } - } - - if (troughComponent.PlayfieldEntrySwitch == null) { - var triggers = tableGo.GetComponentsInChildren(); - foreach (var trigger in triggers) { - - if (string.Equals(trigger.name, entrySwitch, StringComparison.OrdinalIgnoreCase)) { - troughComponent.PlayfieldEntrySwitch = trigger; - } - } - } - - troughGo.name = name; - return troughComponent; - } - - protected T FindSiblingComponent(MonoBehaviour mb, string name) where T : MonoBehaviour - { - return mb.gameObject.transform.parent.transform.Find(name).gameObject.GetComponent(); - } - - /// - /// Creates a drop target bank component. - /// - /// Table game object, for retrieving references - /// Parent game object of the new trough - /// Name of the new drop target bank - /// A list of drop targets that are in the drop target bank. - - protected static DropTargetBankComponent CreateDropTargetBank(GameObject tableGo, GameObject go, - string name = "DropTargetBank", params string[] dropTargetNames) - { - var playfieldGo = go.GetComponentInParent().gameObject; - var dropTargetBankParentGo = GetOrCreateGameObject(playfieldGo, "Drop Target Banks"); - - var dropTargetBankGo = PrefabUtility.InstantiatePrefab(DropTargetBankComponent.LoadPrefab(), dropTargetBankParentGo.transform) as GameObject; - var dropTargetBank = dropTargetBankGo!.GetComponent(); - - var compIndex = tableGo.GetComponentsInChildren() - .ToDictionary(dtc => dtc.name, dtc => dtc); - var dropTargetComponents = dropTargetNames - .Where(n => compIndex.ContainsKey(n)) - .Select(n => compIndex[n]) - .ToArray(); - - dropTargetBank.name = name; - dropTargetBank.BankSize = dropTargetComponents.Length; - dropTargetBank.DropTargets = dropTargetComponents; - - return dropTargetBank; - } - - #endregion - - #region Light Helpers - - /// - /// Adds a light group component to an existing game object. - /// - /// Table game object for retrieving light references. - /// Game object to which the light group is added to. - /// A list of light names that are part of the light group. - protected static LightGroupComponent AddLightGroup(GameObject tableGo, GameObject go, params string[] names) - { - var lightComponentGroup = go.AddComponent(); - - var compIndex = tableGo.GetComponentsInChildren() - .ToDictionary(lc => lc.name, lc => lc); - var lightComponents = names - .Where(n => compIndex.ContainsKey(n)) - .Select(n => compIndex[n]) - .ToList(); - - lightComponentGroup.Lights = lightComponents; - - return lightComponentGroup; - } - - /// - /// Sets the light color of a light source. - /// - /// - /// Supports multiple light sources. - /// - /// Game object of the light source - /// New color of the light source - protected static void LightColor(GameObject go, Color color) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.SetColor(light, color); - } - } - - /// - /// Sets the temperature of the light. - /// - /// Game object of the light - /// Temperature in Kelvin - protected static void LightTemperature(GameObject go, float temp) - { - foreach (var l in go.GetComponentsInChildren()) { - RenderPipeline.Current.LightConverter.SetTemperature(l, temp); - } - } - - /// - /// Sets the angle of a spot light. - /// - /// - /// Supports multiple light sources. - /// - /// Game object of the spot light - /// Outer angle of the spot - /// Inner angle of the spot, in percent of the outer angle - protected static void SpotAngle(GameObject go, float outer, float inner) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.SpotLight(light, outer, inner); - } - } - - - /// - /// Sets the angle of a spot light. - /// - /// - /// Supports multiple light sources. - /// - /// Game object of the spot light - /// Outer angle of the spot - /// Inner angle of the spot, in percent of the outer angle - protected static void PointRange(GameObject go, float outer, float inner) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.SpotLight(light, outer, inner); - } - } - - /// - /// Sets a light source to pyramid spotlight and sets its parameters. - /// - /// - /// Supports multiple light sources. - /// - /// Game object of the light source - /// Angle of the pyramid - /// Aspect ratio of the pyramid - protected static void PyramidAngle(GameObject go, float angle, float ar) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.PyramidAngle(light, angle, ar); - } - } - - /// - /// Sets the intensity of a light source in lumen. - /// - /// - /// Supports multiple light sources. - /// - /// Game object of the light source - /// Intensity of the light in lumen - protected static void LightIntensity(GameObject go, float intensityLumen) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.SetIntensity(light, intensityLumen); - } - } - - /// - /// Sets the range of the light. - /// - /// Game object of the light - /// Range in meters - protected static void LightRange(GameObject go, float range) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.SetRange(light, range); - } - } - - /// - /// Sets the shadow of the light. - /// - /// Game object of the light - /// Whether to enable or disable shadows. - /// If true, update on each frame. - /// Distance from when on shadows are cast. - protected static void LightShadow(GameObject go, bool enabled, bool isDynamic, float nearPlane = 0.01f) - { - var lights = go.GetComponentsInChildren(); - foreach (var light in lights) { - RenderPipeline.Current.LightConverter.SetShadow(light, enabled, isDynamic, nearPlane); - } - } - - /// - /// Sets the light position. - /// - /// - /// Supports multiple light sources. Note that this only applies to the light source, not to the light itself. - /// - /// Game object of the light source - /// X-position of the source relative to the light - /// Y-position of the source relative to the light - /// Z-position of the source relative to the light - protected static void LightPos(GameObject go, float x, float y, float z) - { - var light = go.GetComponentInChildren(); - if (light != null) { - light.gameObject.transform.localPosition = new Vector3(x, y, z); - } - } - - /// - /// Creates a point light. - /// - /// Name of the new light - /// X-position on the playfield - /// Y-position on the playfield - /// Game object to parent to (usually "Lights") - /// - protected static LightComponent CreateLight(string name, float x, float y, GameObject parentGo) - { - var light = VpeLight.GetDefault(name, x, y); - light.Data.ShowBulbMesh = false; - - var prefab = RenderPipelineConverter.Current.PrefabProvider.CreateLight(); - var lightGo = PrefabUtility.InstantiatePrefab(prefab, parentGo.transform) as GameObject; - if (!lightGo) { - return null; - } - lightGo.name = name; - var lightTransform = lightGo.transform; - var lightComponent = lightGo.GetComponent(); - lightComponent.SetData(light.Data); - lightComponent.UpdateTransforms(); - lightTransform.Find("Bulb").gameObject.SetActive(false); - lightTransform.Find("Socket").gameObject.SetActive(false); - return lightComponent; - } - - /// - /// Converts a normal light to an insert light, by deleting and re-creating the insert prefab. - /// - /// Light component to convert - /// New converted game object - protected GameObject ConvertToInsertLight(LightComponent lo) - { - var name = lo.name; - var parent = lo.transform.parent.gameObject; - Object.DestroyImmediate(lo.gameObject); - return CreateInsertLight(TableContainer.Get(name).Data, parent); - } - - /// - /// Creates an insert light based on existing light data. - /// - /// - /// - private GameObject CreateInsertLight(LightData data, GameObject parentGo) - { - var prefab = RenderPipelineConverter.Current.PrefabProvider.CreateInsertLight(); - var go = PrefabUtility.InstantiatePrefab(prefab, parentGo.transform) as GameObject; - go!.name = data.Name; - data.OffImage = TableContainer.Table.Data.Image; - var lc = go.GetComponent(); - lc.SetData(data); - lc.SetReferencedData(data, TableContainer.Table, MaterialProvider, TextureProvider, null); - - EditorUtility.SetDirty(go); - PrefabUtility.RecordPrefabInstancePropertyModifications(lc); - - return go; - } - - /// - /// Duplicates a light source. - /// - /// Game object of the light source - /// X-position of the new light source, relative to the lamp - /// Y-position of the new light source, relative to the lamp - /// Z-position of the new light source, relative to the lamp - protected static void DuplicateLight(GameObject go, float x, float y, float z) - { - var light = go.GetComponentInChildren(); - if (light != null) { - var newGo = Object.Instantiate(light.gameObject, go.transform, true); - newGo.transform.localPosition = new Vector3(x, y, z); - } - } - - /// - /// Creates a light group with the given light names - /// - /// GameObject to add the light group to. - /// Names of the light GameObjects. They must be sister objects of the first parameter. - protected static void LinkLights(GameObject go, params string[] lightNames) - { - var parentTransform = go.transform.parent; - var lightComponents = lightNames - .Select(n => parentTransform.Find(n).GetComponent()) - .Where(c => c != null); - var lg = go.AddComponent(); - lg.Lights = lightComponents.ToList(); - } - - #endregion - - #region Mapping Helpers - - /// - /// Links a coil device to an existing coil mapping. - /// - /// Table component for retrieving mappings. - /// The ID of the coil mapping that the coil device will be linked to - /// The coil device to be linked - /// If set, it's the device item, otherwise the first item of the device. - protected static void LinkCoil(TableComponent tableComponent, string coilId, ICoilDeviceComponent coilDevice, string deviceItem = null) - { - var coilMapping = tableComponent.MappingConfig.Coils.FirstOrDefault(cm => cm.Id == coilId); - if (coilMapping == null) { - return; - } - coilMapping.Device = coilDevice; - coilMapping.DeviceItem = deviceItem ?? coilDevice.AvailableCoils.First().Id; - } - - /// - /// Links a coil device to an existing coil mapping if it matches a given name. - /// - /// Table component for retrieving mappings. - /// The name that the coil device's GameObject has to match in order to be linked. - /// The ID of the coil mapping that the coil device will be linked to - /// The coil device to be linked - /// If set, it's the device item, otherwise the first item of the device. - protected static void LinkCoil(TableComponent tableComponent, string elementName, string coilId, ICoilDeviceComponent coilDevice, string deviceItem = null) - { - if (!string.Equals(coilDevice.gameObject.name, elementName, StringComparison.OrdinalIgnoreCase)) { - return; - } - LinkCoil(tableComponent, coilId, coilDevice, deviceItem); - } - - /// - /// Links a switch device to an existing switch mapping. - /// - /// Table component for retrieving mappings. - /// The ID of the switch mapping that the switch device will be linked to - /// The switch device to be linked - /// Switch ID inside of the device item. If null, the first switch will be used. - protected static void LinkSwitch(TableComponent tableComponent, string switchId, ISwitchDeviceComponent switchDevice, string switchDeviceItem = null) - { - var switchMapping = tableComponent.MappingConfig.Switches.FirstOrDefault(sw => sw.Id == switchId); - if (switchMapping == null) { - return; - } - switchMapping.Device = switchDevice; - switchMapping.DeviceItem = switchDeviceItem ?? switchDevice.AvailableSwitches.First().Id; - } - - /// - /// Links a switch device to an existing switch mapping if it matches a given name. - /// - /// Table component for retrieving mappings. - /// The name that the switch device's GameObject has to match in order to be linked. - /// The ID of the switch mapping that the switch device will be linked to - /// The switch device to be linked - protected static void LinkSwitch(TableComponent tableComponent, string elementName, string switchId, ISwitchDeviceComponent switchDevice) - { - if (!string.Equals(switchDevice.gameObject.name, elementName, StringComparison.OrdinalIgnoreCase)) { - return; - } - LinkSwitch(tableComponent, switchId, switchDevice); - } - - #endregion - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/TablePatcher.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/TablePatcher.cs.meta deleted file mode 100644 index dc0d95ed9..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Matcher/TablePatcher.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f2db227803e55c64fac564f27a2464b2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher.meta deleted file mode 100644 index bad8111d2..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d3dfd67c93e94b4d99f89b23cfe5cc49 -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common.meta deleted file mode 100644 index 106258b64..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 7f5754d87ae245f797fd9746f827de9e -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/Defaults.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/Defaults.cs deleted file mode 100644 index 726327975..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/Defaults.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using UnityEngine; - -namespace VisualPinball.Unity.Patcher -{ - [AnyMatch] - public class Defaults - { - [NameMatch("BallShadow1")] - [NameMatch("BallShadow2")] - [NameMatch("BallShadow3")] - [NameMatch("BallShadow4")] - [NameMatch("BallShadow5")] - [NameMatch("BallShadow6")] - [NameMatch("BallShadow7")] - public void RemoveBallShadow(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("FlipperLSh")] - [NameMatch("FlipperRSh")] - public void RemoveFlipperShadow(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("Ruler_mm")] - [NameMatch("Ruler_inches")] - [NameMatch("Ruler_inches_and_mm")] - public void RemoveColliders(PrimitiveColliderComponent collider) - { - Object.DestroyImmediate(collider); - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/Defaults.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/Defaults.cs.meta deleted file mode 100644 index 173c7f518..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/Defaults.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 05c2c3e4b1a2464898983d4db055b87b -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/PatcherUtil.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/PatcherUtil.cs deleted file mode 100644 index f4162f66a..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/PatcherUtil.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using NLog; -using UnityEngine; -using Logger = NLog.Logger; - -namespace VisualPinball.Unity.Patcher -{ - /// - /// Common methods for patching a table during import. - /// - static class PatcherUtil - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - /// - /// Hide the gameobject. - /// - /// - public static void Hide(GameObject gameObject) - { - gameObject.SetActive(false); - } - - /// - /// Set a new parent for the given child while keeping the position and rotation. - /// - /// - /// - public static void Reparent(GameObject child, GameObject parent) - { - var rot = child.transform.rotation; - var pos = child.transform.position; - - // re-parent the child - child.transform.SetParent(parent.transform, false); - - child.transform.rotation = rot; - child.transform.position = pos; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/PatcherUtil.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/PatcherUtil.cs.meta deleted file mode 100644 index bb3acfe91..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Common/PatcherUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 79ce971d0433bf74e90e452941cc356b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Patcher.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Patcher.cs deleted file mode 100644 index 434bb4c2c..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Patcher.cs +++ /dev/null @@ -1,167 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable UnusedType.Global - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using NLog; -using UnityEngine; -using VisualPinball.Engine.VPT.Table; -using Logger = NLog.Logger; - -namespace VisualPinball.Unity.Patcher -{ - public sealed class Patcher : IPatcher - { - private readonly List _patchers = new List(); - private FileTableContainer _tableContainer; - - private IMaterialProvider _materialProvider; - private ITextureProvider _textureProvider; - - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - public void Set(FileTableContainer tableContainer, string fileName, IMaterialProvider materialProvider, ITextureProvider textureProvider) - { - _tableContainer = tableContainer; - _materialProvider = materialProvider; - _textureProvider = textureProvider; - - var types = typeof(Patcher).Assembly.GetTypes(); - foreach (var type in types) { - var classMatchers = type - .GetCustomAttributes(typeof(TableMatchAttribute), false) - .Select(a => a as TableMatchAttribute) - .Where(a => a != null) - .Where(a => a.Matches(_tableContainer, fileName)) - .ToArray(); - - if (classMatchers.Length > 0) { - _patchers.Add(Activator.CreateInstance(type)); - } - } - Logger.Info("Table will be patched using the following patchers: [ {0} ]", string.Join(", ", _patchers.Select(o => o.GetType().Name))); - } - - public void ApplyPatches(GameObject gameObject, GameObject tableGameObject) - { - foreach (var patcher in _patchers) { - var methods = patcher.GetType().GetMembers().Where(member => member.MemberType == MemberTypes.Method); - - if (patcher is TablePatcher tp) { - tp.TableContainer = _tableContainer; - tp.MaterialProvider = _materialProvider; - tp.TextureProvider = _textureProvider; - } - - foreach (var method in methods) { - var methodMatchers = Attribute - .GetCustomAttributes(method, typeof(ItemMatchAttribute)) - .Select(a => a as ItemMatchAttribute) - .Where(a => a != null); - - var methodInfo = method as MethodInfo; - if (methodInfo != null) { - foreach (var methodMatcher in methodMatchers) { - // if the game object has been destroyed by a patcher, exit. - if (!gameObject) { - return; - } - if (methodMatcher.Matches(_tableContainer, gameObject)) { - var validArgs = true; - var patcherParamInfos = methodInfo.GetParameters(); - var patcherParams = new object[patcherParamInfos.Length]; - - foreach (var pi in patcherParamInfos) { - - // principal game object - if (pi.ParameterType == typeof(GameObject)) { - patcherParams[pi.Position] = gameObject; - - // game object reference - } else if (pi.ParameterType == typeof(GameObject).MakeByRefType()) { - if (methodMatcher.Ref == null) { - Logger.Warn($"No Ref provided in {pi.ParameterType} {pi.Name} in patch method {patcher.GetType()}.{methodInfo.Name}(), skipping."); - validArgs = false; - - } else { - var goRef = tableGameObject.transform.Find(methodMatcher.Ref); - if (goRef == null) { - Logger.Warn($"No GameObject named {methodMatcher.Ref} found in {pi.ParameterType} {pi.Name} in patch method {patcher.GetType()}.{methodInfo.Name}(), skipping."); - validArgs = false; - - } else { - patcherParams[pi.Position] = goRef.gameObject; - } - } - - // component - } else if (typeof(MonoBehaviour).IsAssignableFrom(pi.ParameterType)) { - var comp = gameObject.GetComponent(pi.ParameterType); - if (comp != null) { - patcherParams[pi.Position] = comp; - - } else { - Logger.Warn($"Component {pi.ParameterType} not found on element \"{gameObject.name}\"."); - validArgs = false; - } - - // table object - } else if (pi.ParameterType == typeof(Table)) { - patcherParams[pi.Position] = _tableContainer.Table; - - // source table container - } else if (pi.ParameterType == typeof(FileTableContainer)) { - patcherParams[pi.Position] = _tableContainer; - - // param from matcher - } else if (pi.ParameterType == typeof(float) && pi.Name == "param") { - patcherParams[pi.Position] = methodMatcher.FloatParam; - - } else { - Logger.Warn($"Unknown parameter {pi.ParameterType} {pi.Name} in patch method {patcher.GetType()}.{methodInfo.Name}(), skipping."); - validArgs = false; - } - } - - if (validArgs) { - Logger.Info($"Patching element \"{gameObject.name}\" based on match by {patcher.GetType().Name}.{method.Name}"); - methodInfo.Invoke(patcher, patcherParams); - - } else { - Logger.Error($"NOT patching element \"{gameObject.name}\" based on match by {patcher.GetType().Name}.{method.Name}"); - } - - } - } - } - } - } - } - - public void PostPatch(GameObject go) - { - foreach (var patcher in _patchers) { - if (patcher is TablePatcher p) { - p.PostPatch(go); - } - } - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Patcher.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Patcher.cs.meta deleted file mode 100644 index 17416647b..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Patcher.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 22d15f57f5d94b47a11ba016788aad16 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables.meta deleted file mode 100644 index db9a5ad13..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: eb06d90136d042abb7ad33ab94a37157 -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/CreatureFromTheBlackLagoon.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/CreatureFromTheBlackLagoon.cs deleted file mode 100644 index 5e99fb06a..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/CreatureFromTheBlackLagoon.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Creature From The Black Lagoon", AuthorName = "fuzzel, flupper1, rothbauerw")] - public class CreatureFromTheBlackLagoon : TablePatcher - { - [NameMatch("batleft", Ref = "Playfield/Flippers/LeftFlipper")] - [NameMatch("batright", Ref = "Playfield/Flippers/RightFlipper")] - public void ReparentFlippers(PrimitiveComponent flipper, GameObject gameObject, ref GameObject parent) - { - PatcherUtil.Reparent(gameObject, parent); - - flipper.Position = Vector2.zero; - // flipper.ObjectRotation.z = 0; - } - - [NameMatch("batleftshadow")] - [NameMatch("batrightshadow")] - public void RemoveFlipperShadow(GameObject gameObject) - { - gameObject.SetActive(false); - } - - [NameMatch("sw55")] - public void FixSw55(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Speed = 20; - kickerComponent.Coils[0].Angle = 60; - } - - [NameMatch("sw56")] - public void FixSw56(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Speed = 12; - kickerComponent.Coils[0].Angle = 60; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/CreatureFromTheBlackLagoon.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/CreatureFromTheBlackLagoon.cs.meta deleted file mode 100644 index 2474e25af..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/CreatureFromTheBlackLagoon.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0cc69560675214f87946cb6cab296984 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Goldorak.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Goldorak.cs deleted file mode 100644 index a062be444..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Goldorak.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Goldorak", AuthorName = "Rom (Future PinBall) Javier VPX")] - public class Goldorak : TablePatcher - { - [NameMatch("LFLogo", Ref = "Playfield/Flippers/LeftFlipper")] - [NameMatch("RFLogo", Ref = "Playfield/Flippers/RightFlipper")] - public void ReparentFlippers(PrimitiveComponent flipper, GameObject gameObject, ref GameObject parent) - { - PatcherUtil.Reparent(gameObject, parent); - - flipper.Position = Vector2.zero; - - // rotation is set in the original data, reparenting caused the flippers to be rotated wrong => fixing the rotation - // flipper.Rotation.y = 0; - - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Goldorak.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Goldorak.cs.meta deleted file mode 100644 index 39c4dcc24..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Goldorak.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 706d4c4419a90414685b3eb2b0ec8e4e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/IndianaJones.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/IndianaJones.cs deleted file mode 100644 index c391d7e24..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/IndianaJones.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; -using UnityEngine.Rendering; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Indiana Jones - The Pinball Adventure", AuthorName = "ninuzzu,tom tower")] - public class IndianaJones : TablePatcher - { - [NameMatch("LeftFlipperSh", IgnoreCase = false)] - [NameMatch("RightFlipperSh")] - public void RemoveFlipperShadow(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("Primitive21")] - public void FixWhateverPrimitive21Is(GameObject gameObject) - { - var unityMat = gameObject.GetComponent().sharedMaterial; - unityMat.SetFloat("_Mode", 1); - unityMat.SetInt("_SrcBlend", (int)BlendMode.One); - unityMat.SetInt("_DstBlend", (int)BlendMode.Zero); - unityMat.SetInt("_ZWrite", 1); - unityMat.EnableKeyword("_ALPHATEST_ON"); - unityMat.DisableKeyword("_ALPHABLEND_ON"); - unityMat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); - unityMat.renderQueue = 2450; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/IndianaJones.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/IndianaJones.cs.meta deleted file mode 100644 index b34dd4165..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/IndianaJones.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1f3caa34b5534392917f93f21e567a88 -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/JurassicPark.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/JurassicPark.cs deleted file mode 100644 index 6c8256e10..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/JurassicPark.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; -using UnityEngine.Rendering; -using VisualPinball.Unity.Editor; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Jurassic Park (Data East)", AuthorName = "Dark & Friends")] - public class JurassicPark : TablePatcher - { - #region Shader Properties - - private static readonly int DistortionSrcBlend = Shader.PropertyToID("_DistortionSrcBlend"); - private static readonly int DistortionDstBlend = Shader.PropertyToID("_DistortionDstBlend"); - private static readonly int DistortionBlurSrcBlend = Shader.PropertyToID("_DistortionBlurSrcBlend"); - private static readonly int DistortionBlurDstBlend = Shader.PropertyToID("_DistortionBlurDstBlend"); - private static readonly int StencilWriteMask = Shader.PropertyToID("_StencilWriteMask"); - private static readonly int StencilWriteMaskGBuffer = Shader.PropertyToID("_StencilWriteMaskGBuffer"); - private static readonly int StencilWriteMaskMv = Shader.PropertyToID("_StencilWriteMaskMV"); - private static readonly int AlphaCutoffEnable = Shader.PropertyToID("_AlphaCutoffEnable"); - private static readonly int TransparentDepthPrepassEnable = Shader.PropertyToID("_TransparentDepthPrepassEnable"); - private static readonly int SurfaceType = Shader.PropertyToID("_SurfaceType"); - private static readonly int BlendMode = Shader.PropertyToID("_BlendMode"); - private static readonly int DstBlend = Shader.PropertyToID("_DstBlend"); - private static readonly int AlphaDstBlend = Shader.PropertyToID("_AlphaDstBlend"); - private static readonly int ZWrite = Shader.PropertyToID("_ZWrite"); - private static readonly int ZTestDepthEqualForOpaque = Shader.PropertyToID("_ZTestDepthEqualForOpaque"); - private static readonly int ZTestGBuffer = Shader.PropertyToID("_ZTestGBuffer"); - - #endregion - - /// - /// Removing the normal map. - /// The normal map of the TRex Head is bad and contains invalid data. - /// This causes the entire unity editor window to become black and the play mode flicker if normal map scale is higher than 0. - /// - /// - [NameMatch("TrexMain")] - public void FixBrokenNormalMap(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetNormalMapDisabled(gameObject); - } - - [NameMatch("LFLogo", Ref="Playfield/Flippers/LeftFlipper")] - [NameMatch("RFLogo", Ref="Playfield/Flippers/RightFlipper")] - [NameMatch("RFLogo1", Ref="Playfield/Flippers/UpperRightFlipper")] - public void ReparentFlippers(PrimitiveComponent primitive, GameObject gameObject, ref GameObject parent) - { - PatcherUtil.Reparent(gameObject, parent); - primitive.Position = Vector3.zero; - // primitive.ObjectRotation.z = 0; - } - - [NameMatch("PLeftFlipper")] - [NameMatch("PRightFlipper")] - [NameMatch("PRightFlipper1")] - public void SetAlphaCutOffEnabled(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetAlphaCutOffEnabled(gameObject); - } - - [NameMatch("Primitive_Plastics")] - public void SetOpaque(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetOpaque(gameObject); - } - - [NameMatch("leftrail")] - [NameMatch("rightrail")] - [NameMatch("TrexMain")] - [NameMatch("sidewalls")] - public void SetDoubleSided(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetDoubleSided(gameObject); - } - - [NameMatch("Primitive_SideWallReflect")] - [NameMatch("Primitive_SideWallReflect1")] - [NameMatch("Primitive_PlasticWhitePart")] // bug in the table, sticks out from the ramp; doesn't contribute anyway to the table - public void Hide(GameObject gameObject) - { - PatcherUtil.Hide(gameObject); - } - - /// - /// Custom properties for the ramp: - /// * change opaque to transparent - /// * disable alpha clipping - /// * enable depth prepass - /// - /// - [NameMatch("Primitive_PlasticsRamp")] - public void ApplyRampSettings(GameObject gameObject) - { - var material = gameObject.GetComponent().sharedMaterial; - - material.EnableKeyword("_BLENDMODE_PRESERVE_SPECULAR_LIGHTING"); - material.EnableKeyword("_BLENDMODE_PRE_MULTIPLY"); - material.EnableKeyword("_ENABLE_FOG_ON_TRANSPARENT"); - material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); - material.EnableKeyword("_DISABLE_SSR_TRANSPARENT"); - material.DisableKeyword("_ALPHATEST_ON"); - - material.SetInt(DistortionSrcBlend, 1); - material.SetInt(DistortionDstBlend, 1); - material.SetInt(DistortionBlurSrcBlend, 1); - material.SetInt(DistortionBlurDstBlend, 1); - material.SetInt(StencilWriteMask, 6); - material.SetInt(StencilWriteMaskGBuffer, 14); - material.SetInt(StencilWriteMaskMv, 40); - - material.SetInt(AlphaCutoffEnable, 0); - material.SetInt(TransparentDepthPrepassEnable, 1); - material.SetInt(SurfaceType, 1); - material.SetInt(BlendMode, 4); - material.SetInt(DstBlend, 10); - material.SetInt(AlphaDstBlend, 10); - material.SetInt(ZWrite, 0); - material.SetInt(ZTestDepthEqualForOpaque, 4); - material.SetInt(ZTestGBuffer, 4); - - material.SetShaderPassEnabled("TransparentDepthPrepass", true); - material.SetShaderPassEnabled("RayTracingPrepass", false); - - material.renderQueue = (int) RenderQueue.Transparent; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/JurassicPark.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/JurassicPark.cs.meta deleted file mode 100644 index 370f0711d..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/JurassicPark.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 661c4a2680951c14eba3745af844f077 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Mississippi.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Mississippi.cs deleted file mode 100644 index 1bd911a93..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Mississippi.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; -using VisualPinball.Unity.Editor; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Mississipi", AuthorName = "jpsalas, akiles50000, Loserman")] - public class Mississippi : TablePatcher - { - [NameMatch("lrail1", Ref = "Playfield/Ramps/lrail1/LeftWall")] // left outside wall to the left - [NameMatch("rrail1", Ref = "Playfield/Ramps/rrail1/LeftWall")] // left inside wall to the right - public void SetDoubleSided(GameObject gameObject, ref GameObject child) - { - if (gameObject == child) - RenderPipelineConverter.Current.MaterialAdapter.SetDoubleSided(gameObject); - } - - /// - /// Activate depth prepass or else the image visibility changes depending on distance - /// - /// - /// - [NameMatch("wall13", Ref = "Playfield/Walls/wall13/Top")] - [NameMatch("wall14", Ref = "Playfield/Walls/wall14/Top")] - [NameMatch("wall15", Ref = "Playfield/Walls/wall15/Top")] - [NameMatch("wall18", Ref = "Playfield/Walls/wall18/Top")] - [NameMatch("wall19", Ref = "Playfield/Walls/wall19/Top")] - [NameMatch("wall22", Ref = "Playfield/Walls/wall22/Top")] - [NameMatch("wall23", Ref = "Playfield/Walls/wall23/Top")] - [NameMatch("wall359", Ref = "Playfield/Walls/wall359/Top")] - [NameMatch("apron", Ref = "Playfield/Walls/apron/Top")] - public void SetTransparentDepthPrepassEnabled(GameObject gameObject, ref GameObject child) - { - if (gameObject == child) - { - RenderPipelineConverter.Current.MaterialAdapter.SetTransparentDepthPrepassEnabled(gameObject); - } - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Mississippi.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Mississippi.cs.meta deleted file mode 100644 index c0d64e9cc..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Mississippi.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe1e47b630735fc4c8fc80dbe2e65b3a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Rock.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Rock.cs deleted file mode 100644 index 2f87e1c91..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Rock.cs +++ /dev/null @@ -1,482 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global -// ReSharper disable UnusedType.Global - -using System.Linq; -using System.Text.RegularExpressions; -using UnityEditor; -using UnityEngine; -using VisualPinball.Engine.Math; -using VisualPinball.Engine.VPT; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Rock", AuthorName = "jpsalas")] - public class Rock : TablePatcher - { - #region Global - - public override void PostPatch(GameObject tableGo) - { - var playfieldGo = Playfield(tableGo); - playfieldGo.isStatic = true; - - SetupLights(tableGo, playfieldGo); - - SetupFlippers(playfieldGo); - SetupDropTargetBanks(tableGo, playfieldGo); - SetupTrough(tableGo, playfieldGo); - - SetupCollisionSwitch(playfieldGo.transform.Find("Walls/sw41a").gameObject); - SetupCollisionSwitch(playfieldGo.transform.Find("Walls/sw41b").gameObject); - SetupCollisionSwitch(playfieldGo.transform.Find("Walls/sw41c").gameObject); - SetupCollisionSwitch(playfieldGo.transform.Find("Walls/sw41d").gameObject); - SetupCollisionSwitch(playfieldGo.transform.Find("Walls/sw41e").gameObject); - SetupCollisionSwitch(playfieldGo.transform.Find("Walls/sw41f").gameObject); - - SetupLeftSlingshot(playfieldGo.transform.Find("Walls/LeftSlingshot").gameObject); - SetupRightSlingshot(playfieldGo.transform.Find("Walls/RightSlingshot").gameObject); - - SetupPinMame(tableGo, playfieldGo); - SetupDisplays(tableGo); - } - - private static void SetupLights(GameObject tableGo, GameObject playfieldGo) - { - var displayRegEx = new Regex("^[a-c][0-9a-f][0-9a-f]$"); - - foreach (var child in playfieldGo.transform.Find("Lights").gameObject.transform.Cast().ToList()) { - var go = child.gameObject; - - if (displayRegEx.Match(go.name).Success) { - Object.DestroyImmediate(go); - } - else { - var lc = go.GetComponentInParent(); - - if (lc != null) { - lc.FadeSpeedUp = .2f; - lc.FadeSpeedDown = .1f; - - PrefabUtility.RecordPrefabInstancePropertyModifications(lc); - } - } - } - - var lightGroups = CreateEmptyGameObject(playfieldGo, "Light Groups"); - - AddLightGroup(tableGo, CreateEmptyGameObject(lightGroups, "UpperLeft1"), - "gi26", "gi28", "gi25", "gi23"); - - AddLightGroup(tableGo, CreateEmptyGameObject(lightGroups, "UpperLeft2"), - "gi27", "gi24", "gi22"); - - AddLightGroup(tableGo, CreateEmptyGameObject(lightGroups, "UpperRight"), - "gi30", "gi31", "gi14", "gi29", "gi4", "gi2", "gi7", "gi9", "gi21", - "gi20", "gi19", "gi18", "gi17", "gi16", "gi15", "gi13", "gi12", "gi11"); - - AddLightGroup(tableGo, CreateEmptyGameObject(lightGroups, "Lower"), - "gi6", "gi10"); - - AddLightGroup(tableGo, CreateEmptyGameObject(lightGroups, "Auxiliary"), - "AL1a", "AL1b", "AL2a", "AL2b", "AL3a", "AL3b", "AL4a", "AL4b", - "AL5a", "AL5b", "AL6a", "AL6b", "AL7a", "AL7b", "AL8a", "AL8b", - "AL9a", "AL9a", "AL10a", "AL10a"); - } - - private static void SetupFlippers(GameObject playfieldGo) - { - var flipper = playfieldGo.transform.Find("Flippers/LeftFlipper1").gameObject; - flipper.name = "LowerLeftFlipper"; - - flipper = playfieldGo.transform.Find("Flippers/RightFlipper1").gameObject; - flipper.name = "LowerRightFlipper"; - - flipper = playfieldGo.transform.Find("Flippers/LeftFlipper5").gameObject; - flipper.name = "UpperLeftFlipper"; - - flipper = playfieldGo.transform.Find("Flippers/RightFlipper5").gameObject; - flipper.name = "UpperRightFlipper"; - } - - private static void SetupDropTargetBanks(GameObject tableGo, GameObject playfieldGo) - { - CreateDropTargetBank(tableGo, playfieldGo, "4PosBankUpper", - new string[] { "sw40", "sw50", "sw60", "sw70" }); - - CreateDropTargetBank(tableGo, playfieldGo, "5PosBankLower", - new string[] { "sw51", "sw61", "sw71", "sw62", "sw72" }); - } - - private static void SetupTrough(GameObject tableGo, GameObject playfieldGo) - { - var troughComponent = CreateTrough(tableGo, playfieldGo); - troughComponent.Type = TroughType.ClassicSingleBall; - troughComponent.BallCount = 1; - troughComponent.SwitchCount = 1; - troughComponent.KickTime = 100; - troughComponent.RollTime = 300; - } - - private static void SetupCollisionSwitch(GameObject go) - { - go.AddComponent(); - } - - private static void SetupLeftSlingshot(GameObject go) - { - var playfieldGo = go.GetComponentInParent().gameObject; - var ssParentGo = GetOrCreateGameObject(playfieldGo, "Slingshots"); - - var ssGo = PrefabUtility.InstantiatePrefab(SlingshotComponent.LoadPrefab(), ssParentGo.transform) as GameObject; - var ss = ssGo!.GetComponent(); - - ss.name = "Left Slingshot"; - ss.SlingshotSurface = go.GetComponent(); - ss.RubberOff = playfieldGo.transform.Find("Rubbers/LeftSling1").GetComponent(); - ss.RubberOn = playfieldGo.transform.Find("Rubbers/LeftSling4").GetComponent(); - ss.CoilArm = playfieldGo.transform.Find("Primitives/Lemk").gameObject; - ss.CoilArmEndAngle = 22f; - - EditorUtility.SetDirty(ssGo); - PrefabUtility.RecordPrefabInstancePropertyModifications(ss); - - ss.RebuildMeshes(); - } - - private static void SetupRightSlingshot(GameObject go) - { - var playfieldGo = go.GetComponentInParent().gameObject; - var ssParentGo = GetOrCreateGameObject(playfieldGo, "Slingshots"); - - var ssGo = PrefabUtility.InstantiatePrefab(SlingshotComponent.LoadPrefab(), ssParentGo.transform) as GameObject; - var ss = ssGo!.GetComponent(); - - ss.name = "Right Slingshot"; - ss.SlingshotSurface = go.GetComponent(); - ss.RubberOff = playfieldGo.transform.Find("Rubbers/RightSling1").GetComponent(); - ss.RubberOn = playfieldGo.transform.Find("Rubbers/RightSling3").GetComponent(); - ss.CoilArm = playfieldGo.transform.Find("Primitives/Remk").gameObject; - ss.CoilArmEndAngle = 22f; - - EditorUtility.SetDirty(ssGo); - PrefabUtility.RecordPrefabInstancePropertyModifications(ss); - - ss.RebuildMeshes(); - } - - private static void SetupPinMame(GameObject tableGo, GameObject playfieldGo) - { -#if !NO_PINMAME - var tableComponent = tableGo.GetComponent(); - - // GLE - Object.DestroyImmediate(tableGo.GetComponent()); - var pinmameGle = tableGo.AddComponent(); - pinmameGle.Game = new Engine.PinMAME.Games.Rock(); - pinmameGle.romId = "rock"; - pinmameGle.DisableMechs = true; - pinmameGle.SolenoidDelay = 1000; - tableComponent.RepopulateHardware(pinmameGle); - TableSelector.Instance.TableUpdated(); -#endif - } - - private static void SetupDisplays(GameObject tableGo) - { - const float scale = 0.5f; - var cabinetGo = tableGo.transform.Find("Cabinet").gameObject; - var go = new GameObject - { - name = "Segment Display [0]", - transform = { - localEulerAngles = new Vector3(0, 0, 0), - localPosition = new Vector3(0, 0.31f, 1.1f), - localScale = new Vector3(scale, scale, scale) - } - }; - go.transform.SetParent(cabinetGo.transform, false); - - var segment = go.AddComponent(); - segment.Id = "display0"; - segment.SegmentTypeName = "Seg16"; - segment.NumSegments = 14; - segment.SeparatorType = 2; - segment.NumChars = 20; - segment.LitColor = new UnityEngine.Color(0, 0.87f, 0.87f); - segment.Emission = 3; - - go = new GameObject - { - name = "Segment Display [1]", - transform = { - localEulerAngles = new Vector3(0, 0, 0), - localPosition = new Vector3(0, 0.21f, 1.1f), - localScale = new Vector3(scale, scale, scale) - } - }; - go.transform.SetParent(cabinetGo.transform, false); - - segment = go.AddComponent(); - segment.Id = "display1"; - segment.SegmentTypeName = "Seg16"; - segment.NumSegments = 14; - segment.SeparatorType = 2; - segment.NumChars = 20; - segment.LitColor = new UnityEngine.Color(0, 0.87f, 0.87f); - segment.Emission = 3; - } - - #endregion - - [NameMatch("LeftFlipper2", Ref = "Playfield/Flippers/LeftFlipper1")] - [NameMatch("LeftFlipper3", Ref = "Playfield/Flippers/LeftFlipper1")] - [NameMatch("LeftFlipper4", Ref = "Playfield/Flippers/LeftFlipper1")] - [NameMatch("RightFlipper2", Ref = "Playfield/Flippers/RightFlipper1")] - [NameMatch("RightFlipper3", Ref = "Playfield/Flippers/RightFlipper1")] - [NameMatch("RightFlipper4", Ref = "Playfield/Flippers/RightFlipper1")] - public void ReparentFlipper(FlipperComponent flipper, GameObject go, ref GameObject parent) - { - PatcherUtil.Reparent(go, parent); - PatcherUtil.Hide(go.GetComponentInChildren().gameObject); - - flipper.Position = Vector2.zero; - flipper.StartAngle = 0; - } - - [NameMatch("sw40")] - [NameMatch("sw50")] - [NameMatch("sw60")] - [NameMatch("sw70")] - public void FixUpperDropTargetTexture(GameObject go) - { - var renderer = go.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("DropTargetSimple_rock-red"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("sw51")] - [NameMatch("sw61")] - [NameMatch("sw71")] - [NameMatch("sw62")] - [NameMatch("sw72")] - public void FixLowerDropTargetTexture(GameObject go) - { - var renderer = go.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("DropTargetSimple_rock-black"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("sw52")] - public void FixTargetTexture(GameObject go) - { - var renderer = go.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("target1-rock"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("sw45")] - [NameMatch("sw75")] - public void FixSpinnerTexture(GameObject go) - { - var plate = go.transform.Find("Plate").gameObject; - var renderer = plate.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("spinner_gottlieb"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("Gate4", Ref = "Playfield/Spinners/sw45")] - [NameMatch("Gate5", Ref = "Playfield/Spinners/sw45")] - public void FixGateBracketMaterial(GameObject go, ref GameObject spinnerGo) - { - var gateBracket = go.transform.Find("Bracket").gameObject; - var spinnerBracket = spinnerGo.transform.Find("Bracket").gameObject; - - // Use spinner bracket material set gate bracket material not found - gateBracket.GetComponent().sharedMaterial = spinnerBracket.GetComponent().sharedMaterial; - } - - [NameMatch("LeftSling2")] - [NameMatch("LeftSling3")] - [NameMatch("RightSling2")] - [NameMatch("RightSling3")] - public void DisableObsoleteSlingshotElements(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("LeftSling1")] - public void AddLeftSlingshotDragPoints(RubberComponent rubberComponent) - { - var dp = rubberComponent.DragPoints.ToList(); - dp.Insert(13, new DragPointData(219.8f, 1342.7f)); - dp.Insert(14, new DragPointData(209.1f, 1305.8f)); - rubberComponent.DragPoints = dp.ToArray(); - } - - [NameMatch("RightSling1")] - public void AddRightSlingshotDragPoints(RubberComponent rubberComponent) - { - var dp = rubberComponent.DragPoints.ToList(); - dp.Insert(8, new DragPointData(657.1f, 1308.5f)); - dp.Insert(9, new DragPointData(648.8f, 1338.4f)); - rubberComponent.DragPoints = dp.ToArray(); - } - - [NameMatch("L0")] - [NameMatch("L1")] - [NameMatch("L2")] - [NameMatch("L4")] - [NameMatch("gi5")] - [NameMatch("gi1")] - [NameMatch("gi3")] - [NameMatch("gi8")] - public void DisableLights(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("gi14")] - public void FixGI14(GameObject go) - { - go.GetComponent().transform.localPosition = new Vector3(894.29f, 178.4f); - } - - [NameMatch("gi2")] - [NameMatch("gi4")] - [NameMatch("gi6")] - [NameMatch("gi7")] - [NameMatch("gi9")] - [NameMatch("gi10")] - [NameMatch("gi11")] - [NameMatch("gi12")] - [NameMatch("gi13")] - [NameMatch("gi14")] - [NameMatch("gi15")] - [NameMatch("gi16")] - [NameMatch("gi17")] - [NameMatch("gi18")] - [NameMatch("gi19")] - [NameMatch("gi20")] - [NameMatch("gi21")] - [NameMatch("gi23")] - [NameMatch("gi25")] - [NameMatch("gi26")] - [NameMatch("gi28")] - [NameMatch("gi29")] - [NameMatch("gi30")] - [NameMatch("gi31")] - [NameMatch("gi22")] - [NameMatch("gi24")] - [NameMatch("gi27")] - public void FixGIs(GameObject go) - { - LightTemperature(go, 2700f); - LightIntensity(go, 120f); - } - - [NameMatch("L3")] - [NameMatch("L5")] - [NameMatch("L6")] - [NameMatch("L7")] - [NameMatch("L8")] - [NameMatch("L9")] - [NameMatch("L10")] - [NameMatch("L11")] - [NameMatch("L12")] - [NameMatch("L13a")] - [NameMatch("L13b")] - [NameMatch("L14")] - [NameMatch("L15")] - [NameMatch("L16")] - [NameMatch("L17")] - [NameMatch("L18")] - [NameMatch("L19")] - [NameMatch("L20")] - [NameMatch("L21")] - [NameMatch("L22")] - [NameMatch("L23")] - [NameMatch("L24")] - [NameMatch("L25")] - [NameMatch("L26")] - [NameMatch("L27")] - [NameMatch("L28")] - [NameMatch("L29")] - [NameMatch("L30")] - [NameMatch("L31")] - [NameMatch("L32")] - [NameMatch("L33")] - [NameMatch("L34")] - [NameMatch("L35")] - [NameMatch("L36")] - [NameMatch("L37")] - [NameMatch("L38")] - [NameMatch("L39")] - [NameMatch("L40")] - [NameMatch("L41")] - [NameMatch("L42")] - [NameMatch("L43")] - [NameMatch("L44")] - [NameMatch("L45")] - [NameMatch("L46")] - [NameMatch("L47a")] - [NameMatch("L47b")] - [NameMatch("L51a")] - [NameMatch("L51b")] - public void FixLights(GameObject go) - { - LightTemperature(go, 2700f); - LightIntensity(go, 50f); - } - - [NameMatch("AL1a")] - [NameMatch("AL1b")] - [NameMatch("AL2a")] - [NameMatch("AL2b")] - [NameMatch("AL3a")] - [NameMatch("AL3b")] - [NameMatch("AL4a")] - [NameMatch("AL4b")] - [NameMatch("AL5a")] - [NameMatch("AL5b")] - [NameMatch("AL6a")] - [NameMatch("AL6b")] - [NameMatch("AL7a")] - [NameMatch("AL7b")] - [NameMatch("AL8a")] - [NameMatch("AL8b")] - [NameMatch("AL9a")] - [NameMatch("AL10a")] - public void FixAuxiliaryLights(GameObject go) - { - LightTemperature(go, 5500f); - LightColor(go, UnityEngine.Color.white); - LightIntensity(go, 175f); - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Rock.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Rock.cs.meta deleted file mode 100644 index e75a42c58..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Rock.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7ad1e1403cf484e69bb0b81423e75c53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Terminator2.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Terminator2.cs deleted file mode 100644 index 0be3774c2..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Terminator2.cs +++ /dev/null @@ -1,988 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global -// ReSharper disable UnusedType.Global - -using System.Linq; -using UnityEditor; -using UnityEngine; -using VisualPinball.Engine.Math; -using VisualPinball.Engine.VPT; -using Color = UnityEngine.Color; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Terminator 2 - Judgment Day (Williams 1991)", AuthorName = "g5k")] - public class Terminator2 : TablePatcher - { - #region Global - - public override void PostPatch(GameObject tableGo) - { - var playfieldGo = Playfield(tableGo); - playfieldGo.isStatic = true; - - // playfield material - RenderPipeline.Current.MaterialConverter.SetSmoothness(playfieldGo.GetComponent().sharedMaterial, 0.96f); - - // missing lights - CreateFlasher28(playfieldGo); - - SetupTrough(tableGo, playfieldGo); - SetupPinMame(tableGo, playfieldGo); - SetupDmd(tableGo); - SetupMapping(tableGo); - - // slingshots - SetupLeftSlingshot(playfieldGo.transform.Find("Walls/LeftSlingshot").gameObject); - SetupRightSlingshot(playfieldGo.transform.Find("Walls/RightSlingshot").gameObject); - } - - private static void SetupTrough(GameObject tableGo, GameObject playfieldGo) - { - var troughComponent = CreateTrough(tableGo, playfieldGo); - troughComponent.Type = TroughType.TwoCoilsNSwitches; - troughComponent.BallCount = 3; - troughComponent.SwitchCount = 3; - troughComponent.JamSwitch = false; - troughComponent.RollTime = 300; - } - - private static void SetupPinMame(GameObject tableGo, GameObject playfieldGo) - { - #if !NO_PINMAME - var tableComponent = tableGo.GetComponent(); - - // GLE - Object.DestroyImmediate(tableGo.GetComponent()); - var pinmameGle = tableGo.AddComponent(); - pinmameGle.Game = new Engine.PinMAME.Games.Terminator2(); - pinmameGle.romId = "t2_l82"; - tableComponent.RepopulateHardware(pinmameGle); - TableSelector.Instance.TableUpdated(); - - // create GI light groups - var gi = CreateEmptyGameObject(playfieldGo, "GI"); - var gi1 = CreateEmptyGameObject(gi, "CPU"); - var gi2 = CreateEmptyGameObject(gi, "Left Playfield"); - var gi3 = CreateEmptyGameObject(gi, "Right Playfield"); - var giCpu = AddLightGroup(tableGo, gi1, "Light2", "Light3", "Light4", "Light5"); - var giLeftPlayfield = AddLightGroup(tableGo, gi2, "GI_35", "GI_1", "GI_3", "GI_4", "GI_12", "GI_7", - "GI_8", "GI_9", "GI_13", "GI_14", "GI_23", "GI_24", "GI_25", "GI_38"); - var giRightPlayfield = AddLightGroup(tableGo, gi3, "GI_36", "GI_2", "GI_5", "GI_6", "GI_10", "GI_11", "GI_15", "GI_16", "GI_18", "GI_19", "GI_17", - "GI_20", "GI_21", "GI_22", "GI_26", "GI_27", "GI_28", "GI_30", "GI_29", "GI_31", "GI_32", "GI_33", "GI_34", "GI_37", "B1", "B2", "B3"); - - // map GI light groups - tableComponent.MappingConfig.Lamps.First(lm => lm.Id == "2").Device = giRightPlayfield; - tableComponent.MappingConfig.Lamps.First(lm => lm.Id == "3").Device = giCpu; - tableComponent.MappingConfig.Lamps.First(lm => lm.Id == "4").Device = giLeftPlayfield; - #endif - } - - private static void SetupMapping(GameObject tableGo) - { - var tc = tableGo.GetComponent(); - - var kickers = tableGo.GetComponentsInChildren(); - foreach (var kicker in kickers) { - - // shooter - LinkSwitch(tc, "sw78", "78", kicker); - LinkCoil(tc, "sw78", "09", kicker); - - // top lock - LinkCoil(tc, "sw55", "10", kicker); - - // left lock - LinkCoil(tc, "sw51", "16", kicker); - - // cannon - LinkCoil(tc, "sw31", "02", kicker); - } - - var plungers = tableGo.GetComponentsInChildren(); - foreach (var plunger in plungers) { - // kickback - LinkCoil(tc, "Plunger1", "08", plunger, PlungerComponent.FireCoilId); - } - - var teleporters = tableGo.GetComponentsInChildren(); - foreach (var teleporter in teleporters) { - - // skull kicker - LinkCoil(tc, "sw76", "01", teleporter, TeleporterComponent.CoilItem); - } - - var bumpers = tableGo.GetComponentsInChildren(); - foreach (var bumper in bumpers) { - LinkSwitch(tc, "Bumper1", "41", bumper); - LinkSwitch(tc, "Bumper2", "43", bumper); - LinkSwitch(tc, "Bumper3", "42", bumper); - } - - // cannon - var cannonGo = tc.transform.Find("Playfield/Mechs/Cannon").gameObject; - var cannonMech = cannonGo.GetComponent(); - LinkSwitch(tc, "32", cannonMech, "gun_mark_switch"); - LinkSwitch(tc, "33", cannonMech, "gun_home_switch"); - LinkCoil(tc, "11", cannonMech); - } - - private static void SetupDmd(GameObject tableGo) - { - const float scale = 0.43f; - var cabinetGo = tableGo.transform.Find("Cabinet").gameObject; - var go = new GameObject { - name = "Dot Matrix Display", - transform = { - localEulerAngles = new Vector3(5.963f, 0, 0), - localPosition = new Vector3(0f, 0.513f, 1.0329f), - localScale = new Vector3(scale, scale, scale) - } - }; - go.transform.SetParent(cabinetGo.transform, false); - - var dmd = go.AddComponent(); - dmd.UpdateDimensions(128, 32); - dmd.Emission = 100f; - } - - #endregion - - #region Geometry - - [NameMatch("_Apron")] - [NameMatch("_BackWall")] - [NameMatch("_Bulbs (GI - visible)")] - [NameMatch("_ChromeRails")] - [NameMatch("_ClearPlastics")] - [NameMatch("_CliffyPosts")] - [NameMatch("_HKShip")] - [NameMatch("_LeftOVerBits")] - [NameMatch("_LeftRampMetal")] - [NameMatch("_MetalPosts")] - [NameMatch("_Plastics")] - [NameMatch("_Posts")] - [NameMatch("_RedPlastics")] - [NameMatch("_RightRampPlastic")] - [NameMatch("_Rubbers")] - [NameMatch("_Screws")] - [NameMatch("_StarPosts")] - [NameMatch("_SteelBits")] - [NameMatch("_SteelWalls")] - [NameMatch("_Switches")] - [NameMatch("_Timber")] - [NameMatch("_Washers")] - [NameMatch("_WireSwitches")] - [NameMatch("_Wireforms")] - [NameMatch("_popbumperassy")] - [NameMatch("_wires")] - public void MakeStatic(GameObject go) - { - go.isStatic = true; - } - - [NameMatch("RubberPostPrim001")] - [NameMatch("RubberPostPrim002")] - [NameMatch("RubberPostPrim003")] - [NameMatch("RubberPostPrim004")] - [NameMatch("RubberPostPrim005")] - [NameMatch("RubberPostPrim006")] - [NameMatch("RubberPostPrim007")] - [NameMatch("RubberPostPrim008")] - [NameMatch("RubberPostPrim009")] - [NameMatch("RubberPostPrim010")] - [NameMatch("RubberPostPrim011")] - [NameMatch("RubberPostPrim012")] - [NameMatch("RubberPostPrim013")] - [NameMatch("RubberPostPrim014")] - [NameMatch("RubberPostPrim015")] - [NameMatch("RubberPostPrim016")] - public void PrimitiveCollider(GameObject go) - { - go.isStatic = true; - Object.DestroyImmediate(go.GetComponent()); - Object.DestroyImmediate(go.GetComponent()); - Object.DestroyImmediate(go.GetComponent()); - } - - [NameMatch("EndPointLp")] - [NameMatch("EndPointRp")] - [NameMatch("batleftshadow")] - [NameMatch("batrightshadow")] - [NameMatch("FlasherT1")] - [NameMatch("FlasherT2")] - public void Disable(GameObject go) - { - go.SetActive(false); - } - - - [NameMatch("Wall002")] - [NameMatch("Wall003")] - public void InvisibleWall(GameObject go) - { - foreach (var mr in go.GetComponentsInChildren()) { - mr.gameObject.SetActive(false); - } - } - - #endregion - - #region Flippers - - [NameMatch("batleft", Ref = "Playfield/Flippers/LeftFlipper")] - [NameMatch("batright", Ref = "Playfield/Flippers/RightFlipper")] - public void ReparentFlippers(PrimitiveComponent flipper, GameObject gameObject, ref GameObject parent) - { - PatcherUtil.Reparent(gameObject, parent); - - flipper.Position = Vector2.zero; - // flipper.ObjectRotation.z = 0; - } - - [NameMatch("LeftFlipper")] - [NameMatch("RightFlipper")] - public void DeleteFlipperMeshes(GameObject go) - { - go.GetComponentInChildren().gameObject.SetActive(false); - go.GetComponentInChildren().gameObject.SetActive(false); - } - - #endregion - - #region Slingshots - - [NameMatch("LSling2")] - [NameMatch("RSling2")] - [NameMatch("_SteelBits")] - public void DisableObsoleteSlingshotElements(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("LSling")] - public void AddLeftSlingshotDragPoints(RubberComponent rubberComponent) - { - var dp = rubberComponent.DragPoints.ToList(); - dp.RemoveAt(9); - dp.RemoveAt(10); - dp.Insert(9, new DragPointData(208.9f, 1597.3f)); - dp.Insert(10, new DragPointData(202.9f, 1580.6f)); - rubberComponent.DragPoints = dp.ToArray(); - } - - [NameMatch("RSling")] - public void AddRightSlingshotDragPoints(RubberComponent rubberComponent) - { - var dp = rubberComponent.DragPoints.ToList(); - dp.RemoveAt(4); - dp.RemoveAt(5); - dp.Insert(4, new DragPointData(661.6f, 1583f)); - dp.Insert(5, new DragPointData(657f, 1595.7f)); - rubberComponent.DragPoints = dp.ToArray(); - } - - [NameMatch("SLING1")] - [NameMatch("SLING2")] - public void EnableSlingshotArm(GameObject go) - { - go.GetComponent().enabled = true; - } - - private static void SetupLeftSlingshot(GameObject go) - { - var playfieldGo = go.GetComponentInParent().gameObject; - var ssParentGo = GetOrCreateGameObject(playfieldGo, "Slingshots"); - - var ssGo = PrefabUtility.InstantiatePrefab(SlingshotComponent.LoadPrefab(), ssParentGo.transform) as GameObject; - var ss = ssGo!.GetComponent(); - - ss.name = "Left Slingshot"; - ss.SlingshotSurface = go.GetComponent(); - ss.RubberOff = playfieldGo.transform.Find("Rubbers/LSling").GetComponent(); - ss.RubberOn = playfieldGo.transform.Find("Rubbers/LSling1").GetComponent(); - //ss.CoilArm = playfieldGo.transform.Find("Primitives/SLING2").GetComponent(); - - EditorUtility.SetDirty(ssGo); - PrefabUtility.RecordPrefabInstancePropertyModifications(ss); - - ss.RebuildMeshes(); - } - - private static void SetupRightSlingshot(GameObject go) - { - var playfieldGo = go.GetComponentInParent().gameObject; - var ssParentGo = GetOrCreateGameObject(playfieldGo, "Slingshots"); - - var ssGo = PrefabUtility.InstantiatePrefab(SlingshotComponent.LoadPrefab(), ssParentGo.transform) as GameObject; - var ss = ssGo!.GetComponent(); - - ss.name = "Right Slingshot"; - ss.SlingshotSurface = go.GetComponent(); - ss.RubberOff = playfieldGo.transform.Find("Rubbers/RSling").GetComponent(); - ss.RubberOn = playfieldGo.transform.Find("Rubbers/RSling1").GetComponent(); - //ss.CoilArm = playfieldGo.transform.Find("Primitives/SLING1").GetComponent(); - - EditorUtility.SetDirty(ssGo); - PrefabUtility.RecordPrefabInstancePropertyModifications(ss); - - ss.RebuildMeshes(); - } - - #endregion - - #region Kickers - - [NameMatch("BallRelease")] - public void FixSw17(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Name = "Eject"; - kickerComponent.Coils[0].Speed = 5; - kickerComponent.Coils[0].Angle = 60; - } - - [NameMatch("sw78")] - public void Shooter(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Name = "Shooter"; - kickerComponent.Coils[0].Speed = 50; - kickerComponent.Coils[0].Angle = 0; - } - - [NameMatch("sw76")] - public void SkullKicker(KickerComponent kickerComponent) - { - kickerComponent.Coils.Clear(); - var tp = kickerComponent.gameObject.AddComponent(); - tp.FromKicker = kickerComponent; - tp.ToKicker = FindSiblingComponent(kickerComponent, "sw76a"); - tp.ToKickerItem = tp.ToKicker.AvailableCoils.First().Id; - tp.EjectDelay = 0; - tp.EjectAfterTeleportation = true; - } - - [NameMatch("sw76a")] - public void Teleporter(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Name = "Teleporter Out"; - kickerComponent.Coils[0].Speed = 3; - kickerComponent.Coils[0].Angle = 72; - } - - [NameMatch("sw55")] - public void TopLock(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Name = "Kick Out"; - kickerComponent.Coils[0].Speed = 5; - kickerComponent.Coils[0].Angle = 270; - } - - [NameMatch("sw51")] - public void LeftLock(KickerComponent kickerComponent) - { - kickerComponent.Coils[0].Name = "Kick Out"; - kickerComponent.Coils[0].Speed = 13; - kickerComponent.Coils[0].Angle = 160; - } - - #endregion - - #region Mechs - - [NameMatch("sw77")] - public void CreateDropTargetBank(GameObject dropTargetGo, DropTargetComponent dropTargetComponent) - { - var dropTargetBank = dropTargetGo.AddComponent(); - dropTargetBank.BankSize = 1; - dropTargetBank.DropTargets = new[] { dropTargetComponent }; - } - - [NameMatch("T2_Gun")] - public void SetupCannon(GameObject primitiveGo, PrimitiveComponent cannonComp) - { - var playfieldGo = primitiveGo.GetComponentInParent().gameObject; - var mechsParent = GetOrCreateGameObject(playfieldGo, "Mechs"); - - var rotatorGo = CreateEmptyGameObject(mechsParent, "Cannon"); - var rotatorComp = rotatorGo.AddComponent(); - var mechComp = rotatorGo.AddComponent(); - //mechComp.Target = rotatorComp; - mechComp.NumSteps = 240; - mechComp.Marks = new[] { - new MechMark(MechMarkSwitchType.EnableBetween, "Gun Home", "gun_home_switch", 0, 5), - new MechMark(MechMarkSwitchType.EnableBetween, "Gun Mark", "gun_mark_switch", 98, 105), - }; - - //rotatorComp.Target = cannonComp; - rotatorComp.RotateWith = new IRotatableComponent[] { - playfieldGo.transform.Find("Kickers/sw31").GetComponent(), - }; - } - - #endregion - - #region Materials - - [NameMatch("_Plastics")] - [NameMatch("_RedPlastics")] - [NameMatch("_RightRampPlastic")] - [NameMatch("_StarPosts")] - public void FixTranslucentMaterials(GameObject go) - { - var material = go.GetComponent().sharedMaterial; - RenderPipeline.Current.MaterialConverter.SetDiffusionProfile(material, DiffusionProfileTemplate.Plastics); - RenderPipeline.Current.MaterialConverter.SetMaterialType(material, MaterialType.Translucent); - } - - [NameMatch("Cab_DT")] - [NameMatch("L52")] - [NameMatch("LSling")] - [NameMatch("Rubber2")] - [NameMatch("Rubber7")] - [NameMatch("SLING1")] - [NameMatch("T2_Gun")] - [NameMatch("_Apron")] - [NameMatch("_ChromeRails")] - [NameMatch("_CliffyPosts")] - [NameMatch("_LeftRampMetal")] - [NameMatch("_MetalPosts")] - [NameMatch("_Rubbers")] - [NameMatch("_Screws")] - [NameMatch("_SteelWalls")] - [NameMatch("_Targets")] - [NameMatch("_Washers")] - [NameMatch("_Wireforms")] - [NameMatch("batleft")] - [NameMatch("batright")] - [NameMatch("sw53")] - public void FixSolidMaterials(GameObject go) - { - var material = go.GetComponent().sharedMaterial; - RenderPipeline.Current.MaterialConverter.SetMaterialType(material, MaterialType.Standard); - } - - [NameMatch("_HKShip")] - public void FixShip(GameObject go) - { - var material = go.GetComponent().sharedMaterial; - RenderPipeline.Current.MaterialConverter.SetMaterialType(material, MaterialType.Standard); - RenderPipeline.Current.MaterialConverter.SetSmoothness(material, 1f); - } - - #endregion - - #region Lights - - #region Flashers - - [NameMatch("F118", FloatParam = 10000f)] - [NameMatch("F119", FloatParam = 10000f)] - [NameMatch("F120", FloatParam = 10000f)] - [NameMatch("F121", FloatParam = 10000f)] - [NameMatch("F122", FloatParam = 20000f)] - [NameMatch("F123", FloatParam = 20000f)] - [NameMatch("F125", FloatParam = 10000f)] - [NameMatch("F126", FloatParam = 10000f)] - [NameMatch("F126a", FloatParam = 10000f)] - [NameMatch("F127", FloatParam = 10000f)] - [NameMatch("F127a", FloatParam = 10000f)] - public void FlasherIntensities(GameObject go, LightComponent lc, float param) - { - lc.FadeSpeedUp = 0f; - lc.FadeSpeedDown = 0.15f; - foreach (var l in go.GetComponentsInChildren()) { - RenderPipeline.Current.LightConverter.SetIntensity(l, param); - RenderPipeline.Current.LightConverter.SetTemperature(l, 3000); - RenderPipeline.Current.LightConverter.SetShadow(l, true, true, 0.001f); - } - } - - [NameMatch("F120")] - public void F120Pos(GameObject go) => LightPos(go, -160.8f, 17.6f, -6f); - [NameMatch("F121")] public void F121Pos(GameObject go) => LightPos(go, 0f, -12.5f, 15.7f); - [NameMatch("F122")] public void F122Pos(GameObject go) => LightPos(go, -4f, 97f, 25f); - [NameMatch("F123")] public void F123Pos(GameObject go) - { - LightPos(go, -6.9f, -21.9f, 94.1f); - LightRange(go, 0.3f); - } - [NameMatch("F125")] public void F125Pos(GameObject go) - { - LightPos(go, 42.5f, -75.8f, 12.8f); - LightRange(go, 0.17f); - } - [NameMatch("F126")] public void F126(GameObject go, LightComponent lightComponent) - { - LightPos(go, 51.6f, 34.5f, 5f); - LinkLights(go, lightComponent.name, "F126a"); - } - [NameMatch("F126a")] public void F126aPos(GameObject go) => LightPos(go, -28.1f, 61.1f, 37f); - - [NameMatch("F127")] public void F127(GameObject go, LightComponent lightComponent) - { - LightPos(go, -33.2f, 2.9f, 5f); - LinkLights(go, lightComponent.name, "F127a"); - } - [NameMatch("F127a")] public void F127aPos(GameObject go) => LightPos(go, -31.5f, 89.5f, 37f); - - private static void CreateFlasher28(GameObject playfieldGo) - { - var parent = GetOrCreateGameObject(playfieldGo, "Lights"); - var lightComponent = CreateLight("F128", 302.4f, 361.4f, parent); - var go = lightComponent.gameObject; - SpotAngle(go, 104f, 53.4f); - LightPos(go, 0, 0, -79f); - LightIntensity(go, 10000f); - LightTemperature(go, 3400f); - LightRange(go, 0.11f); - } - - #endregion - - #region Global Illumination - - [NameMatch("GI_1")] - [NameMatch("GI_2")] - [NameMatch("GI_3")] - [NameMatch("GI_4")] - [NameMatch("GI_5")] - [NameMatch("GI_6")] - [NameMatch("GI_7")] - [NameMatch("GI_8")] - [NameMatch("GI_9")] - [NameMatch("GI_10")] - [NameMatch("GI_11")] - [NameMatch("GI_12")] - [NameMatch("GI_13")] - [NameMatch("GI_14")] - [NameMatch("GI_15")] - [NameMatch("GI_16")] - [NameMatch("GI_17")] - [NameMatch("GI_18")] - [NameMatch("GI_19")] - [NameMatch("GI_20")] - [NameMatch("GI_21")] - [NameMatch("GI_22")] - [NameMatch("GI_23")] - [NameMatch("GI_24")] - [NameMatch("GI_25")] - [NameMatch("GI_26")] - [NameMatch("GI_27")] - [NameMatch("GI_28")] - [NameMatch("GI_29")] - [NameMatch("GI_30")] - [NameMatch("GI_31")] - [NameMatch("GI_32")] - [NameMatch("GI_33")] - [NameMatch("GI_34")] - [NameMatch("GI_35")] - [NameMatch("GI_36")] - [NameMatch("GI_37")] - [NameMatch("GI_38")] - public void GiIntensity(GameObject go) - { - foreach (var l in go.GetComponentsInChildren()) { - RenderPipeline.Current.LightConverter.SetIntensity(l, 200f); - RenderPipeline.Current.LightConverter.SetTemperature(l, 2700); - } - } - - [NameMatch("GI_3", FloatParam = 0.01f)] - [NameMatch("GI_4", FloatParam = 0.01f)] - [NameMatch("GI_5", FloatParam = 0.02f)] - [NameMatch("GI_6", FloatParam = 0.01f)] - - public void GiDynamicShadow(GameObject go, float param) => LightShadow(go, false, false, param); - - [NameMatch("GI_10", FloatParam = 0.01f)] - [NameMatch("GI_11", FloatParam = 0.01f)] - [NameMatch("GI_12", FloatParam = 0.01f)] - [NameMatch("GI_15", FloatParam = 0.02f)] - [NameMatch("GI_16", FloatParam = 0.02f)] - [NameMatch("GI_18", FloatParam = 0.01f)] - [NameMatch("GI_19", FloatParam = 0.02f)] - [NameMatch("GI_20", FloatParam = 0.02f)] - [NameMatch("GI_33", FloatParam = 0.02f)] - [NameMatch("GI_34", FloatParam = 0.02f)] - [NameMatch("GI_37", FloatParam = 0.01f)] - [NameMatch("GI_38", FloatParam = 0.01f)] - [NameMatch("GI_7", FloatParam = 0.01f)] // leaks - [NameMatch("GI_8", FloatParam = 0.01f)] // leaks - [NameMatch("GI_9", FloatParam = 0.01f)] // leaks - [NameMatch("GI_13", FloatParam = 0.01f)] // leaks - [NameMatch("GI_14", FloatParam = 0.01f)] // leaks - [NameMatch("GI_22", FloatParam = 0.01f)] // leaks - [NameMatch("GI_23", FloatParam = 0.01f)] // leaks - [NameMatch("GI_24", FloatParam = 0.01f)] // leaks (not too badly) - [NameMatch("GI_25", FloatParam = 0.01f)] // leaks (not too badly) - [NameMatch("GI_29", FloatParam = 0.01f)] // leaks - [NameMatch("GI_30", FloatParam = 0.01f)] // leaks - [NameMatch("GI_31", FloatParam = 0.01f)] // leaks - [NameMatch("GI_32", FloatParam = 0.01f)] // leaks - [NameMatch("GI_35", FloatParam = 0.01f)] // leaks (not too badly) - public void GiStaticShadow(GameObject go, float param) => LightShadow(go, false, false, param); - - [NameMatch("GI_27")] - [NameMatch("GI_28")] - public void GiDisable(GameObject go) => go.SetActive(false); - - [NameMatch("B1")] - [NameMatch("B2")] - [NameMatch("B3")] - public void Bumpers(GameObject go) - { - LightIntensity(go, 1000f); - LightTemperature(go, 2700f); - } - #endregion - - #region Insert Links - - [NameMatch("L22a")] public void Link22(GameObject go) => LinkLights(go, "L22a", "L22b"); - [NameMatch("L51a")] public void Link51(GameObject go) => LinkLights(go, "L51a", "L51b"); - - [NameMatch("L481")] - [NameMatch("L581")] - public void MakeInsert481(LightComponent lo) - { - var go = ConvertToInsertLight(lo); - // those don't actually need a light source, because the first light shines through the insert mesh. - go.transform.Find("Source").gameObject.SetActive(false); - } - - [NameMatch("L43")] - [NameMatch("L44")] - [NameMatch("L45")] - [NameMatch("L46")] - [NameMatch("L47")] - [NameMatch("L48")] - [NameMatch("L481")] - [NameMatch("L53")] - [NameMatch("L54")] - [NameMatch("L55")] - [NameMatch("L56")] - [NameMatch("L57")] - [NameMatch("L58")] - [NameMatch("L581")] - public void Rectangles(GameObject go) - { - SpotAngle(go, 122f, 48f); - LightIntensity(go, 4500f); - } - - [NameMatch("L16")] - [NameMatch("L22a")] - [NameMatch("L22b")] - [NameMatch("L23")] - [NameMatch("L24")] - public void MidSizedCircles(GameObject go) - { - SpotAngle(go, 64f, 67f); - LightIntensity(go, 1200f); - } - - [NameMatch("L76")] - [NameMatch("L77")] - [NameMatch("L78")] - public void SmallSizedCircles(GameObject go) - { - SpotAngle(go, 45f, 13f); - LightIntensity(go, 700f); - } - - [NameMatch("L61")] - [NameMatch("L62")] - [NameMatch("L63")] - [NameMatch("L64")] - [NameMatch("L65")] - [NameMatch("L71")] - [NameMatch("L72")] - [NameMatch("L73")] - [NameMatch("L74")] - [NameMatch("L75")] - public void InnerYellowCircles(GameObject go) - { - LightColor(go, Color.yellow); - } - - [NameMatch("L11")] - [NameMatch("L12")] - [NameMatch("L13")] - [NameMatch("L14")] - [NameMatch("L15")] - [NameMatch("L21")] - [NameMatch("L25")] - [NameMatch("L26")] - [NameMatch("L27")] - [NameMatch("L28")] - [NameMatch("L41")] - [NameMatch("L42")] - [NameMatch("L66")] - [NameMatch("L67")] - [NameMatch("L68")] - [NameMatch("L81")] - [NameMatch("L82")] - [NameMatch("L83")] - [NameMatch("L85")] - public void MidSizedTriangles(GameObject go) - { - SpotAngle(go, 96.4f, 47.8f); - } - - [NameMatch("L31")] - [NameMatch("L32")] - [NameMatch("L33")] - [NameMatch("L34")] - [NameMatch("L35")] - [NameMatch("L36")] - [NameMatch("L37")] - [NameMatch("L38")] - public void SmallSizedTriangles(GameObject go) - { - SpotAngle(go, 80f, 45f); - } - - [NameMatch("L36")] - [NameMatch("L37")] - [NameMatch("L38")] - public void SmallSizedTrianglesRed(GameObject go) - { - LightIntensity(go, 1000f); - } - - [NameMatch("L31")] - [NameMatch("L32")] - [NameMatch("L33")] - [NameMatch("L34")] - [NameMatch("L35")] - public void SmallSizedTrianglesWhite(GameObject go) - { - LightIntensity(go, 700f); - LightColor(go, Color.white); - } - - [NameMatch("L11")] - [NameMatch("L12")] - [NameMatch("L14")] - [NameMatch("L15")] - [NameMatch("L26")] - [NameMatch("L41")] - [NameMatch("L66")] - public void MidSizedTrianglesGreen(GameObject go) - { - LightIntensity(go, 3400f); - } - - [NameMatch("L13")] - [NameMatch("L21")] - [NameMatch("L27")] - [NameMatch("L81")] - [NameMatch("L82")] - public void MidSizedTrianglesRed(GameObject go) - { - LightIntensity(go, 1850f); - } - - [NameMatch("L85")] - public void MidSizedTrianglesWhite(GameObject go) - { - LightIntensity(go, 1850f); - LightColor(go, Color.white); - } - - [NameMatch("L28")] - public void MidSizedTrianglesBlue(GameObject go) - { - LightIntensity(go, 12000f); - LightColor(go, new Color(0f, 0.4f, 1)); - } - - [NameMatch("L25")] - [NameMatch("L42")] - [NameMatch("L67")] - public void MidSizedTrianglesYellow(GameObject go) - { - LightIntensity(go, 1850f); - LightColor(go, Color.yellow); - } - - #endregion - - #region Insert Positions - - [NameMatch("L11")] public void Insert2xPos(GameObject go) => LightPos(go, 28.6f, 9.6f, -50f); - [NameMatch("L12")] public void Insert4xPos(GameObject go) => LightPos(go, 22.4f, 25.1f, -50f); - [NameMatch("L13")] public void InsertHoldBonus(GameObject go) => LightPos(go, 0f, 35f, -50f); - [NameMatch("L14")] public void Insert6xPos(GameObject go) => LightPos(go, -24.7f, 25.1f, -50f); - [NameMatch("L15")] public void Insert8xPos(GameObject go) => LightPos(go, -31.3f, 10.7f, -50f); - [NameMatch("L16")] public void BallSave(GameObject go) => LightPos(go, 0, -19.6f, -50f); - - [NameMatch("L17")] - public void T2Mouth(GameObject go) - { - LightPos(go, 0f, 0f, -50f); - SpotAngle(go, 73f, 10f); - LightIntensity(go, 340f); - } - - [NameMatch("L21")] - public void Kickback(GameObject go) => LightPos(go, -3f, -13.5f, -50f); - - [NameMatch("L22a")] - [NameMatch("L22b")] - public void Special(GameObject go) => LightPos(go, 0, -15f, -50f); - - [NameMatch("L23")] - [NameMatch("L24")] - public void HurryUp(GameObject go) => LightPos(go, 0, -16f, -50f); - - [NameMatch("L25")] - [NameMatch("L26")] - [NameMatch("L27")] - [NameMatch("L28")] - [NameMatch("L85")] - public void LockLane(GameObject go) => LightPos(go, -6f, -35f, -50f); - - - [NameMatch("F117")] - public void AutoFire(GameObject go) - { - SpotAngle(go, 70f, 15f); - LightIntensity(go, 4000f); - - LightPos(go, -52f, 3.3f, -50f); - DuplicateLight(go, -18f, 0f, -50f); - DuplicateLight(go, 16f, 0f, -50f); - DuplicateLight(go, 52f, 3.3f, -50f); - } - - [NameMatch("L31")] - [NameMatch("L32")] - [NameMatch("L33")] - [NameMatch("L34")] - [NameMatch("L35")] - public void LeftSmallTriangles(GameObject go) => LightPos(go, -21f, -10f, -50f); - - [NameMatch("L36")] - [NameMatch("L37")] - [NameMatch("L38")] - public void TopSmallTriangles(GameObject go) => LightPos(go, 1.7f, -25f, -50f); - - [NameMatch("L41")] - [NameMatch("L42")] - public void LockVideo(GameObject go) => LightPos(go, -8.2f, -35f, -50f); - - [NameMatch("L43")] - [NameMatch("L44")] - [NameMatch("L45")] - [NameMatch("L46")] - [NameMatch("L47")] - public void LeftRedRect(GameObject go) => LightPos(go, -6.1f, -12.3f, -50f); - - [NameMatch("L48")] - public void LeftBottomRedRect(GameObject go) => LightPos(go, -2.4f, 16.6f, -50f); - - - [NameMatch("L51a")] - [NameMatch("L51b")] - public void T2Eyes(GameObject go) - { - LightPos(go, -2.2f, 0.8f, -50f); - SpotAngle(go, 27f, 60f); - LightIntensity(go, 1000f); - } - - [NameMatch("L53")] - [NameMatch("L54")] - [NameMatch("L55")] - [NameMatch("L56")] - [NameMatch("L57")] - public void RightRedRect(GameObject go) => LightPos(go, 8.5f, -11.7f, -50f); - [NameMatch("L58")] public void L58Pos(GameObject go) => LightPos(go, -2.3f, 20f, -50f); - - [NameMatch("L61")] - [NameMatch("L62")] - [NameMatch("L63")] - [NameMatch("L64")] - [NameMatch("L65")] - public void LeftYellowCircle(GameObject go) => LightPos(go, -4.3f, -18.2f, -50f); - - [NameMatch("L66")] - [NameMatch("L67")] - public void LeftOuterTriangles(GameObject go) => LightPos(go, -14f, -24f, -50f); - - [NameMatch("L68")] - public void Million(GameObject go) => LightPos(go, -6.6f, -31f, -50f); - - [NameMatch("L71")] - [NameMatch("L72")] - [NameMatch("L73")] - [NameMatch("L74")] - [NameMatch("L75")] - public void RightYellowCircle(GameObject go) => LightPos(go, 2.6f, -15.9f, -50f); - - [NameMatch("L76")] - [NameMatch("L77")] - [NameMatch("L78")] - public void LiteKickback(GameObject go) => LightPos(go, -10.6f, 0f, -50f); - - [NameMatch("L81")] public void L81(GameObject go) => LightPos(go, 15f, -40f, -50f); - [NameMatch("L82")] public void L82(GameObject go) => LightPos(go, 10f, -28f, -50f); - [NameMatch("L83")] public void L83(GameObject go) => LightPos(go, 13f, -37f, -50f); - - [NameMatch("L86")] - [NameMatch("L87")] - [NameMatch("L88")] - public void TopTriangles(GameObject go) - { - LightPos(go, 0f, 6f, -50f); - LightIntensity(go, 6700f); - SpotAngle(go, 80f, 40f); - } - - [NameMatch("Light2")] - [NameMatch("Light3")] - [NameMatch("Light4")] - [NameMatch("Light5")] - public void Boxes(GameObject go) - { - LightPos(go, 0f, -7, -50f); - PyramidAngle(go, 40f, 2.74f); - } - - [NameMatch("Light4")] - public void BlueBox(GameObject go) - { - LightIntensity(go, 12000f); - LightColor(go, new Color(0f, 0.4f, 1)); - } - - [NameMatch("Light5")] - public void YellowBox(GameObject go) - { - LightIntensity(go, 670f); - LightColor(go, Color.yellow); - } - - #endregion - - #endregion - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Terminator2.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Terminator2.cs.meta deleted file mode 100644 index 8fb88f390..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Terminator2.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f8e80a30d4b741d4286beae28e5edcc5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/TomAndJerry.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/TomAndJerry.cs deleted file mode 100644 index 3719e678d..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/TomAndJerry.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; -using VisualPinball.Unity.Editor; -using VisualPinball.Unity.Patcher.Matcher.Table; - -namespace VisualPinball.Unity.Patcher -{ - [TableNameMatch("TomandJerry")] - public class TomAndJerry : TablePatcher - { - [NameMatch("ShadowsRamp")] - [NameMatch("JerryHAMMERshadow")] - [NameMatch("MuscleswithknifeSHADOW")] - public void HideGameObject(GameObject gameObject) - { - PatcherUtil.Hide(gameObject); - } - - [NameMatch("sw51")] - [NameMatch("sw40")] - [NameMatch("sw50")] - [NameMatch("sw60")] - [NameMatch("sw41")] - [NameMatch("sw61")] - [NameMatch("sw63")] - [NameMatch("sw53")] - [NameMatch("sw43")] - [NameMatch("sw44")] - [NameMatch("sw54")] - [NameMatch("sw64")] - [NameMatch("sw73")] - [NameMatch("sw73a")] - [NameMatch("BumperCap2")] // Jerry Bumper - [NameMatch("BumperCap3")] // Tom Bumper - public void SetOpaque(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetOpaque(gameObject); - } - - /// - /// The transparent plastic glass had some strange artefacts. We need to adjust the alpha clip. - /// - /// - [NameMatch("Primitive67")] - [NameMatch("JerryHammer")] - [NameMatch("MusclesKnife")] - public void SetAlphaClip(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetAlphaCutOff(gameObject, 0.05f); - } - - /// - /// Make the children of the ramps doublesided or else the ramps wouldn't be visible. - /// This patches all children (e. g. Floor, LeftWall, RightWall of the ramps) of the item the same way - /// - /// - [NameMatch("Ramp5")] - [NameMatch("Ramp6")] - [NameMatch("Ramp13")] - [NameMatch("Ramp15")] - [NameMatch("Ramp20")] - [NameMatch("Primitive52")] // side-wall - [NameMatch("Primitive66")] // jerry at plunger - public void SetDoubleSided(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetDoubleSided(gameObject); - } - - [NameMatch("Ramp5")] - [NameMatch("Ramp6")] - [NameMatch("Ramp13")] - [NameMatch("Ramp15")] - [NameMatch("Ramp20")] - public void SetMetallic(GameObject gameObject) - { - RenderPipelineConverter.Current.MaterialAdapter.SetMetallic(gameObject, 1.0f); - } - - [NameMatch("Lflip", Ref = "Playfield/Flippers/LeftFlipper")] - [NameMatch("Rflip", Ref = "Playfield/Flippers/RightFlipper")] - [NameMatch("LFlip1", Ref = "Playfield/Flippers/LeftFlipper1")] - [NameMatch("Rflip1", Ref = "Playfield/Flippers/RightFlipper1")] - public void ReparentFlippers(PrimitiveComponent primitive, GameObject gameObject, ref GameObject parent) - { - PatcherUtil.Reparent(gameObject, parent); - - primitive.Position = Vector3.zero; - // primitive.Rotation.y = 0; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/TomAndJerry.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/TomAndJerry.cs.meta deleted file mode 100644 index b47d526b1..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/TomAndJerry.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e0f60a82afb84c34fa66e9408bacb831 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Volley.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Volley.cs deleted file mode 100644 index b4b61d2bb..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Volley.cs +++ /dev/null @@ -1,176 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable InconsistentNaming -// ReSharper disable UnusedMember.Global -// ReSharper disable UnusedType.Global - -using System.Linq; -using System.Text.RegularExpressions; -using UnityEditor; -using UnityEngine; -using VisualPinball.Engine.Math; -using VisualPinball.Engine.VPT; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Volley", TableVersion = "1.0")] - public class Volley : TablePatcher - { - public override void PostPatch(GameObject tableGo) - { - var playfieldGo = Playfield(tableGo); - playfieldGo.isStatic = true; - - SetupLights(tableGo, playfieldGo); - - SetupDropTargetBanks(tableGo, playfieldGo); - SetupTrough(tableGo, playfieldGo); - } - - private static void SetupLights(GameObject tableGo, GameObject playfieldGo) - { - /*foreach (var child in playfieldGo.transform.Find("Lights").gameObject.transform.Cast().ToList()) { - var go = child.gameObject; - - var lc = go.GetComponentInParent(); - - if (lc != null) { - lc.FadeSpeedUp = .2f; - lc.FadeSpeedDown = .1f; - - PrefabUtility.RecordPrefabInstancePropertyModifications(lc); - } - }*/ - - var lightGroups = CreateEmptyGameObject(playfieldGo, "Light Groups"); - - AddLightGroup(tableGo, CreateEmptyGameObject(lightGroups, "LightGroupGI"), - "GILight1", "GILight2", "GILight3", "GILight4", - "GILight6", "GILight7", "GILight9", "GILight20", - "GILight21", "GILight22", "GILight23", "GILight24", - "GILight25", "GILight26", "GILight27", "GILight28", - "GILight29", "GILight30", "GILight31", "GILight32", - "GILight33", "GILight34", - "GILight5", "GILight8", "GILight10", "GILight11", "GILight12", - "GILight13"); - } - - private static void SetupDropTargetBanks(GameObject tableGo, GameObject playfieldGo) - { - CreateDropTargetBank(tableGo, playfieldGo, "YellowDropTargetBank", - new string[] { "Yellow1", "Yellow2", "Yellow3", "Yellow4", "Yellow5" }); - - CreateDropTargetBank(tableGo, playfieldGo, "BlueDropTargetBank", - new string[] { "Blue1", "Blue2", "Blue3", "Blue4", "Blue5" }); - - CreateDropTargetBank(tableGo, playfieldGo, "GreenDropTargetBank", - new string[] { "Green1", "Green2", "Green3", "Green4", "Green5" }); - } - - private static void SetupTrough(GameObject tableGo, GameObject playfieldGo) - { - /*var troughComponent = CreateTrough(tableGo, playfieldGo); - troughComponent.Type = TroughType.ClassicSingleBall; - troughComponent.BallCount = 1; - troughComponent.SwitchCount = 1; - troughComponent.KickTime = 100; - troughComponent.RollTime = 300;*/ - } - - [NameMatch("Yellow1")] - [NameMatch("Yellow2")] - [NameMatch("Yellow3")] - [NameMatch("Yellow4")] - [NameMatch("Yellow5")] - public void FixYellowDropTargetTexture(GameObject go) - { - var renderer = go.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("DropTarget_Yellow"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("Blue1")] - [NameMatch("Blue2")] - [NameMatch("Blue3")] - [NameMatch("Blue4")] - [NameMatch("Blue5")] - public void FixBlueDropTargetTexture(GameObject go) - { - var renderer = go.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("DropTarget_Blue"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("Green1")] - [NameMatch("Green2")] - [NameMatch("Green3")] - [NameMatch("Green4")] - [NameMatch("Green5")] - public void FixGreenDropTargetTexture(GameObject go) - { - var renderer = go.GetComponent(); - var material = new UnityEngine.Material(renderer.sharedMaterial); - material.mainTexture = TextureProvider.GetTexture("DropTarget_Green"); - material.color = UnityEngine.Color.white; - renderer.sharedMaterial = material; - } - - [NameMatch("OperatorMenuBackdrop")] - public void DisableOperatorMenuBackgroup(GameObject go) - { - go.SetActive(false); - } - - [NameMatch("GILight1")] - [NameMatch("GILight2")] - [NameMatch("GILight3")] - [NameMatch("GILight4")] - [NameMatch("GILight5")] - [NameMatch("GILight6")] - [NameMatch("GILight7")] - [NameMatch("GILight9")] - [NameMatch("GILight10")] - [NameMatch("GILight11")] - [NameMatch("GILight12")] - [NameMatch("GILight13")] - [NameMatch("GILight20")] - [NameMatch("GILight21")] - [NameMatch("GILight22")] - [NameMatch("GILight23")] - [NameMatch("GILight24")] - [NameMatch("GILight25")] - [NameMatch("GILight26")] - [NameMatch("GILight27")] - [NameMatch("GILight28")] - [NameMatch("GILight29")] - [NameMatch("GILight30")] - [NameMatch("GILight31")] - [NameMatch("GILight32")] - [NameMatch("GILight33")] - [NameMatch("GILight34")] - public void FixGIs(GameObject go) - { - //LightTemperature(go, 2700f); - //LightIntensity(go, 120f); - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Volley.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Volley.cs.meta deleted file mode 100644 index 186a5b917..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/Volley.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1a0239751e2bc47589b8d0e8f59a193e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/WipeOut.cs b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/WipeOut.cs deleted file mode 100644 index ff8f1811a..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/WipeOut.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// ReSharper disable StringLiteralTypo -// ReSharper disable UnusedType.Global -// ReSharper disable UnusedMember.Global - -using UnityEngine; - -namespace VisualPinball.Unity.Patcher -{ - [MetaMatch(TableName = "Wipe Out Premier 1993", AuthorName = "Edizzle & Kiwi")] - public class WipeOut : TablePatcher - { - [NameMatch("Prim_RightFlipper", Ref="Playfield/Flippers/RightFlipper")] - [NameMatch("Prim_LeftFlipper", Ref="Playfield/Flippers/LeftFlipper")] - public void ReparentFlippers(PrimitiveComponent primitive, GameObject gameObject, ref GameObject parent) - { - PatcherUtil.Reparent(gameObject, parent); - primitive.Position = Vector3.zero; - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/WipeOut.cs.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/WipeOut.cs.meta deleted file mode 100644 index c3ff3e83a..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/Patcher/Tables/WipeOut.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 940ba5c21acb5234993a0616942a8353 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/README.md b/VisualPinball.Unity/VisualPinball.Unity.Patcher/README.md deleted file mode 100644 index 46f46335d..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/README.md +++ /dev/null @@ -1,218 +0,0 @@ -# Patching System - -While we handle most of VPX's quirks in a generic way, there are things that -are impossible to deal with because they are implemented in the table via -script. Examples are ball- or flipper shadows, or material properties that -cannot be reproduced the same way in the Unity renderer. - -This project allows to apply changes to an imported table in a simple, -automated and reusable way. - -## How? - -In order to patch something, we create a class under `VisualPinball.Unity.Patcher.Patcher`. -There are currently two sub packages, `Common` for changes likely to be applied -to all tables, and a `Tables` package with classes that concern only specific -tables. - -## Matcher - -Before we can patch, we need to know *what* to patch. More precisely, we need -to: - -1. Identify the table -2. Identify the element we want to patch. - -We use [Attributes](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/) -to do that. - -### Identify the Table - -Create a matcher class by extending `TableMatchAttribute` or use one of the -existing ones. If this matcher returns a negative value, all patch methods of -the underlying class are ignored. - -For example, if you want to match a table with the file name "foo.vpx", you -would create the attribute class like that: - -```cs -public class FooMatchAttribute : TableMatchAttribute -{ - public override bool Matches(Engine.VPT.Table.Table table, string fileName) - { - return fileName == "foo.vpx"; - } -} -``` - -Then, decorate your patch class with the attribute (you can omit the `Attribute` suffix when using attributes): - -```cs -[FooMatch] -public class MyTablePatcher -{ -} -``` - -This isn't very DRY though. If matching by file name is something you're doing -a lot, you pass the file name as parameter: - -```cs -public class FileNameMatchAttribute : TableMatchAttribute -{ - private readonly string _fileName; - - public NameMatchAttribute(string fileName) - { - _fileName = fileName; - } - - public override bool Matches(Engine.VPT.Table.Table table, string fileName) - { - return fileName == _fileName; - } -} -``` - -And use it like so: - -```cs -[FileNameMatch("foo.vpx")] -public class MyTablePatcher -{ -} -``` - -We already include a few matcher for you to use, [see below](#built-in-matchers). - -### Identify the Game Item - -Now we know how to filter the table, let's look at how to identify the -table element to patch. We use the same principle as above, but by extending -`ItemMatchAttribute` instead of `TableMatchAttribute`. - -You've noticed that the table matcher classes get only the parsed table and the -file name of the table to decide whether to match or not. Since we're dealing -with table items, we get a lot more input here, namely: - -- the parsed table (maybe you want to exclude some tables) -- the table item (this holds the name of the element) -- the render object (maybe the match is based on the mesh itself) -- the Unity `GameObject` (maybe the match is based on the converted object) - -So, here's an example: - -```cs -public class NameMatchAttribute : ItemMatchAttribute -{ - public bool IgnoreCase = true; - - private readonly string _name; - - public NameMatchAttribute(string name) - { - _name = name; - } - - public override bool Matches(FileTableContainer tableContainer, GameObject obj) - { - return IgnoreCase - ? string.Equals(obj.name, _name, StringComparison.CurrentCultureIgnoreCase) - : obj.name == _name; - } -} -``` - -Let's look at how to apply this in the next section. - -## Patcher - -Now we know how to match an item, let's create a patch. It's as easy as -writing a `void` method in your patch class that takes in the objects you're -interested in (see below), and decorate it with an item matcher. - -Let's take the name matcher from the example above and use it to hide the -flipper shadows: - -```cs -[NameMatch("LeftFlipperSh")] -[NameMatch("RightFlipperSh")] -public void RemoveFlipperShadow(GameObject gameObject) -{ - gameObject.SetActive(false); -} -``` - -Putting several attributes on a method means that it is matched if *at least -one* of the matchers matches (the same applies to the table matchers, by the -way). - -You can pass different types in any order to the method. Supported types are: - -- `UnityEngine.GameObject` - Unity game object that was created for that game item. -- `VisualPinball.Engine.VPT.Table.Table` - The table object for which the game - item was created for -- Any game item type, e.g. `VisualPinball.Engine.VPT.Flipper.Flipper` that - extends `IItem`. If your matched game item is not of the type you've provided - in the method signature, the patch is skipped and a warning is printed. -- Any Unity component, e.g. `FlipperComponent`, or even `MeshFilter`. -- `ref UnityEngine.GameObject` - Another game object, specified by the `Ref` - field of the matcher (see *Advanced Features* below). - -## Built-in Matchers - -### Table Matchers - -- `[AnyMatch]` - Matches all tables -- `[MetaMatch(string TableName, string AuthorName)]` - Matches a table where - `TableName` is the table name and `AuthorName` the (exact) string of the - authors field of the table's metadata. - - `[TableNameMatch(string name)]` - Matches a table by the table's game item - item name (also the table name in the table script). -- `[RenderPipeline(RenderPipelineType rp)]` - Matches if the current render - pipeline is set to the given value. - -### Item Matchers - -- `[NameMatch(string name)]` - Matches an item by its name. -- `[RenderPipeline(RenderPipelineType rp)]` - Matches if the current render - pipeline is set to the given value. - -## Advanced Features - -You might need to find another game object during patching, and repeat this -over several patch methods. For that, you can use the matcher's `Ref` field, -which is a search path for the game object you'd like to find. In the patch -method, you can retrieve this using a `ref GameObject` parameter. - -For example, many tables use a primitive for the flipper, that we'd like to -re-parent to the actual flipper object. So we would do the following: - -```cs -[NameMatch("RightFlipperPrimitive", Ref="Flippers/RightFlipper")] -[NameMatch("LeftFlipperPrimitive", Ref="Flippers/LeftFlipper")] -public void ReparentFlippers(GameObject gameObject, ref GameObject parent) -{ - var rot = gameObject.transform.rotation; - var pos = gameObject.transform.position; - - // re-parent the child - gameObject.transform.SetParent(parent.transform, false); - - gameObject.transform.rotation = rot; - gameObject.transform.position = pos; -} -``` - -## Summary - -For a new table: - -1. Create a patch class. Preferably at `Patcher.Tables` package. Name it - however you want. -2. Put a class matcher attribute on it. -3. For every element to patch, create a new method and add an item matcher - attribute on it. - -All classes are automatically loaded, there is no need to register them -anywhere. diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/README.md.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/README.md.meta deleted file mode 100644 index 870a68f60..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/README.md.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0fc29c6639af46629bee38b22c52bfe2 -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.asmdef b/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.asmdef deleted file mode 100644 index 73c6710d8..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.asmdef +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "VisualPinball.Unity.Patcher", - "rootNamespace": "VisualPinball.Unity.Patcher", - "references": [ - "VisualPinball.Engine", - "VisualPinball.Unity", - "VisualPinball.Unity.Editor", - "VisualPinball.Engine.PinMAME.Unity" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.asmdef.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.asmdef.meta deleted file mode 100644 index 8adfcce80..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.asmdef.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4847348767c1421eab8b5b3d15cb7a21 -timeCreated: 1583488751 \ No newline at end of file diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.csproj b/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.csproj deleted file mode 100644 index 690432495..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - netstandard2.1 - VisualPinball.Unity.Patcher - A bridge between VisualPinball.Engine and Unity - freezy;ravarcade;shaderbytes;rbxnk;jsm174;Vroonsh;Rowlan;kleisauke;ecurtz;Pandeli;Cupid - Copyright 2023 freezy - <freezy@vpdb.io> - 0.1.0.0 - 0.1.0.0 - 0.1.0.0 - 9.0 - NO_PINMAME - - - - - - - ..\Plugins\.unity\UnityEngine.dll - - - ..\Plugins\.unity\UnityEngine.CoreModule.dll - - - ..\Plugins\.unity\UnityEditor.dll - - - ..\Plugins\.unity\UnityEditor.CoreModule.dll - - - ..\Plugins\.unity\Unity.Entities.Hybrid.dll - - - - - - - - diff --git a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.csproj.meta b/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.csproj.meta deleted file mode 100644 index b1a5c1f1b..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity.Patcher/VisualPinball.Unity.Patcher.csproj.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c4ecea4b01b8202439c6787d5d9dc715 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VisualPinball.Unity/VisualPinball.Unity/Import/PatcherManager.cs b/VisualPinball.Unity/VisualPinball.Unity/Import/PatcherManager.cs deleted file mode 100644 index d0b032d61..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity/Import/PatcherManager.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Visual Pinball Engine -// Copyright (C) 2023 freezy and VPE Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Linq; -using UnityEngine; -using VisualPinball.Engine.VPT.Table; - -namespace VisualPinball.Unity -{ - public interface IPatcher - { - void Set(FileTableContainer tableContainer, string filename, IMaterialProvider materialProvider, ITextureProvider textureProvider); - void ApplyPatches(GameObject gameObject, GameObject tableGameObject); - void PostPatch(GameObject tableGameObject); - } - - public static class PatcherManager - { - public static IPatcher GetPatcher() { - var t = typeof(IPatcher); - var patchers = AppDomain.CurrentDomain.GetAssemblies() - .Where(x => x.FullName.StartsWith("VisualPinball.")) - .SelectMany(x => x.GetTypes()) - .Where(x => x.IsClass && t.IsAssignableFrom(x)) - .Select(x => (IPatcher) Activator.CreateInstance(x)) - .ToArray(); - - return patchers.First(); - } - } -} diff --git a/VisualPinball.Unity/VisualPinball.Unity/Import/PatcherManager.cs.meta b/VisualPinball.Unity/VisualPinball.Unity/Import/PatcherManager.cs.meta deleted file mode 100644 index 12879983c..000000000 --- a/VisualPinball.Unity/VisualPinball.Unity/Import/PatcherManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8d4f9ead7336a664f9a4c6432aae5547 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: