From 63eeeabe928a62bf7226ab87599ae2720dd6c3b3 Mon Sep 17 00:00:00 2001 From: stilnat Date: Thu, 30 Nov 2023 14:49:27 +0100 Subject: [PATCH] Refactor the tilemap menu (#1355) * Little cleanup * Split Place() into two with input acitons * Place action is performed on release * Rewrite tile construction menu script * Implement dragging * Implement correct placing * Implement deleting * Fix stuff, implement square form * Rearrange stuff * Fix everything, rearrenge methods into regions, rename GhostManager to BuildGhost * Add comments, resize menu * Add comment * Move methods into helpers * Reimplement restrained rotations * Remove redundant dependencies * make it work * activate ghosts * add material database * renaming * set rotation correctly * add last registered direction * fix merge errors * fix broken body parts * big refactor * another bunch of refactoring * some encapsulation * more splitting * some doc and renaming * some more refactoring * doc and clean up * doc * clean up, doc and renaming * set up missing value * fix hand bugging due to bad merge * refresh hologram after adding them * move handle load and handle save to tilemapmenusaveandloadtabs * Rename stuff, beutify code, move handlers * Move input logic --------- Co-authored-by: Mechar418 <77565416+Mechar418@users.noreply.github.com> --- .../AddressableAssetSettings.asset | 1 + .../Addressables/AssetGroups/BodyParts.asset | 8 +- .../Addressables/AssetGroups/Materials.asset | 37 ++ .../AssetGroups/Materials.asset.meta | 14 + .../Materials_BundledAssetGroupSchema.asset | 45 ++ ...terials_BundledAssetGroupSchema.asset.meta | 8 + .../Materials_ContentUpdateGroupSchema.asset | 16 + ...erials_ContentUpdateGroupSchema.asset.meta | 8 + Assets/Content/Data/BodyParts.asset | 2 +- Assets/Content/Data/Items.asset | 14 - Assets/Content/Data/Materials.asset | 21 + Assets/Content/Data/Materials.asset.meta | 8 + .../Construction/ConstructionMenu.prefab | 92 ++- .../Entities/Humanoids/Human/Human.prefab | 77 +-- .../Human/HumanOrgans/HumanHeart.prefab.meta | 7 + Assets/DefaultPrefabObjects.asset | 22 +- .../Scripts/SS3D/Data/Enums/AssetDatabases.cs | 11 +- .../Scripts/SS3D/Data/Enums/BodyPartsIds.cs | 8 +- Assets/Scripts/SS3D/Data/Enums/ItemId.cs | 14 - .../Scripts/SS3D/Data/Enums/MaterialsIds.cs | 10 + .../SS3D/Data/Enums/MaterialsIds.cs.meta | 11 + .../Systems/Tile/TileMapCreator/AssetGrid.cs | 192 ++++++ .../Tile/TileMapCreator/AssetGrid.cs.meta | 11 + .../{TileMapCreatorTab.cs => AssetSlot.cs} | 13 +- ...apCreatorTab.cs.meta => AssetSlot.cs.meta} | 0 .../Systems/Tile/TileMapCreator/BuildGhost.cs | 89 --- .../TileMapCreator/ConstructionHologram.cs | 119 ++++ .../ConstructionHologram.cs.meta | 11 + .../ConstructionHologramManager.cs | 376 +++++++++++ ...ta => ConstructionHologramManager.cs.meta} | 0 .../Tile/TileMapCreator/ConstructionMode.cs | 9 + .../TileMapCreator/ConstructionMode.cs.meta | 11 + .../TileMapCreator/ICustomGhostRotation.cs | 13 +- .../Tile/TileMapCreator/TileMapCreator.cs | 626 ------------------ .../Tile/TileMapCreator/TileMapMenu.cs | 184 +++++ ...MapCreator.cs.meta => TileMapMenu.cs.meta} | 0 .../Tile/TileMapCreator/TileMapSaveAndLoad.cs | 40 ++ .../TileMapCreator/TileMapSaveAndLoad.cs.meta | 11 + Assets/Settings/AssetDatabaseSettings.asset | 1 + 39 files changed, 1248 insertions(+), 892 deletions(-) create mode 100644 Assets/Content/Addressables/AssetGroups/Materials.asset create mode 100644 Assets/Content/Addressables/AssetGroups/Materials.asset.meta create mode 100644 Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset create mode 100644 Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset.meta create mode 100644 Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset create mode 100644 Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset.meta create mode 100644 Assets/Content/Data/Materials.asset create mode 100644 Assets/Content/Data/Materials.asset.meta create mode 100644 Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs create mode 100644 Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs.meta create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs.meta rename Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/{TileMapCreatorTab.cs => AssetSlot.cs} (62%) rename Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/{TileMapCreatorTab.cs.meta => AssetSlot.cs.meta} (100%) delete mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/BuildGhost.cs create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs.meta create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologramManager.cs rename Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/{BuildGhost.cs.meta => ConstructionHologramManager.cs.meta} (100%) create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs.meta delete mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreator.cs create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenu.cs rename Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/{TileMapCreator.cs.meta => TileMapMenu.cs.meta} (100%) create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs create mode 100644 Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs.meta diff --git a/Assets/Content/Addressables/AddressableAssetSettings.asset b/Assets/Content/Addressables/AddressableAssetSettings.asset index 77c2af35bb..2f628afa3e 100644 --- a/Assets/Content/Addressables/AddressableAssetSettings.asset +++ b/Assets/Content/Addressables/AddressableAssetSettings.asset @@ -52,6 +52,7 @@ MonoBehaviour: - {fileID: 11400000, guid: dd394b793b56e43418a2c11a61130663, type: 2} - {fileID: 11400000, guid: d640c8e212e7a5349999a9ddd6ffb5b5, type: 2} - {fileID: 11400000, guid: d700978032e12a647b8734863a0bf7c2, type: 2} + - {fileID: 11400000, guid: 2caa591261a883b4183d04829ce705fd, type: 2} m_BuildSettings: m_CompileScriptsInVirtualMode: 0 m_CleanupStreamingAssetsAfterBuilds: 1 diff --git a/Assets/Content/Addressables/AssetGroups/BodyParts.asset b/Assets/Content/Addressables/AssetGroups/BodyParts.asset index 947a799eb9..2a49741a15 100644 --- a/Assets/Content/Addressables/AssetGroups/BodyParts.asset +++ b/Assets/Content/Addressables/AssetGroups/BodyParts.asset @@ -81,10 +81,6 @@ MonoBehaviour: m_Address: Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanLiver.prefab m_ReadOnly: 0 m_SerializedLabels: [] - - m_GUID: ea5b9b571f8df3948b52b7023aa66c99 - m_Address: Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab - m_ReadOnly: 0 - m_SerializedLabels: [] - m_GUID: 1e304f9a331c2ba419514ef8afb8a13c m_Address: Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanIntestineLarge.prefab m_ReadOnly: 0 @@ -97,6 +93,10 @@ MonoBehaviour: m_Address: Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanBrain.prefab m_ReadOnly: 0 m_SerializedLabels: [] + - m_GUID: fccdc78a6cf916047ba52f2877f755e5 + m_Address: Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab + m_ReadOnly: 0 + m_SerializedLabels: [] m_ReadOnly: 0 m_Settings: {fileID: 11400000, guid: ddc57d0f5f9fb874e8a26db0c5b215e0, type: 2} m_SchemaSet: diff --git a/Assets/Content/Addressables/AssetGroups/Materials.asset b/Assets/Content/Addressables/AssetGroups/Materials.asset new file mode 100644 index 0000000000..80acdcf841 --- /dev/null +++ b/Assets/Content/Addressables/AssetGroups/Materials.asset @@ -0,0 +1,37 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3} + m_Name: Materials + m_EditorClassIdentifier: + m_GroupName: Materials + m_Data: + m_SerializedData: [] + m_GUID: ca573a7d9c8fb1044a5ceb85f048f213 + m_SerializeEntries: + - m_GUID: ed5a1263eb564c94abc6407ac0919ea7 + m_Address: Assets/Content/WorldObjects/World/VFX/Construction/DeleteConstruction.mat + m_ReadOnly: 0 + m_SerializedLabels: [] + - m_GUID: e9b99cfb2e59ffa40a062c2f4b88b729 + m_Address: Assets/Content/WorldObjects/World/VFX/Construction/InvalidConstruction.mat + m_ReadOnly: 0 + m_SerializedLabels: [] + - m_GUID: 6d2a18aa72cbaf94694dce9f8451160b + m_Address: Assets/Content/WorldObjects/World/VFX/Construction/ValidConstruction.mat + m_ReadOnly: 0 + m_SerializedLabels: [] + m_ReadOnly: 0 + m_Settings: {fileID: 11400000, guid: ddc57d0f5f9fb874e8a26db0c5b215e0, type: 2} + m_SchemaSet: + m_Schemas: + - {fileID: 11400000, guid: 84c038900429ad74e9cf6f6d27f33ade, type: 2} + - {fileID: 11400000, guid: b22abbf9f6bc06c4491b5c4a8258a702, type: 2} diff --git a/Assets/Content/Addressables/AssetGroups/Materials.asset.meta b/Assets/Content/Addressables/AssetGroups/Materials.asset.meta new file mode 100644 index 0000000000..0f4637ed69 --- /dev/null +++ b/Assets/Content/Addressables/AssetGroups/Materials.asset.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +<<<<<<<< HEAD:Assets/Content/Addressables/AssetGroups/Materials.asset.meta +guid: 2caa591261a883b4183d04829ce705fd +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 +======== +guid: ea5b9b571f8df3948b52b7023aa66c99 +PrefabImporter: + externalObjects: {} +>>>>>>>> develop:Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab.meta + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset new file mode 100644 index 0000000000..83bdf6323d --- /dev/null +++ b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset @@ -0,0 +1,45 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3} + m_Name: Materials_BundledAssetGroupSchema + m_EditorClassIdentifier: + m_Group: {fileID: 11400000, guid: 2caa591261a883b4183d04829ce705fd, type: 2} + m_InternalBundleIdMode: 1 + m_Compression: 1 + m_IncludeAddressInCatalog: 1 + m_IncludeGUIDInCatalog: 1 + m_IncludeLabelsInCatalog: 1 + m_InternalIdNamingMode: 0 + m_CacheClearBehavior: 0 + m_IncludeInBuild: 1 + m_BundledAssetProviderType: + m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider + m_ForceUniqueProvider: 0 + m_UseAssetBundleCache: 1 + m_UseAssetBundleCrc: 1 + m_UseAssetBundleCrcForCachedBundles: 1 + m_UseUWRForLocalBundles: 0 + m_Timeout: 0 + m_ChunkedTransfer: 0 + m_RedirectLimit: -1 + m_RetryCount: 0 + m_BuildPath: + m_Id: 56790a984472fbe4a809c1ab1b0e4c79 + m_LoadPath: + m_Id: 8abc09617b79e8b4994b07cc672cbbe5 + m_BundleMode: 0 + m_AssetBundleProviderType: + m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider + m_BundleNaming: 0 + m_AssetLoadMode: 0 diff --git a/Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset.meta b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset.meta new file mode 100644 index 0000000000..e9b8cf0b81 --- /dev/null +++ b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_BundledAssetGroupSchema.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84c038900429ad74e9cf6f6d27f33ade +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset new file mode 100644 index 0000000000..b720ccd552 --- /dev/null +++ b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3} + m_Name: Materials_ContentUpdateGroupSchema + m_EditorClassIdentifier: + m_Group: {fileID: 11400000, guid: 2caa591261a883b4183d04829ce705fd, type: 2} + m_StaticContent: 0 diff --git a/Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset.meta b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset.meta new file mode 100644 index 0000000000..90d5f219ae --- /dev/null +++ b/Assets/Content/Addressables/AssetGroups/Schemas/Materials_ContentUpdateGroupSchema.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b22abbf9f6bc06c4491b5c4a8258a702 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Content/Data/BodyParts.asset b/Assets/Content/Data/BodyParts.asset index 49bdc57f75..754c964a09 100644 --- a/Assets/Content/Data/BodyParts.asset +++ b/Assets/Content/Data/BodyParts.asset @@ -32,7 +32,7 @@ MonoBehaviour: - {fileID: 1705603677127675533, guid: a019475d05ec8824494b0fa88e2282d8, type: 3} - {fileID: 5774385816057912484, guid: 2bc6f6a968d5ba04c919ba56d0ccdab4, type: 3} - {fileID: 5774385816057912484, guid: d75ff9a3ac207a84487ec1ee73a676fc, type: 3} - - {fileID: 2302397424301738637, guid: ea5b9b571f8df3948b52b7023aa66c99, type: 3} - {fileID: 5774385816057912484, guid: 1e304f9a331c2ba419514ef8afb8a13c, type: 3} - {fileID: 5774385816057912484, guid: 071581df025e1ba49a8a75eb39611ff6, type: 3} - {fileID: 5774385816057912484, guid: 7579883b8dd8801448a176adace4860b, type: 3} + - {fileID: 2302397424301738637, guid: fccdc78a6cf916047ba52f2877f755e5, type: 3} diff --git a/Assets/Content/Data/Items.asset b/Assets/Content/Data/Items.asset index 912e83af76..08a37c89fc 100644 --- a/Assets/Content/Data/Items.asset +++ b/Assets/Content/Data/Items.asset @@ -60,17 +60,3 @@ MonoBehaviour: - {fileID: 726792282085660869, guid: 4635651592391df41b6b2413afdb76c3, type: 3} - {fileID: 7723921361698481624, guid: f549f4153ef612c4586c46ea280e0e94, type: 3} - {fileID: 8712940276313799639, guid: 1a2f912be4bc1b948a2b22ffde517cdc, type: 3} - - {fileID: 5774385816057912484, guid: 7579883b8dd8801448a176adace4860b, type: 3} - - {fileID: 6632297082311541152, guid: e60ba1e09be8316448e419ecbdfb64a6, type: 3} - - {fileID: 6958959792659314810, guid: 94aaf82bb6ab002418e01d9cc7c6eaaa, type: 3} - - {fileID: 5562010227207703736, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} - - {fileID: 2207730063960764759, guid: 35dfc7c3f708a5b48a206b4a44e7ab49, type: 3} - - {fileID: 7546631754298856378, guid: 7f5954f009d06b2439ca637b43920440, type: 3} - - {fileID: 3470038122221450171, guid: ecaf79b0a74bdb443a350e88daa94a66, type: 3} - - {fileID: 8256619991674398311, guid: 242a937784a622f4f8a6e6d097e0737c, type: 3} - - {fileID: 1888615333292121711, guid: 06b6be83779804245b7f6411fe07b851, type: 3} - - {fileID: 832941577213411195, guid: 432a4ad70e41e5c4f8f913f76fe0e66c, type: 3} - - {fileID: 8006468508714419156, guid: cc54bc74b2f4c2349b1f84b501b0a091, type: 3} - - {fileID: 1705603677127675533, guid: a019475d05ec8824494b0fa88e2282d8, type: 3} - - {fileID: 8304480218026041231, guid: a8b265034e3f79344a6067b406e1bff6, type: 3} - - {fileID: 2302397424301738637, guid: ea5b9b571f8df3948b52b7023aa66c99, type: 3} diff --git a/Assets/Content/Data/Materials.asset b/Assets/Content/Data/Materials.asset new file mode 100644 index 0000000000..531da208e7 --- /dev/null +++ b/Assets/Content/Data/Materials.asset @@ -0,0 +1,21 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3c9b6c8ad6324c838c1743c2a2e2abc4, type: 3} + m_Name: Materials + m_EditorClassIdentifier: + EnumNamespaceName: SS3D.Data.Enums + EnumName: MaterialsIds + AssetGroup: {fileID: 11400000, guid: 2caa591261a883b4183d04829ce705fd, type: 2} + Assets: + - {fileID: 2100000, guid: ed5a1263eb564c94abc6407ac0919ea7, type: 2} + - {fileID: 2100000, guid: e9b99cfb2e59ffa40a062c2f4b88b729, type: 2} + - {fileID: 2100000, guid: 6d2a18aa72cbaf94694dce9f8451160b, type: 2} diff --git a/Assets/Content/Data/Materials.asset.meta b/Assets/Content/Data/Materials.asset.meta new file mode 100644 index 0000000000..5fdb8ffd31 --- /dev/null +++ b/Assets/Content/Data/Materials.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 51c28dd8b59ae0540a4e2cbcceb4999e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Content/Systems/UI/Systems/Construction/ConstructionMenu.prefab b/Assets/Content/Systems/UI/Systems/Construction/ConstructionMenu.prefab index 43fb423f18..e403019209 100644 --- a/Assets/Content/Systems/UI/Systems/Construction/ConstructionMenu.prefab +++ b/Assets/Content/Systems/UI/Systems/Construction/ConstructionMenu.prefab @@ -784,9 +784,8 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 6924109542537538210} - m_TargetAssemblyTypeName: SS3D.Systems.Tile.TileMapCreator.TileMapCreator, - SS3D.Systems - m_MethodName: OnInputFieldSelect + m_TargetAssemblyTypeName: SS3D.Systems.Tile.TileMapCreator.TileMapMenu, SS3D.Systems + m_MethodName: HandleInputFieldSelect m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -800,9 +799,8 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 6924109542537538210} - m_TargetAssemblyTypeName: SS3D.Systems.Tile.TileMapCreator.TileMapCreator, - SS3D.Systems - m_MethodName: OnInputFieldDeselect + m_TargetAssemblyTypeName: SS3D.Systems.Tile.TileMapCreator.TileMapMenu, SS3D.Systems + m_MethodName: HandleInputFieldDeselect m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -822,9 +820,8 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 6924109542537538210} - m_TargetAssemblyTypeName: SS3D.Systems.Tile.TileMapCreator.TileMapCreator, - SS3D.Systems - m_MethodName: OnInputFieldChanged + m_TargetAssemblyTypeName: SS3D.Systems.Tile.TileMapCreator.TileMapMenu, SS3D.Systems + m_MethodName: HandleInputFieldChanged m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -1207,10 +1204,9 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 6924109542537538210} - m_TargetAssemblyTypeName: SS3D.Systems.Construction.UI.ConstructionMenu, - SS3D.Systems - m_MethodName: SaveMap + - m_Target: {fileID: 0} + m_TargetAssemblyTypeName: TileMapMenuSaveAndLoadTabs, SS3D.Systems + m_MethodName: HandleSaveButton m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -1477,6 +1473,8 @@ GameObject: - component: {fileID: 2747704420924042145} - component: {fileID: 6924109542537538210} - component: {fileID: 9154675693299657064} + - component: {fileID: 978946649210659857} + - component: {fileID: 6241789247798514904} m_Layer: 5 m_Name: ConstructionMenu m_TagString: Untagged @@ -1558,14 +1556,10 @@ MonoBehaviour: _componentIndexCache: 0 _addedNetworkObject: {fileID: 9154675693299657064} _networkObjectCache: {fileID: 9154675693299657064} - _menuRoot: {fileID: 7547524062666404018} - _contentRoot: {fileID: 6243703131314193102} - _slotPrefab: {fileID: 4285405521571209506, guid: 484315627df23dd428819ee4c9e05603, type: 3} - _layerPlacementDropdown: {fileID: 2409669378435090507} _inputField: {fileID: 5558970035109273631} - _validConstruction: {fileID: 2100000, guid: 6d2a18aa72cbaf94694dce9f8451160b, type: 2} - _invalidConstruction: {fileID: 2100000, guid: e9b99cfb2e59ffa40a062c2f4b88b729, type: 2} - _deleteConstruction: {fileID: 2100000, guid: ed5a1263eb564c94abc6407ac0919ea7, type: 2} + _menuRoot: {fileID: 7547524062666404018} + _hologramManager: {fileID: 978946649210659857} + _tileMapMenuBuildingTabs: {fileID: 6241789247798514904} --- !u!114 &9154675693299657064 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1583,12 +1577,13 @@ MonoBehaviour: k__BackingField: {fileID: 0} _networkBehaviours: - {fileID: 6924109542537538210} + - {fileID: 978946649210659857} k__BackingField: {fileID: 0} k__BackingField: [] SerializedTransformProperties: - Position: {x: 0, y: 0, z: 0} - Rotation: {x: 0, y: 0, z: 0, w: 0} - LocalScale: {x: 0, y: 0, z: 0} + Position: {x: 272.53857, y: 67.66217, z: 0} + Rotation: {x: -0, y: -0, z: -0, w: 1} + LocalScale: {x: 1.3615595, y: 1.3615595, z: 1.3615595} _isNetworked: 1 _isGlobal: 0 _initializeOrder: 0 @@ -1599,6 +1594,39 @@ MonoBehaviour: _scenePathHash: 0 k__BackingField: 0 k__BackingField: 17865247151196156452 +--- !u!114 &978946649210659857 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1965414683581951142} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4d16ab4eb1127ca4eac3cb229241649e, type: 3} + m_Name: + m_EditorClassIdentifier: + _componentIndexCache: 1 + _addedNetworkObject: {fileID: 9154675693299657064} + _networkObjectCache: {fileID: 9154675693299657064} + _menu: {fileID: 6924109542537538210} +--- !u!114 &6241789247798514904 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1965414683581951142} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf5f993f47e925246af5c62ba3290524, type: 3} + m_Name: + m_EditorClassIdentifier: + _slotPrefab: {fileID: 4285405521571209506, guid: 484315627df23dd428819ee4c9e05603, type: 3} + _layerPlacementDropdown: {fileID: 2409669378435090507} + _inputField: {fileID: 5558970035109273631} + _menu: {fileID: 6924109542537538210} + _contentRoot: {fileID: 6243703131314193102} --- !u!1 &2420290731705129391 GameObject: m_ObjectHideFlags: 0 @@ -3803,9 +3831,8 @@ MonoBehaviour: m_OnValueChanged: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 6924109542537538210} - m_TargetAssemblyTypeName: SS3D.Systems.Construction.UI.ConstructionMenu, - SS3D.Systems + - m_Target: {fileID: 6241789247798514904} + m_TargetAssemblyTypeName: TileMapMenuBuildingView, SS3D.Systems m_MethodName: OnDropDownChange m_Mode: 1 m_Arguments: @@ -4202,7 +4229,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &4235739587677223029 RectTransform: m_ObjectHideFlags: 0 @@ -4305,7 +4332,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 2287788854832640797} m_HandleRect: {fileID: 3379647602017452814} m_Direction: 2 - m_Value: 0 + m_Value: 1 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: @@ -4930,7 +4957,7 @@ RectTransform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: -0.000030517578, y: -0.00018310547} m_SizeDelta: {x: 20, y: 20} m_Pivot: {x: 0.5, y: 0.5} @@ -5334,10 +5361,9 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 6924109542537538210} - m_TargetAssemblyTypeName: SS3D.Systems.Construction.UI.ConstructionMenu, - SS3D.Systems - m_MethodName: LoadMap + - m_Target: {fileID: 0} + m_TargetAssemblyTypeName: TileMapMenuSaveAndLoadTabs, SS3D.Systems + m_MethodName: HandleLoadButton m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} diff --git a/Assets/Content/WorldObjects/Entities/Humanoids/Human/Human.prefab b/Assets/Content/WorldObjects/Entities/Humanoids/Human/Human.prefab index ecc8fcf51c..364818273d 100644 --- a/Assets/Content/WorldObjects/Entities/Humanoids/Human/Human.prefab +++ b/Assets/Content/WorldObjects/Entities/Humanoids/Human/Human.prefab @@ -6732,10 +6732,6 @@ MonoBehaviour: - {fileID: 8067289659534850981} - {fileID: 6911900315559804093} - {fileID: 8626656600768578774} - - {fileID: 8522085659551376728} - - {fileID: 5616218768785348228} - - {fileID: 1515245783558115485} - - {fileID: 2474978630392406517} SerializedTransformProperties: Position: {x: 0, y: 0, z: 0} Rotation: {x: 0, y: 0, z: 0, w: 1} @@ -7152,7 +7148,7 @@ MonoBehaviour: _componentIndexCache: 15 _addedNetworkObject: {fileID: 2930813178971533500} _networkObjectCache: {fileID: 2930813178971533500} - _heart: {fileID: 21628525243681339} + _heart: {fileID: 0} _container: {fileID: 6282983976573159881} _healthController: {fileID: 5857269694861021747} --- !u!114 &-8255755562304280350 @@ -10288,7 +10284,7 @@ PrefabInstance: - target: {fileID: 702766120831828262, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 2474978630392406517} + objectReference: {fileID: 0} - target: {fileID: 702766120831828262, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _componentIndexCache value: 2 @@ -10312,7 +10308,7 @@ PrefabInstance: - target: {fileID: 1679913059421053496, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 5616218768785348228} + objectReference: {fileID: 0} - target: {fileID: 1679913059421053496, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _componentIndexCache value: 2 @@ -10336,7 +10332,7 @@ PrefabInstance: - target: {fileID: 1884146052328272359, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 2474978630392406517} + objectReference: {fileID: 0} - target: {fileID: 1884146052328272359, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _componentIndexCache value: 3 @@ -10356,7 +10352,7 @@ PrefabInstance: - target: {fileID: 2609194673879173157, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 1515245783558115485} + objectReference: {fileID: 0} - target: {fileID: 2609194673879173157, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _componentIndexCache value: 3 @@ -10380,7 +10376,7 @@ PrefabInstance: - target: {fileID: 2805978293965679539, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 1515245783558115485} + objectReference: {fileID: 0} - target: {fileID: 2805978293965679539, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _componentIndexCache value: 2 @@ -10728,7 +10724,7 @@ PrefabInstance: - target: {fileID: 8911652692201450867, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 5616218768785348228} + objectReference: {fileID: 0} - target: {fileID: 8911652692201450867, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} propertyPath: _componentIndexCache value: 3 @@ -10752,17 +10748,6 @@ PrefabInstance: - {fileID: 4082103562292691345, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} - {fileID: 1366233335549640606, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} ---- !u!114 &21628525243681339 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 1679913059421053496, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} - m_PrefabInstance: {fileID: 1665371995396548611} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 7e0d645991b499c43ac8ca1478c49742, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!114 &1082206991310670826 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 1736228399463719913, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} @@ -10774,17 +10759,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 25696236470760b41b375e9b6939444c, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &1515245783558115485 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 151903039808960670, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} - m_PrefabInstance: {fileID: 1665371995396548611} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!114 &1689438430210725708 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 31103313540038479, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} @@ -10796,17 +10770,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 692f4890b7494814083561e6206c4334, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &2474978630392406517 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 3838321365547895286, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} - m_PrefabInstance: {fileID: 1665371995396548611} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!114 &2959968424826690301 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 4471929947553035006, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} @@ -10851,17 +10814,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 25696236470760b41b375e9b6939444c, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &5616218768785348228 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 6551688761198755463, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} - m_PrefabInstance: {fileID: 1665371995396548611} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!4 &6806139853968569792 stripped Transform: m_CorrespondingSourceObject: {fileID: 5289709911286111683, guid: 4a9d34a6cf84ef045a740513d8ae30b1, type: 3} @@ -12732,7 +12684,7 @@ PrefabInstance: - target: {fileID: 1126450226401312182, guid: cc54bc74b2f4c2349b1f84b501b0a091, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 8522085659551376728} + objectReference: {fileID: 0} - target: {fileID: 1126450226401312182, guid: cc54bc74b2f4c2349b1f84b501b0a091, type: 3} propertyPath: _componentIndexCache value: 3 @@ -12764,7 +12716,7 @@ PrefabInstance: - target: {fileID: 2516703127647681493, guid: cc54bc74b2f4c2349b1f84b501b0a091, type: 3} propertyPath: _networkObjectCache value: - objectReference: {fileID: 8522085659551376728} + objectReference: {fileID: 0} - target: {fileID: 2516703127647681493, guid: cc54bc74b2f4c2349b1f84b501b0a091, type: 3} propertyPath: _componentIndexCache value: 2 @@ -13881,17 +13833,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3c75d17834848bb4f83ee6e730a65519, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &8522085659551376728 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 2810207769013665548, guid: cc54bc74b2f4c2349b1f84b501b0a091, type: 3} - m_PrefabInstance: {fileID: 5817343205059369556} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1001 &7047651788657661578 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab.meta b/Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab.meta index dcde4811fa..b2e0318893 100644 --- a/Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab.meta +++ b/Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab.meta @@ -1,7 +1,14 @@ fileFormatVersion: 2 +<<<<<<<< HEAD:Assets/Content/Addressables/AssetGroups/Materials.asset.meta +guid: fccdc78a6cf916047ba52f2877f755e5 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 +======== guid: ea5b9b571f8df3948b52b7023aa66c99 PrefabImporter: externalObjects: {} +>>>>>>>> develop:Assets/Content/WorldObjects/Entities/Humanoids/Human/HumanOrgans/HumanHeart.prefab.meta userData: assetBundleName: assetBundleVariant: diff --git a/Assets/DefaultPrefabObjects.asset b/Assets/DefaultPrefabObjects.asset index fd2ee13f38..af0c0109b5 100644 --- a/Assets/DefaultPrefabObjects.asset +++ b/Assets/DefaultPrefabObjects.asset @@ -22,24 +22,9 @@ MonoBehaviour: - {fileID: 8203177977882359099, guid: 6ab4ce7059d374a4498481e1385c222e, type: 3} - {fileID: 6636680625000353110, guid: cc5383d385556f443b2a7d3202f2b2c1, type: 3} - {fileID: 3227132888119106738, guid: 7bbb74a7ffc8cae44baa886de43c586b, type: 3} + - {fileID: 4294524822034227355, guid: 8dc5399c58290d54f9a6cc2f6c1c9d9f, type: 3} - {fileID: 1871071288925904272, guid: add4d1bc2d874d94782d6b8c912af5e2, type: 3} - {fileID: 4220345139042552220, guid: 0188e95eec8518246940499957802de9, type: 3} - - {fileID: 8532088199163376958, guid: 9659c4cc7bea07c4ba38b492f407ef7f, type: 3} - - {fileID: 8532088199163376958, guid: 2f664501d8d74774c9427f7fb6d50ae6, type: 3} - - {fileID: 8532088199163376958, guid: 229b5ce92c3d9164e845f68308a037a2, type: 3} - - {fileID: 8532088199163376958, guid: 2081061d3c98e50408979ea90372c244, type: 3} - - {fileID: 8532088199163376958, guid: 6687a95358e52a348aaf6179f3c252f2, type: 3} - - {fileID: 171614716955879869, guid: 60890cc80962a7e44b97b4ba3b0518e3, type: 3} - - {fileID: 8532088199163376958, guid: 4d59bb658831172479995d721f8cbd6c, type: 3} - - {fileID: 8532088199163376958, guid: df85b75fd341a244c8364ebb9c4fcfef, type: 3} - - {fileID: 8532088199163376958, guid: c19eccca279beee4186432a03257a7b9, type: 3} - - {fileID: 8532088199163376958, guid: 9ac7c2cd12db800479e566335ff7440b, type: 3} - - {fileID: 8532088199163376958, guid: 8b2b80e8392e44944a184d9166ce97b1, type: 3} - - {fileID: 8532088199163376958, guid: 2d0913074150cca43b88c90ec658aacb, type: 3} - - {fileID: -4360250799920595422, guid: 983acf51173ef60479e35c5e35946162, type: 3} - - {fileID: 8532088199163376958, guid: 57d15c94003230048bd96a5bc7115bc2, type: 3} - - {fileID: 8532088199163376958, guid: 9d475ae6ec7b7a749abae10066b336be, type: 3} - - {fileID: 8532088199163376958, guid: 885d5a9c5776fd64ab1cf595e0cfd9d8, type: 3} - {fileID: 6115335805774105745, guid: bf177f8bab26bc84b87fd9a971004418, type: 3} - {fileID: 6699414010407460003, guid: f1aeab0a35c29314a8a3f823de9815c1, type: 3} - {fileID: 4692070367735979832, guid: 8725b7f8f45d28a4ba6063318904cc8a, type: 3} @@ -94,6 +79,7 @@ MonoBehaviour: - {fileID: 1019513474262773944, guid: 06c946c7c639138488b814e4448b82e4, type: 3} - {fileID: -9151722837240714421, guid: 41d7af24659a0d3439668aeb4c46d9bc, type: 3} - {fileID: 8320282919264059031, guid: 8ae2f499d25bfcd41bf26b735c852ab1, type: 3} + - {fileID: 8031370004641457100, guid: 85fa4c9b76b4b23458dcf24a745a1dfe, type: 3} - {fileID: 8095612838085175437, guid: 5a09b3e93f0022b468da150e3c4a78c6, type: 3} - {fileID: -6797522191161373784, guid: 11d64ed349b96ec4780c4dda0ad89daf, type: 3} - {fileID: -5414623717715724467, guid: 7b74e45100446b440b4b0a12cd6d05ef, type: 3} @@ -143,7 +129,7 @@ MonoBehaviour: - {fileID: 8532088199163376958, guid: eea05d13801552e46b6083adad76e601, type: 3} - {fileID: 8532088199163376958, guid: 7579883b8dd8801448a176adace4860b, type: 3} - {fileID: 8532088199163376958, guid: 071581df025e1ba49a8a75eb39611ff6, type: 3} - - {fileID: 4159476743201579799, guid: ea5b9b571f8df3948b52b7023aa66c99, type: 3} + - {fileID: 4159476743201579799, guid: fccdc78a6cf916047ba52f2877f755e5, type: 3} - {fileID: 8532088199163376958, guid: 1e304f9a331c2ba419514ef8afb8a13c, type: 3} - {fileID: 8532088199163376958, guid: 9c5418cbebef419429574992d3e296a3, type: 3} - {fileID: 8532088199163376958, guid: d75ff9a3ac207a84487ec1ee73a676fc, type: 3} @@ -152,6 +138,8 @@ MonoBehaviour: - {fileID: 8532088199163376958, guid: 2bc6f6a968d5ba04c919ba56d0ccdab4, type: 3} - {fileID: 354436423397270740, guid: 7a895b269e3f67241af148d25331f5af, type: 3} - {fileID: 5640352947892099654, guid: 4a1bd08646e8e1f4a861960d9b7485f8, type: 3} + - {fileID: -9158575437637332483, guid: e9009aff81f29eb429148fd71961539f, type: 3} + - {fileID: -908405258838932631, guid: 672b544ba53de0144aab307a16b085cb, type: 3} - {fileID: 6244957436306937818, guid: 4d48472d06930bd42a15897e6a1794ac, type: 3} - {fileID: 5716146803221059512, guid: ebddb1721dcbe36499e4d093e5a7ff09, type: 3} - {fileID: 8635336608555116780, guid: 6caa99f8281726e40a793826d5c047db, type: 3} diff --git a/Assets/Scripts/SS3D/Data/Enums/AssetDatabases.cs b/Assets/Scripts/SS3D/Data/Enums/AssetDatabases.cs index 2ce1940e7c..a6958cde09 100644 --- a/Assets/Scripts/SS3D/Data/Enums/AssetDatabases.cs +++ b/Assets/Scripts/SS3D/Data/Enums/AssetDatabases.cs @@ -6,11 +6,12 @@ public enum AssetDatabases CraftingRecipes = 1, InteractionIcons = 2, Items = 3, - ParticlesEffects = 4, - Scenes = 5, - Settings = 6, - Sounds = 7, - UIElements = 8, + Materials = 4, + ParticlesEffects = 5, + Scenes = 6, + Settings = 7, + Sounds = 8, + UIElements = 9, } } diff --git a/Assets/Scripts/SS3D/Data/Enums/BodyPartsIds.cs b/Assets/Scripts/SS3D/Data/Enums/BodyPartsIds.cs index 32923f2c66..2100e62503 100644 --- a/Assets/Scripts/SS3D/Data/Enums/BodyPartsIds.cs +++ b/Assets/Scripts/SS3D/Data/Enums/BodyPartsIds.cs @@ -18,10 +18,10 @@ public enum BodyPartsIds HumanLungLeft = 13, HumanStomach = 14, HumanLiver = 15, - HumanHeart = 16, - HumanIntestineLarge = 17, - HumanEye = 18, - HumanBrain = 19, + HumanIntestineLarge = 16, + HumanEye = 17, + HumanBrain = 18, + HumanHeart = 19, } } diff --git a/Assets/Scripts/SS3D/Data/Enums/ItemId.cs b/Assets/Scripts/SS3D/Data/Enums/ItemId.cs index c4e0edbdd3..516b2de197 100644 --- a/Assets/Scripts/SS3D/Data/Enums/ItemId.cs +++ b/Assets/Scripts/SS3D/Data/Enums/ItemId.cs @@ -46,20 +46,6 @@ public enum ItemId JumpsuitSecurity = 41, HeadsetLeft = 42, HeadsetRight = 43, - HumanBrain = 44, - HumanFootRight = 45, - HumanFootLeft = 46, - HumanTorso = 47, - HumanHandLeft = 48, - HumanHandRight = 49, - HumanLegLeft = 50, - HumanLegRight = 51, - HumanArmLeft = 52, - HumanArmRight = 53, - HumanHead = 54, - HumanLungLeft = 55, - HumanLungRight = 56, - HumanHeart = 57, } } diff --git a/Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs b/Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs new file mode 100644 index 0000000000..21f149bd80 --- /dev/null +++ b/Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs @@ -0,0 +1,10 @@ +namespace SS3D.Data.Enums +{ + public enum MaterialsIds + { + DeleteConstruction = 0, + InvalidConstruction = 1, + ValidConstruction = 2, + } +} + diff --git a/Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs.meta b/Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs.meta new file mode 100644 index 0000000000..27384d7258 --- /dev/null +++ b/Assets/Scripts/SS3D/Data/Enums/MaterialsIds.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6820f2a28e45dc04d9a3d5dfd92d614b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs new file mode 100644 index 0000000000..2e44f1cfc1 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs @@ -0,0 +1,192 @@ +using Coimbra; +using Coimbra.Services.Events; +using Coimbra.Services.PlayerLoopEvents; +using SS3D.Core; +using SS3D.Systems.Tile; +using SS3D.Systems.Tile.TileMapCreator; +using SS3D.Systems.Tile.UI; +using System; +using System.Collections.Generic; +using System.Linq; +using TMPro; +using UnityEngine; +using UnityEngine.UI; +using Actor = SS3D.Core.Behaviours.Actor; + +/// +/// Handle the UI and displaying everything related to the tilemap menu building part. +/// +public class AssetGrid : Actor +{ + /// + /// The model for a single slot, to display tile objects in the menu. + /// + [SerializeField] + private GameObject _slotPrefab; + + /// + /// Dropdown to select the layer to display in the menu. + /// + [SerializeField] + private TMP_Dropdown _layerPlacementDropdown; + + /// + /// List of tile objects and items to load in the tilemap menu, that will show in the slots. + /// + private List _objectDatabase; + + /// + /// Script orchestrating the menu UI. + /// + [SerializeField] + private TileMapMenu _menu; + + /// + /// Game object parent of the area in the tile map menu where the tile object slots will display. + /// + [SerializeField] + private GameObject _contentRoot; + + private TileSystem _tileSystem; + + public void Setup() + { + AddHandle(UpdateEvent.AddListener(HandleUpdate)); + _tileSystem= Subsystems.Get(); + LoadObjectGrid(new[] { TileLayer.Plenum }, false); + } + + private void HandleUpdate(ref EventContext context, in UpdateEvent updateEvent) + { + AdjustGridWidth(); + } + + /// + /// Show assets, that contain given string in their name. + /// + public void FindAssets(string text) + { + text = text.Replace(' ', '_'); + ClearGrid(); + foreach (GenericObjectSo asset in _objectDatabase) + { + if (!asset.nameString.Contains(text)) continue; + Instantiate(_slotPrefab, _contentRoot.transform, true).GetComponent().Setup(asset); + } + } + + /// + /// Load a list of tile objects and place them in the UI box grid. + /// + private void LoadObjectGrid(TileLayer[] allowedLayers, bool isItems) + { + ClearGrid(); + _objectDatabase = _tileSystem.Loader.Assets; + foreach (GenericObjectSo asset in _objectDatabase) + { + switch (isItems) + { + case true when asset is not ItemObjectSo: + case false when asset is ItemObjectSo: + case false when asset is TileObjectSo so && !allowedLayers.Contains(so.layer): + continue; + } + Instantiate(_slotPrefab, _contentRoot.transform, true).GetComponent().Setup(asset); + } + } + + /// + /// Change the currently displayed tiles/items when a new layer is selected in the drop down menu. + /// + private void OnDropDownChange() + { + int index = _layerPlacementDropdown.value; + bool isItems = false; + TileLayer[] layers = null; + switch (index) + { + case 0: + layers = new[] { TileLayer.Plenum }; + break; + + case 1: + layers = new[] { TileLayer.Turf }; + break; + + case 2: + layers = new[] + { + TileLayer.FurnitureBase, + TileLayer.FurnitureTop + }; + break; + + case 3: + layers = new[] + { + TileLayer.WallMountLow, + TileLayer.WallMountHigh + }; + break; + + case 4: + layers = new[] + { + TileLayer.Wire, + TileLayer.Disposal, + TileLayer.PipeLeft, + TileLayer.PipeRight, + TileLayer.PipeSurface, + TileLayer.PipeMiddle + }; + break; + + case 5: + layers = new[] + { + TileLayer.Overlays + }; + break; + + case 6: + LoadObjectGrid(null, true); + isItems = true; + break; + + default: + ClearGrid(); + break; + } + + if ((layers != null) || isItems) + { + LoadObjectGrid(layers, isItems); + } + } + + /// + /// Change number of columns in asset grid to fit it's width. + /// Elements of the group will take as much width as possible, but won't exceed width of the menu. + /// + private void AdjustGridWidth() + { + GridLayoutGroup grid = _contentRoot.GetComponent(); + float cellWidth = grid.cellSize.x; + float paddingWidth = grid.spacing.x; + float width = _menu.GetComponent().rect.width; + int constraintCount = Convert.ToInt32(Math.Floor(width / (cellWidth + paddingWidth))); + if (constraintCount != grid.constraintCount) + grid.constraintCount = constraintCount; + } + + /// + /// Clear all tile slots in the content area of the tilemap menu. + /// + private void ClearGrid() + { + for (int i = 0; i < _contentRoot.transform.childCount; i++) + { + _contentRoot.transform.GetChild(i).gameObject.Dispose(true); + } + } +} diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs.meta new file mode 100644 index 0000000000..f21d2e5875 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetGrid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cf5f993f47e925246af5c62ba3290524 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreatorTab.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetSlot.cs similarity index 62% rename from Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreatorTab.cs rename to Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetSlot.cs index 48281114a8..fb95a7dbe7 100644 --- a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreatorTab.cs +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetSlot.cs @@ -1,3 +1,4 @@ +using SS3D.Systems.Tile.TileMapCreator; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -5,13 +6,14 @@ namespace SS3D.Systems.Tile.UI { /// - /// Tab that holds information for each item/tile in the TileMapCreator UI. + /// Slot that holds information for each item/tile in the TileMapCreator UI. + /// They get created when the tilemap menu spawns. /// - public class TileMapCreatorTab : MonoBehaviour + public class AssetSlot : MonoBehaviour { private GenericObjectSo _genericObjectSo; - private TileMapCreator.TileMapCreator _menu; + private ConstructionHologramManager _hologramManager; /// /// Load an UI icon and string for the item/tile. /// @@ -22,12 +24,13 @@ public void Setup(GenericObjectSo genericObjectSo) GetComponent().sprite = genericObjectSo.icon; transform.localScale = Vector3.one; GetComponentInChildren().text = genericObjectSo.nameString; - _menu = GetComponentInParent(); + + _hologramManager = GetComponentInParent(); } public void OnClick() { - _menu.SetSelectedObject(_genericObjectSo); + _hologramManager.SetSelectedObject(_genericObjectSo); } } } \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreatorTab.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetSlot.cs.meta similarity index 100% rename from Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreatorTab.cs.meta rename to Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/AssetSlot.cs.meta diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/BuildGhost.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/BuildGhost.cs deleted file mode 100644 index 62b8dddbd3..0000000000 --- a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/BuildGhost.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Coimbra.Services.Events; -using Coimbra.Services.PlayerLoopEvents; -using UnityEngine; -using Actor = SS3D.Core.Behaviours.Actor; - -namespace SS3D.Systems.Tile.TileMapCreator -{ - /// - /// Class for managing ghost objects, that will be used for building or deleting by TileMapCreator. - /// - public class BuildGhost: Actor - { - private Material _validConstruction; - private Material _invalidConstruction; - private Material _deleteConstruction; - public Vector3 TargetPosition; - public Direction Dir { get; set; } = Direction.North; - public enum BuildMatMode - { - Valid, - Invalid, - Delete - } - public void SetupMaterials(Material validConstruction, Material invalidConstruction, Material deleteConstruction) - { - _validConstruction = validConstruction; - _invalidConstruction = invalidConstruction; - _deleteConstruction = deleteConstruction; - } - - protected override void OnStart() - { - base.OnStart(); - AddHandle(UpdateEvent.AddListener(HandleUpdate)); - if (TryGetComponent(out Rigidbody ghostRigidbody)) - { - ghostRigidbody.useGravity = false; - ghostRigidbody.isKinematic = true; - } - Collider[] colliders = GetComponentsInChildren(); - foreach (Collider col in colliders) - { - col.enabled = false; - } - } - - private void HandleUpdate(ref EventContext context, in UpdateEvent updateEvent) - { - // Small offset is added so that meshes don't overlap with already placed objects. - transform.position = Vector3.Lerp(transform.position, TargetPosition + new Vector3(0, 0.1f, 0), Time.deltaTime * 15f); - transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, TileHelper.GetRotationAngle(Dir), 0), Time.deltaTime * 15f); - } - - /// - /// Chooses which material to set on the ghost based on which mode we are building. - /// - /// - public void ChangeGhostColor(BuildMatMode mode) - { - Material ghostMat = null; - - switch (mode) - { - case BuildMatMode.Valid: - ghostMat = _validConstruction; - break; - - case BuildMatMode.Invalid: - ghostMat = _invalidConstruction; - break; - - case BuildMatMode.Delete: - ghostMat = _deleteConstruction; - break; - } - - foreach (MeshRenderer mr in GetComponentsInChildren()) - { - Material[] materials = mr.materials; - for (int i = 0; i < materials.Length; i++) - { - materials[i] = ghostMat; - } - - mr.materials = materials; - } - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs new file mode 100644 index 0000000000..919e3f2acb --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs @@ -0,0 +1,119 @@ +using Coimbra; +using SS3D.Data; +using SS3D.Data.Enums; +using System.Linq; +using UnityEngine; + +namespace SS3D.Systems.Tile.TileMapCreator +{ + /// + /// Represent a hologram tile object used for construction, through the tilemap menu. + /// + public class ConstructionHologram + { + private GameObject _hologram; + private Vector3 _position; + private Direction _direction; + public Direction Direction => _direction; + public bool ActiveSelf => _hologram.activeSelf; + public bool SetActive { set => _hologram.SetActive(value); } + public Vector3 Position { get => _position; set => _position = value; } + + /// + /// Build a new hologram + /// + /// the game object we want to make a hologram from. + /// the initial position of the hologram in space. + /// the expected original direction. Note that not all directions are compatible with + /// all tile objects. If it's not, it will choose another available direction. + public ConstructionHologram(GameObject ghostObject, Vector3 targetPosition, Direction dir) + { + _hologram = ghostObject; + _position = targetPosition; + _direction = dir; + + if (ghostObject.TryGetComponent(out ICustomGhostRotation customRotationComponent) + && !customRotationComponent.GetAllowedRotations().Contains(dir)) + { + _direction = customRotationComponent.DefaultDirection; + } + + if (ghostObject.TryGetComponent(out Rigidbody ghostRigidbody)) + { + ghostRigidbody.useGravity = false; + ghostRigidbody.isKinematic = true; + } + var colliders = ghostObject.GetComponentsInChildren(); + foreach (Collider col in colliders) + { + col.enabled = false; + } + } + + /// + /// Chooses which material to set on the ghost based on which mode we are building. + /// + /// + public void ChangeHologramColor(ConstructionMode mode) + { + Material ghostMat = null; + + switch (mode) + { + case ConstructionMode.Valid: + ghostMat = Assets.Get((int)AssetDatabases.Materials, (int)MaterialsIds.ValidConstruction); + break; + + case ConstructionMode.Invalid: + ghostMat = Assets.Get((int)AssetDatabases.Materials, (int)MaterialsIds.InvalidConstruction); + break; + + case ConstructionMode.Delete: + ghostMat = Assets.Get((int)AssetDatabases.Materials, (int)MaterialsIds.DeleteConstruction); + break; + } + + + foreach (MeshRenderer mr in _hologram.GetComponentsInChildren()) + { + Material[] materials = mr.materials; + for (int i = 0; i < materials.Length; i++) + { + materials[i] = ghostMat; + } + + mr.materials = materials; + } + } + + /// + /// Smoothly change rotation and position for better visual effects. + /// + public void UpdateRotationAndPosition() + { + // Small offset is added so that meshes don't overlap with already placed objects. + _hologram.transform.position = Vector3.Lerp(_hologram.transform.position, _position + new Vector3(0, 0.1f, 0), Time.deltaTime * 15f); + _hologram.transform.rotation = Quaternion.Lerp(_hologram.transform.rotation, Quaternion.Euler(0, TileHelper.GetRotationAngle(_direction), 0), Time.deltaTime * 15f); + } + + /// + /// Set the next allowed rotation, depends on the tile object. + /// + public void SetNextRotation() + { + if (_hologram.TryGetComponent(out ICustomGhostRotation customRotationComponent)) + { + _direction = customRotationComponent.GetNextDirection(_direction); + } + else + { + _direction = TileHelper.GetNextCardinalDir(_direction); + } + } + + public void Destroy() + { + _hologram.Dispose(true); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs.meta new file mode 100644 index 0000000000..a43ce20be0 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologram.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a50fdc25aaa4ae4484273f5a646b7e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologramManager.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologramManager.cs new file mode 100644 index 0000000000..fc24b11f40 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologramManager.cs @@ -0,0 +1,376 @@ +using Coimbra.Services.Events; +using Coimbra.Services.PlayerLoopEvents; +using FishNet.Connection; +using FishNet.Object; +using SS3D.Core; +using SS3D.Core.Behaviours; +using SS3D.Logging; +using SS3D.Systems.Inputs; +using SS3D.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.InputSystem; +using InputSystem = SS3D.Systems.Inputs.InputSystem; + +namespace SS3D.Systems.Tile.TileMapCreator +{ + /// + /// Class for managing tile objects, that will be used for building or deleting by the tile map menu. + /// It handles creating construction holograms, replacing, adding or deleting tile objects and items upon placement, + /// and placing the holograms in cool shapes like lines and squares. + /// + public class ConstructionHologramManager : NetworkActor + { + /// + /// The last direction registered by a build ghost. + /// + private Direction _lastRegisteredDirection; + private InputSystem _inputSystem; + private Controls.TileCreatorActions _controls; + private bool _isPlacingItem = false; + /// + /// Snapped position are positions in the center of tiles, to display tile objects ghosts properly. + /// + private Vector3 _lastSnappedPosition; + /// + /// The snapped position of the mouse, in the middle of a tile, when the player starts dragging with the mouse. + /// + private Vector3 _dragStartPostion; + /// + /// Is the player currently dragging ? + /// + public bool IsDragging => _isDragging; + private bool _isDragging; + private GenericObjectSo _selectedObject; + /// + /// List of build ghosts currently displaying in game. + /// + private List _holograms = new(); + + [SerializeField] + private TileMapMenu _menu; + + public void SetSelectedObject(GenericObjectSo genericObjectSo) + { + _isPlacingItem = genericObjectSo switch + { + TileObjectSo => false, + ItemObjectSo => true, + _ => _isPlacingItem, + }; + _selectedObject = genericObjectSo; + + DestroyHolograms(); + CreateHologram(genericObjectSo.prefab, TileHelper.GetPointedPosition(!_isPlacingItem)); + } + + protected override void OnStart() + { + base.OnStart(); + AddHandle(UpdateEvent.AddListener(HandleUpdate)); + _inputSystem = Subsystems.Get(); + _controls = _inputSystem.Inputs.TileCreator; + _controls.Place.started += HandlePlaceStarted; + _controls.Place.performed += HandlePlacePerformed; + _controls.Replace.performed += HandleReplace; + _controls.Replace.canceled += HandleReplace; + _controls.Rotate.performed += HandleRotate; + } + + private void HandleUpdate(ref EventContext context, in UpdateEvent updateEvent) + { + foreach (ConstructionHologram hologram in _holograms) + { + hologram.UpdateRotationAndPosition(); + } + + ActivateGhosts(); + + Vector3 position = TileHelper.GetPointedPosition(!_isPlacingItem); + // Move hologram, that sticks to the mouse. Currently it exists only if player is not dragging. + if (_holograms.Count == 1) + { + _holograms.First().Position = position; + if (position != _lastSnappedPosition) + { + RefreshHologram(_holograms.First()); + } + } + + if (_isDragging && (position != _lastSnappedPosition) && (_selectedObject != null)) + { + // Delete all ghosts and instantiate new on correct positions. Currently it causes large fps drops. + DestroyHolograms(); + if (_controls.SquareDrag.phase == InputActionPhase.Performed) + { + SquareDrag(position); + } + else + { + LineDrag(position); + } + } + _lastSnappedPosition = position; + } + + /// + /// Rotate all existing ghosts in the next allowed rotation. + /// + public void SetNextRotation() + { + foreach (ConstructionHologram hologram in _holograms) + { + hologram.SetNextRotation(); + RefreshHologram(hologram); + } + _lastRegisteredDirection = _holograms.First().Direction; + } + + /// + /// Instantiate in the correct position and rotation a single hologram. + /// + public ConstructionHologram CreateHologram(GameObject prefab, Vector3 position) + { + GameObject tileObject = Instantiate(prefab); + ConstructionHologram hologram = new(tileObject, position, _lastRegisteredDirection); + tileObject.transform.rotation = Quaternion.Euler(0, TileHelper.GetRotationAngle(hologram.Direction), 0); + tileObject.transform.position = hologram.Position; + _holograms.Add(hologram); + RefreshHologram(hologram); + return hologram; + } + + /// + /// Destroy all existing holograms. + /// + public void DestroyHolograms() + { + for (int i = _holograms.Count - 1; i >= 0; i--) + { + _holograms[i].Destroy(); + } + _holograms.Clear(); + } + + /// + /// Called upon control triggered to rotate holograms. + /// + private void HandleRotate(InputAction.CallbackContext context) + { + SetNextRotation(); + } + + /// + /// This is called when the player start dragging hologramss. + /// + private void HandlePlaceStarted(InputAction.CallbackContext context) + { + // Dragging is disabled for items + if (_isPlacingItem) + return; + + _isDragging = true; + _dragStartPostion = TileHelper.GetPointedPosition(true); + } + + /// + /// Method called when the tile objects are placed or deleted. + /// + private void HandlePlacePerformed(InputAction.CallbackContext context) + { + _isDragging = false; + + if (_menu.MouseOverUI) + { + _inputSystem.ToggleAction(_controls.Place, false); + } + + if (!_menu.IsDeleting) + { + PlaceOnHolograms(); + } + else + { + DeleteOnHolograms(); + } + + DestroyHolograms(); + + if (_selectedObject == null) return; + CreateHologram(_selectedObject.prefab, TileHelper.GetPointedPosition(!_isPlacingItem)); + } + + /// + /// Called when the control is triggered to replace already present tile objects with new ones. + /// + /// + private void HandleReplace(InputAction.CallbackContext context) + { + foreach (ConstructionHologram buildGhost in _holograms) + { + RefreshHologram(buildGhost); + } + } + + /// + /// Place all objects on the tilemap that are at the same locations as existing holograms. + /// + private void PlaceOnHolograms() + { + bool isReplacing = _controls.Replace.phase == InputActionPhase.Performed; + + foreach (ConstructionHologram buildGhost in _holograms) + { + Subsystems.Get().RpcPlaceObject(_selectedObject.nameString, buildGhost.Position, buildGhost.Direction, isReplacing); + } + } + + /// + /// Delete all objects, that are at the same locations as existing holograms. + /// + private void DeleteOnHolograms() + { + if (_isPlacingItem) + { + FindAndDeleteItem(); + } + else + { + foreach (ConstructionHologram hologram in _holograms) + { + Subsystems.Get().RpcClearTileObject(_selectedObject.nameString, hologram.Position, hologram.Direction); + } + } + } + + /// + /// Update material of holograms based build (or anything else) mode and holograms position + /// + private void RefreshHologram(ConstructionHologram hologram) + { + if (_menu.IsDeleting) + { + hologram.ChangeHologramColor(ConstructionMode.Delete); + } + else if (_isPlacingItem) + { + hologram.ChangeHologramColor(ConstructionMode.Valid); + } + else + { + bool isReplacing = _controls.Replace.phase == InputActionPhase.Performed; + RpcSendCanBuild(_selectedObject.nameString, hologram.Position, hologram.Direction, isReplacing, LocalConnection); + } + } + + /// + /// Activate all buildGhosts. This method is important, because for some reason network objects disable themselves after a few frames. + /// + private void ActivateGhosts() + { + foreach (ConstructionHologram buildGhost in _holograms) + { + if (!buildGhost.ActiveSelf) + { + buildGhost.SetActive = true; + } + } + } + + /// + /// Starting from a given position, create holograms along a line defined by dragging. + /// + private void LineDrag(Vector3 position) + { + Vector2 firstPoint = new(_dragStartPostion.x, _dragStartPostion.z); + Vector2 secondPoint = new(position.x, position.z); + Vector3[] tiles = MathUtility.FindTilesOnLine(firstPoint, secondPoint) + .Select(x => new Vector3(x.x, position.y, x.y)).ToArray(); + + foreach (Vector3 tile in tiles) + { + RefreshHologram(CreateHologram(_selectedObject.prefab, tile)); + } + } + + [ServerRpc(RequireOwnership = false)] + private void RpcSendCanBuild(string tileObjectSoName, Vector3 placePosition, Direction dir, bool replaceExisting, NetworkConnection conn) + { + + TileSystem tileSystem = Subsystems.Get(); + + TileObjectSo tileObjectSo = (TileObjectSo)tileSystem.GetAsset(tileObjectSoName); + + if (tileObjectSo == null) + { + Log.Error(this, "Asset is not found"); + return; + } + + bool canBuild = tileSystem.CanBuild(tileObjectSo, placePosition, dir, replaceExisting); + RpcReceiveCanBuild(conn, placePosition, canBuild); + } + + [TargetRpc] + private void RpcReceiveCanBuild(NetworkConnection conn, Vector3 placePosition, bool canBuild) + { + // Find correct hologram to update its material + for (int i = 0; i < _holograms.Count; i++) + { + ConstructionHologram hologram = _holograms[i]; + if (hologram.Position != placePosition) continue; + + if (canBuild) + { + hologram.ChangeHologramColor(ConstructionMode.Valid); + } + else + { + hologram.ChangeHologramColor(ConstructionMode.Invalid); + } + return; + } + } + + /// + /// Create a square of objects holograms. + /// + /// Fist position of the square + private void SquareDrag(Vector3 position) + { + int x1 = (int)Math.Min(_dragStartPostion.x, position.x); + int x2 = (int)Math.Max(_dragStartPostion.x, position.x); + int y1 = (int)Math.Min(_dragStartPostion.z, position.z); + int y2 = (int)Math.Max(_dragStartPostion.z, position.z); + + for (int i = y1; i <= y2; i++) + { + for (int j = x1; j <= x2; j++) + { + Vector3 tile = new(j, 0, i); + ConstructionHologram hologram = CreateHologram(_selectedObject.prefab, tile); + RefreshHologram(hologram); + } + } + } + + /// + /// Method called when trying to delete an item from the tilemap (as opposed to a tile object). + /// Items need a special method because they are not tied to specific coordinates like tile objects. + /// + private void FindAndDeleteItem() + { + Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); + if (Physics.Raycast(ray, out RaycastHit hitInfo)) + { + PlacedItemObject placedItem = hitInfo.collider.gameObject.GetComponent(); + if (placedItem != null) + { + Subsystems.Get().RpcClearItemObject(placedItem.NameString, placedItem.gameObject.transform.position); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/BuildGhost.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologramManager.cs.meta similarity index 100% rename from Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/BuildGhost.cs.meta rename to Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionHologramManager.cs.meta diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs new file mode 100644 index 0000000000..7c5b651d88 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs @@ -0,0 +1,9 @@ +namespace SS3D.Systems.Tile.TileMapCreator +{ + public enum ConstructionMode + { + Valid, + Invalid, + Delete + } +} \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs.meta new file mode 100644 index 0000000000..ae6a82368c --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ConstructionMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 73ffed75079ec204985d8652829e5c8f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ICustomGhostRotation.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ICustomGhostRotation.cs index f0a1eb619c..266b9c87f9 100644 --- a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ICustomGhostRotation.cs +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/ICustomGhostRotation.cs @@ -1,15 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using SS3D.Logging; -using SS3D.Systems.Inputs; -using SS3D.Systems.Tile.UI; -using System.Linq; -using TMPro; -using UnityEngine.EventSystems; -using UnityEngine.InputSystem; - -namespace SS3D.Systems.Tile.TileMapCreator +namespace SS3D.Systems.Tile.TileMapCreator { /// /// This interface is to be implemented for game objects which need to have special rotations, outside of diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreator.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreator.cs deleted file mode 100644 index 0aa59832de..0000000000 --- a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreator.cs +++ /dev/null @@ -1,626 +0,0 @@ -using Coimbra; -using Coimbra.Services.Events; -using Coimbra.Services.PlayerLoopEvents; -using DynamicPanels; -using FishNet.Connection; -using FishNet.Object; -using SS3D.Core; -using SS3D.Core.Behaviours; -using SS3D.Logging; -using SS3D.Systems.Inputs; -using SS3D.Systems.Tile.UI; -using SS3D.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using TMPro; -using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.InputSystem; -using UnityEngine.UI; -using InputSystem = SS3D.Systems.Inputs.InputSystem; - -namespace SS3D.Systems.Tile.TileMapCreator -{ - /// - /// In-game editor for placing and deleting items/objects in a tilemap. - /// - public class TileMapCreator : NetworkSystem, IPointerEnterHandler, IPointerExitHandler - { - [SerializeField] - private GameObject _menuRoot; - [SerializeField] - private GameObject _contentRoot; - [SerializeField] - private GameObject _slotPrefab; - [SerializeField] - private TMP_Dropdown _layerPlacementDropdown; - [SerializeField] - private TMP_InputField _inputField; - [SerializeField] - private Material _validConstruction; - [SerializeField] - private Material _invalidConstruction; - [SerializeField] - private Material _deleteConstruction; - - private bool _enabled = false; - private bool _itemPlacement = false; - private bool _mouseOverUI = false; - - private Vector3 _lastSnappedPosition; - private GenericObjectSo _selectedObject; - - private TileSystem _tileSystem; - private List _buildGhosts; - - private List _objectDatabase; - private Controls.TileCreatorActions _controls; - private InputSystem _inputSystem; - private PanelTab _tab; - - private Vector3 _dragStartPostion; - private bool _isDragging; - private bool _isDeleting; - private Direction _direction = Direction.North; - private ICustomGhostRotation _ghostRotations; - private List _ghostsToRefresh; - - protected override void OnStart() - { - base.OnStart(); - AddHandle(UpdateEvent.AddListener(HandleUpdate)); - _tab = PanelUtils.GetAssociatedTab(GetComponent()); - _buildGhosts = new(); - _ghostsToRefresh = new(); - ShowUI(false); - _inputSystem = Subsystems.Get(); - _controls = _inputSystem.Inputs.TileCreator; - _inputSystem.ToggleAction(_controls.ToggleMenu, true); - _controls.ToggleMenu.performed += HandleToggleMenu; - _controls.Place.started += HandlePlaceStarted; - _controls.Place.performed += HandlePlacePerformed; - _controls.Replace.performed += HandleReplace; - _controls.Replace.canceled += HandleReplace; - _controls.Rotate.performed += HandleRotate; - } - - private void HandleUpdate(ref EventContext context, in UpdateEvent updateEvent) - { - ActivateGhosts(); - AdjustGridWidth(); - - Vector3 position = TileHelper.GetPointedPosition(!_itemPlacement); - // Move buildGhost, that sticks to the mouse. Currently it exists only if player is not dragging. - if (_buildGhosts.Count == 1) - { - _buildGhosts.First().TargetPosition = position; - if (position != _lastSnappedPosition) - { - RefreshGhost(_buildGhosts.First()); - } - } - - if (_isDragging && (position != _lastSnappedPosition) && (_selectedObject != null)) - { - // Delete all ghosts and instantiate new on correct positions. Currently it causes large fps drops. - ClearGhosts(); - if (_controls.SquareDrag.phase == InputActionPhase.Performed) - { - SquareDrag(position); - } - else - { - LineDrag(position); - } - } - _lastSnappedPosition = position; - } - - #region Handlers - public void HandleDeleteButton() - { - _isDeleting = true; - } - - public void HandleBuildButton() - { - _isDeleting = false; - } - - private void HandleRotate(InputAction.CallbackContext context) - { - if (_ghostRotations != null) - { - _direction = _ghostRotations.GetNextDirection(_direction); - } - else - { - _direction = TileHelper.GetNextCardinalDir(_direction); - } - foreach (BuildGhost buildGhost in _buildGhosts) - { - buildGhost.Dir = _direction; - } - } - - private void HandlePlaceStarted(InputAction.CallbackContext context) - { - // Dragging is disabled for items - if (_itemPlacement) - return; - - _isDragging = true; - _dragStartPostion = TileHelper.GetPointedPosition(true); - } - - private void HandlePlacePerformed(InputAction.CallbackContext context) - { - _isDragging = false; - - if (_mouseOverUI) - { - _inputSystem.ToggleAction(_controls.Place, false); - } - - if (!_isDeleting) - { - PlaceOnGhosts(); - } - else - { - DeleteOnGhosts(); - } - ClearGhosts(); - - if (_selectedObject == null) return; - _buildGhosts.Add(CreateGhost(_selectedObject.prefab, TileHelper.GetPointedPosition(!_itemPlacement), _direction)); - } - - private void HandleReplace(InputAction.CallbackContext context) - { - foreach (BuildGhost buildGhost in _buildGhosts) - { - RefreshGhost(buildGhost); - } - } - - private void HandleToggleMenu(InputAction.CallbackContext context) - { - if (_enabled) - { - _inputSystem.ToggleActionMap(_controls, false, new[] { _controls.ToggleMenu }); - _inputSystem.ToggleCollisions(_controls, true); - } - else - { - _inputSystem.ToggleActionMap(_controls, true, new[] { _controls.ToggleMenu }); - _inputSystem.ToggleCollisions(_controls, false); - } - _enabled = !_enabled; - ShowUI(_enabled); - _tileSystem = Subsystems.Get(); - LoadObjectGrid(new[] { TileLayer.Plenum }, false); - } - - /// - /// Place all objects form buildGhost - /// - private void PlaceOnGhosts() - { - bool isReplacing = _controls.Replace.phase == InputActionPhase.Performed; - - foreach (BuildGhost buildGhost in _buildGhosts) - { - _tileSystem.RpcPlaceObject(_selectedObject.nameString, buildGhost.TargetPosition, buildGhost.Dir, isReplacing); - } - } - - /// - /// Delete all objects, that are under ghosts - /// - private void DeleteOnGhosts() - { - if (_itemPlacement) - { - FindAndDeleteItem(); - } - else - { - foreach (BuildGhost buildGhost in _buildGhosts) - { - _tileSystem.RpcClearTileObject(_selectedObject.nameString, buildGhost.TargetPosition, buildGhost.Dir); - } - } - } - - private void FindAndDeleteItem() - { - Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); - if (Physics.Raycast(ray, out RaycastHit hitInfo)) - { - // It's fine to use get component in parent because the player might click on a part of a whole thing, - // like the lid of a toolbox, intending to click the toolbox itself. - PlacedItemObject placedItem = hitInfo.collider.gameObject.GetComponentInParent(); - - if (placedItem != null) - { - _tileSystem.RpcClearItemObject(placedItem.NameString, placedItem.gameObject.transform.position); - } - } - } - #endregion - - #region Drag algorithms - private void LineDrag(Vector3 position) - { - Vector2 firstPoint = new(_dragStartPostion.x, _dragStartPostion.z); - Vector2 secondPoint = new(position.x, position.z); - Vector3[] tiles = MathUtility.FindTilesOnLine(firstPoint, secondPoint) - .Select(x => new Vector3(x.x, position.y, x.y)).ToArray(); - - foreach (Vector3 tile in tiles) - { - BuildGhost buildGhost = CreateGhost(_selectedObject.prefab, tile, _direction); - buildGhost.TargetPosition = tile; - RefreshGhost(buildGhost); - _buildGhosts.Add(buildGhost); - } - } - - private void SquareDrag(Vector3 position) - { - int x1 = (int)Math.Min(_dragStartPostion.x, position.x); - int x2 = (int)Math.Max(_dragStartPostion.x, position.x); - int y1 = (int)Math.Min(_dragStartPostion.z, position.z); - int y2 = (int)Math.Max(_dragStartPostion.z, position.z); - - for (int i = y1; i <= y2; i++) - { - for (int j = x1; j <= x2; j++) - { - Vector3 tile = new(j, 0, i); - BuildGhost buildGhost = CreateGhost(_selectedObject.prefab, tile, _direction); - buildGhost.TargetPosition = tile; - RefreshGhost(buildGhost); - _buildGhosts.Add(buildGhost); - } - } - } - - #endregion - - #region Ghosts - - private BuildGhost CreateGhost(GameObject prefab, Vector3 position, Direction direction) - { - Quaternion rotation = Quaternion.Euler(0, TileHelper.GetRotationAngle(direction), 0); - BuildGhost buildGhost = Instantiate(prefab, position, rotation).AddComponent(); - buildGhost.SetupMaterials(_validConstruction, _invalidConstruction, _deleteConstruction); - BuildGhost.BuildMatMode mode; - if (_isDeleting) - { - mode = BuildGhost.BuildMatMode.Delete; - } - else - { - mode = BuildGhost.BuildMatMode.Valid; - } - buildGhost.ChangeGhostColor(mode); - buildGhost.Dir = direction; - return buildGhost; - } - - /// - /// Delete all ghosts - /// - private void ClearGhosts() - { - for (int i = 0; i < _buildGhosts.Count; ) - { - _buildGhosts[i].gameObject.Dispose(true); - _buildGhosts.RemoveAt(i); - } - _ghostsToRefresh.Clear(); - } - - /// - /// Update material of buildGhost based build (or anything else) mode and ghosts position - /// - private void RefreshGhost(BuildGhost buildGhost) - { - if (_isDeleting) - { - buildGhost.ChangeGhostColor(BuildGhost.BuildMatMode.Delete); - } - else if (_itemPlacement) - { - buildGhost.ChangeGhostColor(BuildGhost.BuildMatMode.Valid); - } - else - { - if (!_ghostsToRefresh.Contains(buildGhost)) - { - _ghostsToRefresh.Add(buildGhost); - } - bool isReplacing = _controls.Replace.phase == InputActionPhase.Performed; - RpcSendCanBuild(_selectedObject.nameString, buildGhost.TargetPosition, buildGhost.Dir, isReplacing, LocalConnection); - } - } - - [ServerRpc(RequireOwnership = false)] - public void RpcSendCanBuild(string tileObjectSoName, Vector3 placePosition, Direction dir, bool replaceExisting, NetworkConnection conn) - { - if (_tileSystem == null) - { - _tileSystem = Subsystems.Get(); - } - - TileObjectSo tileObjectSo = (TileObjectSo)_tileSystem.GetAsset(tileObjectSoName); - - if (tileObjectSo == null) - { - Log.Error(this, "Asset is not found"); - return; - } - - bool canBuild = _tileSystem.CanBuild(tileObjectSo, placePosition, dir, replaceExisting); - RpcReceiveCanBuild(conn, placePosition, canBuild); - } - - [TargetRpc] - private void RpcReceiveCanBuild(NetworkConnection conn, Vector3 placePosition, bool canBuild) - { - // Find correct buildGhost to update its material - for (int i = 0; i < _ghostsToRefresh.Count; i++) - { - BuildGhost buildGhost = _ghostsToRefresh[i]; - if (buildGhost.TargetPosition != placePosition) continue; - - if (canBuild) - { - buildGhost.ChangeGhostColor(BuildGhost.BuildMatMode.Valid); - } - else - { - buildGhost.ChangeGhostColor(BuildGhost.BuildMatMode.Invalid); - } - _ghostsToRefresh.RemoveAt(i); - return; - } - } - - /// - /// Activate all buildGhosts. This method is important, because for some reason network objects disable themselves after a few frames. - /// - private void ActivateGhosts() - { - foreach (BuildGhost buildGhost in _buildGhosts) - { - if (!buildGhost.gameObject.activeSelf) - { - buildGhost.gameObject.SetActive(true); - } - } - } - - #endregion - - #region UI - private void ShowUI(bool show) - { - if (!show) - { - _tab.Detach(); - ClearGhosts(); - } - _tab.Panel.gameObject.SetActive(show); - _menuRoot.SetActive(show); - } - - public void OnPointerEnter(PointerEventData eventData) - { - _mouseOverUI = true; - _inputSystem.ToggleBinding("/scroll/y", false); - if (!_isDragging) - { - _inputSystem.ToggleAction(_controls.Place, false); - } - } - - public void OnPointerExit(PointerEventData eventData) - { - _mouseOverUI = false; - _inputSystem.ToggleBinding("/scroll/y", true); - if (!_isDragging) - { - _inputSystem.ToggleAction(_controls.Place, true); - } - } - public void OnInputFieldSelect() - { - _inputSystem.ToggleAllActions(false); - } - - public void OnInputFieldDeselect() - { - _inputSystem.ToggleAllActions(true); - } - public void OnInputFieldChanged() - { - ClearGrid(); - - if (_inputField.text.Contains(' ')) - { - // Replace spaces with underscores, since all asset names contain underscores - _inputField.text = _inputField.text.Replace(' ', '_'); - // Prevent executing the same code twice - return; - } - foreach (GenericObjectSo asset in _objectDatabase) - { - if (!asset.nameString.Contains(_inputField.text)) continue; - Instantiate(_slotPrefab, _contentRoot.transform, true).GetComponent().Setup(asset); - } - } - /// - /// Load a list of tile objects and place them in the UI box grid. - /// - private void LoadObjectGrid(TileLayer[] allowedLayers, bool isItems) - { - ClearGrid(); - _objectDatabase = _tileSystem.Loader.Assets; - foreach (GenericObjectSo asset in _objectDatabase) - { - switch (isItems) - { - case true when asset is not ItemObjectSo: - case false when asset is ItemObjectSo: - case false when asset is TileObjectSo so && !allowedLayers.Contains(so.layer): - continue; - } - Instantiate(_slotPrefab, _contentRoot.transform, true).GetComponent().Setup(asset); - } - } - /// - /// Change the currently displayed tiles/items when a new layer is selected in the drop down menu. - /// - public void OnDropDownChange() - { - int index = _layerPlacementDropdown.value; - - switch (index) - { - case 0: - LoadObjectGrid(new[] - { - TileLayer.Plenum - }, false); - break; - - case 1: - LoadObjectGrid(new[] - { - TileLayer.Turf - }, false); - break; - - case 2: - LoadObjectGrid(new[] - { - TileLayer.FurnitureBase, - TileLayer.FurnitureTop - }, false); - break; - - case 3: - LoadObjectGrid(new[] - { - TileLayer.WallMountHigh, - TileLayer.WallMountLow - }, false); - break; - - case 4: - LoadObjectGrid(new[] - { - TileLayer.Wire, - TileLayer.Disposal, - TileLayer.PipeLeft, - TileLayer.PipeRight, - TileLayer.PipeSurface, - TileLayer.PipeMiddle - }, false); - break; - - case 5: - LoadObjectGrid(new[] { TileLayer.Overlays }, false); - break; - - case 6: - LoadObjectGrid(null, true); - break; - - default: - ClearGrid(); - break; - } - } - public void SetSelectedObject(GenericObjectSo genericObjectSo) - { - _itemPlacement = genericObjectSo switch - { - TileObjectSo => false, - ItemObjectSo => true, - _ => _itemPlacement, - }; - _selectedObject = genericObjectSo; - - if (genericObjectSo.prefab.TryGetComponent(out _ghostRotations)) - { - if (!_ghostRotations.GetAllowedRotations().Contains(_direction)) - { - _direction = _ghostRotations.DefaultDirection; - } - } - else - { - _ghostRotations = null; - } - ClearGhosts(); - _buildGhosts.Add(CreateGhost(genericObjectSo.prefab, TileHelper.GetPointedPosition(!_itemPlacement), _direction)); - } - - /// - /// Change number of columns in asset grid to fit it's width. Elements of the group will take as much width as possible, but won't exceed width of the menu. - /// - private void AdjustGridWidth() - { - GridLayoutGroup grid = _contentRoot.GetComponent(); - float cellWidth = grid.cellSize.x; - float paddingWidth = grid.spacing.x; - float width = _menuRoot.GetComponent().rect.width; - int constraintCount = Convert.ToInt32(Math.Floor(width / (cellWidth + paddingWidth))); - if (constraintCount != grid.constraintCount) - grid.constraintCount = constraintCount; - } - #endregion - - #region Map - private void ClearGrid() - { - for (int i = 0; i < _contentRoot.transform.childCount; i++) - { - _contentRoot.transform.GetChild(i).gameObject.Dispose(true); - } - } - [Server] - public void LoadMap() - { - if (IsServer) - { - _tileSystem.Load(); - } - else - { - Log.Information(this, "Cannot load the map on a client"); - } - } - - [Server] - public void SaveMap() - { - if (IsServer) - { - _tileSystem.Save(); - } - else - { - Log.Information(this, "Cannot save the map on a client"); - } - } - #endregion - - - } -} \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenu.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenu.cs new file mode 100644 index 0000000000..8b74e058a8 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenu.cs @@ -0,0 +1,184 @@ +using DynamicPanels; +using FishNet.Object; +using SS3D.Core; +using SS3D.Core.Behaviours; +using SS3D.Systems.Inputs; +using TMPro; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.InputSystem; +using UnityEngine.Serialization; +using InputSystem = SS3D.Systems.Inputs.InputSystem; + +namespace SS3D.Systems.Tile.TileMapCreator +{ + /// + /// the tilemap menu is an in-game editor for placing and deleting items/objects in a tilemap, as well as loading + /// and saving tilemaps. + /// This scripts orchestrate a bunch of other scripts related to making the menu work. + /// + public class TileMapMenu : NetworkSystem, IPointerEnterHandler, IPointerExitHandler + { + /// + /// Is the mouse over the menu UI + /// + public bool MouseOverUI => _mouseOverUI; + private bool _mouseOverUI = false; + /// + /// Is the tilemap menu enabled + /// + private bool _enabled = false; + /// + /// Are we deleting objects from the tilemap + /// + public bool IsDeleting => _isDeleting; + private bool _isDeleting; + private Controls.TileCreatorActions _controls; + private InputSystem _inputSystem; + private PanelTab _tab; + private TileMapSaveAndLoad _tileMapSaveAndLoad; + + /// + /// Input field to search for specific tile objects or items in the menu. + /// + [SerializeField] + private TMP_InputField _inputField; + [SerializeField] + private GameObject _menuRoot; + [SerializeField] + private ConstructionHologramManager _hologramManager; + [SerializeField] + private AssetGrid _assetGrid; + + /// + /// Called when pointer enter the UI of the menu. + /// + public void OnPointerEnter(PointerEventData eventData) + { + _mouseOverUI = true; + _inputSystem.ToggleBinding("/scroll/y", false); + if (!_hologramManager.IsDragging) + { + _inputSystem.ToggleAction(_controls.Place, false); + } + } + + /// + /// Called when pointer exit the UI of the menu. + /// + public void OnPointerExit(PointerEventData eventData) + { + _mouseOverUI = false; + _inputSystem.ToggleBinding("/scroll/y", true); + if (!_hologramManager.IsDragging) + { + _inputSystem.ToggleAction(_controls.Place, true); + } + } + + protected override void OnStart() + { + base.OnStart(); + _tab = PanelUtils.GetAssociatedTab(GetComponent()); + ShowUI(false); + _inputSystem = Subsystems.Get(); + _controls = _inputSystem.Inputs.TileCreator; + _inputSystem.ToggleAction(_controls.ToggleMenu, true); + _controls.ToggleMenu.performed += HandleToggleMenu; + _tileMapSaveAndLoad = new(); + } + + /// + /// Method called when the control to open the tilemap menu is performed. + /// + private void HandleToggleMenu(InputAction.CallbackContext context) + { + if (_enabled) + { + _inputSystem.ToggleActionMap(_controls, false, new[] { _controls.ToggleMenu }); + _inputSystem.ToggleCollisions(_controls, true); + } + else + { + _inputSystem.ToggleActionMap(_controls, true, new[] { _controls.ToggleMenu }); + _inputSystem.ToggleCollisions(_controls, false); + } + _enabled = !_enabled; + ShowUI(_enabled); + + _assetGrid.Setup(); + } + + /// + /// Hide or show the tilemap menu. + /// + private void ShowUI(bool isShow) + { + if (!isShow) + { + // Detach the tab from a movable panel. It's necessary to prevent disabling all tabs in the panel. + _tab.Detach(); + _hologramManager.DestroyHolograms(); + } + _tab.Panel.gameObject.SetActive(isShow); + _menuRoot.SetActive(isShow); + } + + /// + /// Called when clicking on the delete button of the menu. + /// + private void HandleDeleteButton() + { + _isDeleting = true; + } + + /// + /// Called when clicking on the build button of the menu. + /// + private void HandleBuildButton() + { + _isDeleting = false; + } + + /// + /// Method called when the load button is clicked. + /// + [Server] + public void HandleLoadButton() + { + _tileMapSaveAndLoad.SetUpLoad(); + } + + /// + /// Method called when the save button is clicked. + /// + [Server] + public void HandleSaveButton() + { + _tileMapSaveAndLoad.SetUpSave(); + } + /// + /// Called when the input field to search for tile objects is selected. + /// + public void HandleInputFieldSelect() + { + _inputSystem.ToggleAllActions(false); + } + + /// + /// Called when the input field to search for tile objects is selected. + /// + public void HandleInputFieldDeselect() + { + _inputSystem.ToggleAllActions(true); + } + + /// + /// Called when the text in the input field to search for tile objects is changed. + /// + public void HandleInputFieldChanged() + { + _assetGrid.FindAssets(_inputField.text); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreator.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenu.cs.meta similarity index 100% rename from Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapCreator.cs.meta rename to Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenu.cs.meta diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs new file mode 100644 index 0000000000..e826ff915a --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs @@ -0,0 +1,40 @@ +using SS3D.Core; +using SS3D.Core.Behaviours; +using SS3D.Logging; +using SS3D.Systems.Tile; + +/// +/// Handle the UI and logic related to saving and loading maps in the tilemap menu. +/// +public class TileMapSaveAndLoad : NetworkActor +{ + /// + /// Set up the UI for loading saved maps. TODO : actually implement the logic here. Coming soon. + /// + public void SetUpLoad() + { + if (IsServer) + { + Subsystems.Get().Load(); + } + else + { + Log.Information(this, "Cannot load the map on a client"); + } + } + + /// + /// Set up the UI for saving maps. TODO : actually implement the logic here. Coming soon. + /// + public void SetUpSave() + { + if (IsServer) + { + Subsystems.Get().Save(); + } + else + { + Log.Information(this, "Cannot save the map on a client"); + } + } +} diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs.meta new file mode 100644 index 0000000000..acbebf0fa2 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapSaveAndLoad.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 177da45823e2d1d458275216629c83cd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/AssetDatabaseSettings.asset b/Assets/Settings/AssetDatabaseSettings.asset index dbcf64c7d3..8daca9a668 100644 --- a/Assets/Settings/AssetDatabaseSettings.asset +++ b/Assets/Settings/AssetDatabaseSettings.asset @@ -19,6 +19,7 @@ MonoBehaviour: - {fileID: 11400000, guid: c8a3b9b514b2f7543a544259c3c97b81, type: 2} - {fileID: 11400000, guid: cdf9511d9049fa14ab0433934f3537ec, type: 2} - {fileID: 11400000, guid: c2644d7b34e956743a0bc485e7ca5e37, type: 2} + - {fileID: 11400000, guid: 51c28dd8b59ae0540a4e2cbcceb4999e, type: 2} - {fileID: 11400000, guid: 099b9943e9299d54b82d2c1163500458, type: 2} - {fileID: 11400000, guid: 3fc0db940ed0bd14cb905a5e15dd32fe, type: 2} - {fileID: 11400000, guid: 99157bc96fcf5694e856e4d5092c39df, type: 2}