diff --git a/Assets/Art/Models/Furniture/Generic/Seats/DinerBooth.fbx b/Assets/Art/Models/Furniture/Generic/Seats/DinerBooth.fbx new file mode 100644 index 0000000000..8480374ba3 Binary files /dev/null and b/Assets/Art/Models/Furniture/Generic/Seats/DinerBooth.fbx differ diff --git a/Assets/Art/Models/Furniture/Generic/Seats/DinerBooth.fbx.meta b/Assets/Art/Models/Furniture/Generic/Seats/DinerBooth.fbx.meta new file mode 100644 index 0000000000..75d9f3bc6e --- /dev/null +++ b/Assets/Art/Models/Furniture/Generic/Seats/DinerBooth.fbx.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: bcf01b0847ef6d843ae7613281a81df1 +ModelImporter: + serializedVersion: 21300 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 2 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + removeConstantScaleCurves: 1 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + nodeNameCollisionStrategy: 1 + fileIdsGeneration: 2 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + optimizeBones: 1 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 1 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 2 + humanoidOversampling: 1 + avatarSetup: 0 + addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + remapMaterialsIfMaterialImportModeIsNone: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Content/Data/TileMap/Resources/Furniture/Generic/Seats/DinnerBooth.asset b/Assets/Content/Data/TileMap/Resources/Furniture/Generic/Seats/DinnerBooth.asset new file mode 100644 index 0000000000..b3ae6ae014 --- /dev/null +++ b/Assets/Content/Data/TileMap/Resources/Furniture/Generic/Seats/DinnerBooth.asset @@ -0,0 +1,22 @@ +%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: 4584c35d672b8a74797cc5efa123ce16, type: 3} + m_Name: DinnerBooth + m_EditorClassIdentifier: + nameString: + prefab: {fileID: 8085678556641831659, guid: 85fa4c9b76b4b23458dcf24a745a1dfe, type: 3} + icon: {fileID: 0} + layer: 7 + genericType: 5 + specificType: 0 + width: 1 + height: 1 diff --git a/Assets/Content/Data/TileMap/Resources/Furniture/Generic/Seats/DinnerBooth.asset.meta b/Assets/Content/Data/TileMap/Resources/Furniture/Generic/Seats/DinnerBooth.asset.meta new file mode 100644 index 0000000000..894faf575b --- /dev/null +++ b/Assets/Content/Data/TileMap/Resources/Furniture/Generic/Seats/DinnerBooth.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: befbc886dd0869a438a66ce949a10f9a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Content/WorldObjects/Furniture/Generic/Seats/DinnerBooth.prefab b/Assets/Content/WorldObjects/Furniture/Generic/Seats/DinnerBooth.prefab new file mode 100644 index 0000000000..1c77aaf50f --- /dev/null +++ b/Assets/Content/WorldObjects/Furniture/Generic/Seats/DinnerBooth.prefab @@ -0,0 +1,142 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &8085678556641831659 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1750478436839435592} + - component: {fileID: 7418334817260183665} + - component: {fileID: 1740478804813226977} + - component: {fileID: 7950383285113202337} + - component: {fileID: 8031370004641457100} + m_Layer: 0 + m_Name: DinnerBooth + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1750478436839435592 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8085678556641831659} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 9.950995, y: 0.52496845, z: 0.5001033} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &7418334817260183665 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8085678556641831659} + m_Mesh: {fileID: 559316708432223863, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} +--- !u!23 &1740478804813226977 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8085678556641831659} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 695c4de41b9578049a93f19b1eef7213, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!114 &7950383285113202337 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8085678556641831659} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 479fbe67c0de04b449f924bc5462ede3, type: 3} + m_Name: + m_EditorClassIdentifier: + _componentIndexCache: 0 + _addedNetworkObject: {fileID: 8031370004641457100} + _networkObjectCache: {fileID: 8031370004641457100} + AdjacencyResolver: + o: {fileID: 559316708432223863, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} + uLeft: {fileID: -8315600635035084004, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} + uRight: {fileID: -8218306467633424491, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} + i: {fileID: -2434755278463371002, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} + lIn: {fileID: -8550456321050019914, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} + lOut: {fileID: -819412828331094011, guid: bcf01b0847ef6d843ae7613281a81df1, type: 3} +--- !u!114 &8031370004641457100 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8085678556641831659} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: {fileID: 0} + _networkBehaviours: + - {fileID: 7950383285113202337} + k__BackingField: {fileID: 0} + k__BackingField: [] + SerializedTransformProperties: + Position: {x: 9.950995, y: 0.52496845, z: 0.5001033} + Rotation: {x: 0, y: 0, z: 0, w: 1} + LocalScale: {x: 1, y: 1, z: 1} + _isNetworked: 1 + _isGlobal: 0 + _initializeOrder: 0 + _defaultDespawnType: 0 + NetworkObserver: {fileID: 0} + k__BackingField: 0 + k__BackingField: 0 + _scenePathHash: 0 + k__BackingField: 0 + k__BackingField: 3148903556074791268 diff --git a/Assets/Content/WorldObjects/Furniture/Generic/Seats/DinnerBooth.prefab.meta b/Assets/Content/WorldObjects/Furniture/Generic/Seats/DinnerBooth.prefab.meta new file mode 100644 index 0000000000..4b1fe376b9 --- /dev/null +++ b/Assets/Content/WorldObjects/Furniture/Generic/Seats/DinnerBooth.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 85fa4c9b76b4b23458dcf24a745a1dfe +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyShape.cs b/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyShape.cs index de6d7625b4..92a9334cad 100644 --- a/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyShape.cs +++ b/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyShape.cs @@ -38,5 +38,10 @@ public enum AdjacencyShape TSouthWestEast, //Vertical Vertical, + // Directional + LIn, + LOut, + ULeft, + URight, } } \ No newline at end of file diff --git a/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyTypes/DirectionnalShapeResolver.cs b/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyTypes/DirectionnalShapeResolver.cs new file mode 100644 index 0000000000..bc57d737cb --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyTypes/DirectionnalShapeResolver.cs @@ -0,0 +1,182 @@ +using Coimbra; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace SS3D.Systems.Tile.Connections.AdjacencyTypes +{ + [Serializable] + public struct DirectionnalShapeResolver + { + [Tooltip("A mesh where no edges are connected")] + public Mesh o; + [Tooltip("A mesh where the South edge is connected")] + public Mesh uLeft; + [Tooltip("A mesh where the South edge is connected")] + public Mesh uRight; + [Tooltip("A mesh where the South & south edges are connected")] + public Mesh i; + [Tooltip("A mesh where the South & West edges are connected")] + public Mesh lIn; + [Tooltip("A mesh where the South & West edges are connected")] + public Mesh lOut; + [Tooltip("A mesh where the South, West, and west edges are connected")] + + /// + /// + /// + /// + /// + /// Neigthbours direction are only cardinal neighbours + /// + public Tuple GetMeshAndDirectionAndRotation(AdjacencyMap adjacencyMap, Direction direction, List neighboursDirection) + { + // Determine rotation and mesh specially for every single case. + float rotation = 0.0f; + Mesh mesh; + + AdjacencyShape shape = GetSimpleShape(adjacencyMap, direction, neighboursDirection); + + + switch (shape) + { + case AdjacencyShape.O: + mesh = o; + rotation = TileHelper.AngleBetween(Direction.North, direction); + break; + case AdjacencyShape.ULeft: + mesh = uLeft; + rotation = TileHelper.AngleBetween(Direction.North, direction); + break; + case AdjacencyShape.URight: + mesh = uRight; + rotation = TileHelper.AngleBetween(Direction.North, direction); + break; + case AdjacencyShape.I: + mesh = i; + rotation = TileHelper.AngleBetween(Direction.North, direction); + break; + case AdjacencyShape.LIn: + mesh = lIn; + rotation = LInRotation(adjacencyMap); + break; + case AdjacencyShape.LOut: + mesh = lOut; + rotation = LOutRotation(adjacencyMap); + break; + default: + Debug.LogError($"Received unexpected shape from simple shape resolver: {shape}"); + mesh = o; + break; + } + + return new Tuple (direction, new MeshDirectionInfo { Mesh = mesh, Rotation = rotation }); + } + + public static AdjacencyShape GetSimpleShape(AdjacencyMap adjacencyMap, Direction dir, List NeighboursDirection) + { + int cardinalConnectionCount = adjacencyMap.CardinalConnectionCount; + switch (cardinalConnectionCount) + { + case 0: + return AdjacencyShape.O; + case 1: + var directionConnection = adjacencyMap.GetSingleConnection(true); + var relative =TileHelper.GetRelativeDirection(dir, directionConnection); + if(!NeighboursDirection.Contains(dir)) return AdjacencyShape.O; + if (relative == Direction.East) + return AdjacencyShape.ULeft; + else return AdjacencyShape.URight; + //When two connections, checks if they're opposite or adjacent + case 2: + + if (adjacencyMap.HasConnection(Direction.North) == adjacencyMap.HasConnection(Direction.South)) + return AdjacencyShape.I; + + if (IsInsideConfiguration(adjacencyMap, dir)) + return AdjacencyShape.LIn; + else + return AdjacencyShape.LOut; + + default: + Debug.LogError($"Could not resolve Simple Adjacency Shape for given Adjacency Map - {adjacencyMap}"); + return AdjacencyShape.O; + } + } + + /// + /// It's useful to draw the 8 different configuration of LIn shape + /// with 3 couch, one in the middle and two other in cardinal positions. Consider the middle couch can point towards any cardinal + /// direction. We don't care about the directions of the two other couches, what matters is their position relative to the middle one. + /// This help understand the code below. + /// + /// + /// + /// + private static bool IsInsideConfiguration(AdjacencyMap adjacencyMap, Direction dir) + { + var adjacencies = adjacencyMap.GetAdjacencies(true); + + switch (dir) + { + case Direction.North: + return adjacencies.Contains(Direction.North) && + (adjacencies.Contains(Direction.East) || adjacencies.Contains(Direction.West)); + case Direction.East: + return adjacencies.Contains(Direction.East) && + (adjacencies.Contains(Direction.North) || adjacencies.Contains(Direction.South)); + case Direction.South: + return adjacencies.Contains(Direction.South) && + (adjacencies.Contains(Direction.East) || adjacencies.Contains(Direction.West)); + case Direction.West: + return adjacencies.Contains(Direction.West) && + (adjacencies.Contains(Direction.South) || adjacencies.Contains(Direction.North)); + default: + return false; + } + } + + private static float LOutRotation(AdjacencyMap connections) + { + var adjacencies = connections.GetAdjacencies(true); + if(adjacencies.Contains(Direction.South) && adjacencies.Contains(Direction.East)) + { + return 90f; + } + + if (adjacencies.Contains(Direction.South) && adjacencies.Contains(Direction.West)) + { + return 180f; + } + + if (adjacencies.Contains(Direction.North) && adjacencies.Contains(Direction.West)) + { + return 270f; + } + + return 0f; + } + + private static float LInRotation(AdjacencyMap connections) + { + var adjacencies = connections.GetAdjacencies(true); + if (adjacencies.Contains(Direction.South) && adjacencies.Contains(Direction.East)) + { + return 90f; + } + + if (adjacencies.Contains(Direction.South) && adjacencies.Contains(Direction.West)) + { + return 180f; + } + + if (adjacencies.Contains(Direction.North) && adjacencies.Contains(Direction.West)) + { + return 270f; + } + + return 0f; + } + } +} diff --git a/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyTypes/DirectionnalShapeResolver.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyTypes/DirectionnalShapeResolver.cs.meta new file mode 100644 index 0000000000..2ece84b2b2 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/Connections/AdjacencyTypes/DirectionnalShapeResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2470fb8500aed440a5ad3bd78b6c590 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SS3D/Systems/Tile/Connections/DirectionnalAdjacencyConnector.cs b/Assets/Scripts/SS3D/Systems/Tile/Connections/DirectionnalAdjacencyConnector.cs new file mode 100644 index 0000000000..9240537df6 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/Connections/DirectionnalAdjacencyConnector.cs @@ -0,0 +1,181 @@ +using FishNet.Object.Synchronizing; +using SS3D.Core; +using SS3D.Core.Behaviours; +using SS3D.Logging; +using SS3D.Systems.Tile.Connections; +using SS3D.Systems.Tile.Connections.AdjacencyTypes; +using SS3D.Utils; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace SS3D.Systems.Tile.Connections +{ + public class DirectionnalAdjacencyConnector : NetworkActor, IAdjacencyConnector + { + + protected TileObjectGenericType _genericType; + + + protected TileObjectSpecificType _specificType; + + + public DirectionnalShapeResolver AdjacencyResolver; + + protected AdjacencyMap _adjacencyMap; + + protected MeshFilter _filter; + + protected PlacedTileObject _placedObject; + + public PlacedTileObject PlacedObject => _placedObject; + + public Direction PlacedObjectDirection => _placedObject.Direction; + + private bool _initialized; + + public override void OnStartClient() + { + base.OnStartClient(); + Setup(); + } + + /// + /// Simply set things up, including creating new references, and fetching generic and specific type + /// from the associated scriptable object. + /// + private void Setup() + { + if (!_initialized) + { + _adjacencyMap = new AdjacencyMap(); + _filter = GetComponent(); + + _placedObject = GetComponent(); + if (_placedObject == null) + { + _genericType = TileObjectGenericType.None; + _specificType = TileObjectSpecificType.None; + } + else + { + _genericType = _placedObject.GenericType; + _specificType = _placedObject.SpecificType; + } + _initialized = true; + } + } + + /// + /// directionnal are connected only with other directionnals on their right or on their left. + /// + /// + /// + /// + public bool IsConnected(Direction dir, PlacedTileObject neighbourObject) + { + if (neighbourObject == null) return false; + + if (!TileHelper.CardinalDirections().Contains(dir)) return false; + + // add a check to see if connected to another neighbour object instead of the cardinal connection count. + + bool isConnected = true; + + if (neighbourObject.IsInFront(_placedObject) || neighbourObject.IsBehind(_placedObject)) + { + isConnected &= neighbourObject.Direction != _placedObject.Direction && + neighbourObject.Direction != TileHelper.GetOpposite(_placedObject.Direction); + } + + if (neighbourObject.IsOnLeft(_placedObject) || neighbourObject.IsOnRight(_placedObject)) + { + isConnected &= neighbourObject.Direction != TileHelper.GetOpposite(_placedObject.Direction); + } + + isConnected &= neighbourObject.GenericType == _genericType; + isConnected &= neighbourObject.SpecificType == _specificType; + + return isConnected; + } + + + public void UpdateAllConnections(PlacedTileObject[] neighbourObjects) + { + Setup(); + + bool changed = false; + for (int i = 0; i < neighbourObjects.Length; i++) + { + changed |= UpdateSingleConnection((Direction)i, neighbourObjects[i], true); + } + + if (changed) + { + UpdateMeshAndDirection(); + } + } + + public bool UpdateSingleConnection(Direction dir, PlacedTileObject neighbourObject, bool updateNeighbour) + { + Setup(); + + bool isConnected = IsConnected(dir, neighbourObject); + + bool isUpdated = _adjacencyMap.SetConnection(dir, new AdjacencyData(TileObjectGenericType.None, TileObjectSpecificType.None, isConnected)); + + // Update our neighbour as well + if (isConnected && updateNeighbour) + neighbourObject.UpdateSingleAdjacency(_placedObject, TileHelper.GetOpposite(dir)); + + if (isUpdated) + { + UpdateMeshAndDirection(); + } + + return isUpdated; + } + + protected void UpdateMeshAndDirection() + { + + Tuple info; + + var tileSystem = Subsystems.Get(); + var map = tileSystem.CurrentMap; + + var neighbours = map.GetNeighbourPlacedObjects(_placedObject.Layer, _placedObject.transform.position); + + + List neighboursFacingDirection = new(); + + // TODO not solid code if order of neighbours gets changed + foreach (Direction dir in TileHelper.CardinalDirections()) + { + if(_adjacencyMap.HasConnection(dir)) + { + neighboursFacingDirection.Add(neighbours[(int)dir].Direction); + } + } + + info = AdjacencyResolver.GetMeshAndDirectionAndRotation(_adjacencyMap, PlacedObjectDirection, neighboursFacingDirection); + + _placedObject.SetDirection(info.Item1); + + if (_filter == null) + { + Log.Warning(this, "Missing mesh {meshDirectionInfo}", Logs.Generic, info); + } + + _filter.mesh = info.Item2.Mesh; + + Quaternion localRotation = transform.localRotation; + Vector3 eulerRotation = localRotation.eulerAngles; + localRotation = Quaternion.Euler(eulerRotation.x, info.Item2.Rotation, eulerRotation.z); + + transform.localRotation = localRotation; + } + } +} + diff --git a/Assets/Scripts/SS3D/Systems/Tile/Connections/DirectionnalAdjacencyConnector.cs.meta b/Assets/Scripts/SS3D/Systems/Tile/Connections/DirectionnalAdjacencyConnector.cs.meta new file mode 100644 index 0000000000..0fdf60c325 --- /dev/null +++ b/Assets/Scripts/SS3D/Systems/Tile/Connections/DirectionnalAdjacencyConnector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 479fbe67c0de04b449f924bc5462ede3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: