diff --git a/UnityClient/Assets/Resources/Shaders/Sprites/SpriteShader.shadergraph b/UnityClient/Assets/Resources/Shaders/Sprites/SpriteShader.shadergraph index 144d88bb..150867f3 100644 --- a/UnityClient/Assets/Resources/Shaders/Sprites/SpriteShader.shadergraph +++ b/UnityClient/Assets/Resources/Shaders/Sprites/SpriteShader.shadergraph @@ -14,6 +14,9 @@ }, { "m_Id": "6d9ce5407d8d4d2fbfa2d20fd0e8ca92" + }, + { + "m_Id": "173d0fc7f3b34f0dbc1ca5173e4ad1e1" } ], "m_Keywords": [], @@ -45,9 +48,6 @@ { "m_Id": "7a3fc5ac4dcc4d43b70f016e9e804e57" }, - { - "m_Id": "bba8e1455ba9443dab309b652ac997c0" - }, { "m_Id": "12f0983bded64e5fa6eadfacc1f59a42" }, @@ -60,12 +60,6 @@ { "m_Id": "2cd53227088b47aea6aa50a8a5b9350a" }, - { - "m_Id": "8114c0db2bac40aeb31a4b4651886cb6" - }, - { - "m_Id": "46ec2c743f754ba3a5e358268c2f996e" - }, { "m_Id": "c1af0ed34d7b4e2fa8f6b4e12ee2f4d7" }, @@ -73,13 +67,13 @@ "m_Id": "9af640c4a46c449c873879d6cfa0d663" }, { - "m_Id": "5c66d28d62db41e8a6c61351587468bc" + "m_Id": "d1612701d9594569973b605f40446935" }, { - "m_Id": "9b85546abe494c06a859e11abe48f24e" + "m_Id": "164b41acfbe240a486f0561f822e8204" }, { - "m_Id": "d1612701d9594569973b605f40446935" + "m_Id": "8c97ee1cad1d4b56aeb628b879f9da0d" } ], "m_GroupDatas": [], @@ -108,7 +102,7 @@ }, "m_InputSlot": { "m_Node": { - "m_Id": "7a3fc5ac4dcc4d43b70f016e9e804e57" + "m_Id": "8c97ee1cad1d4b56aeb628b879f9da0d" }, "m_SlotId": 0 } @@ -116,27 +110,13 @@ { "m_OutputSlot": { "m_Node": { - "m_Id": "46ec2c743f754ba3a5e358268c2f996e" + "m_Id": "164b41acfbe240a486f0561f822e8204" }, "m_SlotId": 0 }, "m_InputSlot": { "m_Node": { - "m_Id": "8114c0db2bac40aeb31a4b4651886cb6" - }, - "m_SlotId": 2 - } - }, - { - "m_OutputSlot": { - "m_Node": { - "m_Id": "5c66d28d62db41e8a6c61351587468bc" - }, - "m_SlotId": 0 - }, - "m_InputSlot": { - "m_Node": { - "m_Id": "9b85546abe494c06a859e11abe48f24e" + "m_Id": "8c97ee1cad1d4b56aeb628b879f9da0d" }, "m_SlotId": 1 } @@ -144,15 +124,15 @@ { "m_OutputSlot": { "m_Node": { - "m_Id": "5c66d28d62db41e8a6c61351587468bc" + "m_Id": "8c97ee1cad1d4b56aeb628b879f9da0d" }, "m_SlotId": 2 }, "m_InputSlot": { "m_Node": { - "m_Id": "9b85546abe494c06a859e11abe48f24e" + "m_Id": "7a3fc5ac4dcc4d43b70f016e9e804e57" }, - "m_SlotId": 2 + "m_SlotId": 0 } }, { @@ -169,34 +149,6 @@ "m_SlotId": 0 } }, - { - "m_OutputSlot": { - "m_Node": { - "m_Id": "9b85546abe494c06a859e11abe48f24e" - }, - "m_SlotId": 0 - }, - "m_InputSlot": { - "m_Node": { - "m_Id": "8114c0db2bac40aeb31a4b4651886cb6" - }, - "m_SlotId": 3 - } - }, - { - "m_OutputSlot": { - "m_Node": { - "m_Id": "bba8e1455ba9443dab309b652ac997c0" - }, - "m_SlotId": 3 - }, - "m_InputSlot": { - "m_Node": { - "m_Id": "8114c0db2bac40aeb31a4b4651886cb6" - }, - "m_SlotId": 0 - } - }, { "m_OutputSlot": { "m_Node": { @@ -210,34 +162,6 @@ }, "m_SlotId": 1 } - }, - { - "m_OutputSlot": { - "m_Node": { - "m_Id": "bf801063d2648c8b980fe66bc137c879" - }, - "m_SlotId": 0 - }, - "m_InputSlot": { - "m_Node": { - "m_Id": "5c66d28d62db41e8a6c61351587468bc" - }, - "m_SlotId": 1 - } - }, - { - "m_OutputSlot": { - "m_Node": { - "m_Id": "bf801063d2648c8b980fe66bc137c879" - }, - "m_SlotId": 0 - }, - "m_InputSlot": { - "m_Node": { - "m_Id": "8114c0db2bac40aeb31a4b4651886cb6" - }, - "m_SlotId": 1 - } } ], "m_VertexContext": { @@ -318,7 +242,6 @@ "m_GeneratePropertyBlock": true, "m_UseCustomSlotLabel": false, "m_CustomSlotLabel": "", - "m_DismissedVersion": 0, "m_Precision": 1, "overrideHLSLDeclaration": false, "hlslDeclarationOverride": 2, @@ -333,6 +256,54 @@ "m_DefaultType": 0 } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "09516d09aa4945d58a5a7d5b7329038e", + "m_Id": 2, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Internal.Texture2DShaderProperty", @@ -348,7 +319,6 @@ "m_GeneratePropertyBlock": true, "m_UseCustomSlotLabel": false, "m_CustomSlotLabel": "", - "m_DismissedVersion": 0, "m_Precision": 0, "overrideHLSLDeclaration": false, "hlslDeclarationOverride": 2, @@ -363,27 +333,6 @@ "m_DefaultType": 0 } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", - "m_ObjectId": "0cd3ed911d124e0e963654aa4e363bc1", - "m_Id": 0, - "m_DisplayName": "uv", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "uv", - "m_StageCapability": 3, - "m_Value": { - "x": 6.0, - "y": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0 - }, - "m_Labels": [] -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -399,24 +348,6 @@ "m_Labels": [] } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Texture2DInputMaterialSlot", - "m_ObjectId": "125f52442f13424a8f461b1160c5b510", - "m_Id": 1, - "m_DisplayName": "Texture", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "Texture", - "m_StageCapability": 3, - "m_BareResource": false, - "m_Texture": { - "m_SerializedTexture": "{\"texture\":{\"instanceID\":0}}", - "m_Guid": "" - }, - "m_DefaultType": 0 -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.SampleTexture2DNode", @@ -429,10 +360,10 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -1089.0, - "y": -474.9999084472656, + "x": -1265.0001220703125, + "y": -475.0000305175781, "width": 208.0, - "height": 437.0 + "height": 434.9999694824219 } }, "m_Slots": [ @@ -464,7 +395,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -474,6 +404,68 @@ "m_EnableGlobalMipBias": true } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "164b41acfbe240a486f0561f822e8204", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1395.0, + "y": -322.0, + "width": 110.0, + "height": 34.0 + } + }, + "m_Slots": [ + { + "m_Id": "ad07e42333184e5b88adce591b795f2d" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "173d0fc7f3b34f0dbc1ca5173e4ad1e1" + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", + "m_ObjectId": "173d0fc7f3b34f0dbc1ca5173e4ad1e1", + "m_Guid": { + "m_GuidSerialized": "3b7533ec-858f-4af5-b4fc-cc5db67bdd30" + }, + "m_Name": "_Alpha", + "m_DefaultRefNameVersion": 1, + "m_RefNameGeneratedByDisplayName": "_Alpha", + "m_DefaultReferenceName": "_Alpha", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_UseCustomSlotLabel": false, + "m_CustomSlotLabel": "", + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": 1.0, + "m_FloatType": 1, + "m_RangeValues": { + "x": 0.0, + "y": 1.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", @@ -499,24 +491,6 @@ "m_Labels": [] } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Texture2DInputMaterialSlot", - "m_ObjectId": "1c3ae21c981348b8905c64aa5d33e111", - "m_Id": 2, - "m_DisplayName": "palette", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "palette", - "m_StageCapability": 3, - "m_BareResource": false, - "m_Texture": { - "m_SerializedTexture": "{\"texture\":{\"instanceID\":0}}", - "m_Guid": "" - }, - "m_DefaultType": 0 -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -541,10 +515,10 @@ }, "m_AllowMaterialOverride": false, "m_SurfaceType": 1, - "m_ZTestMode": 4, + "m_ZTestMode": 8, "m_ZWriteControl": 0, "m_AlphaMode": 0, - "m_RenderFace": 0, + "m_RenderFace": 2, "m_AlphaClip": false, "m_CastShadows": true, "m_ReceiveShadows": true, @@ -578,7 +552,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -612,7 +585,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -620,64 +592,6 @@ "m_SerializedDescriptor": "SurfaceDescription.AlphaClipThreshold" } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", - "m_ObjectId": "39532d36bbaf401282c4636ebcb497b7", - "m_Id": 9, - "m_DisplayName": "RGBA", - "m_SlotType": 1, - "m_Hidden": false, - "m_ShaderOutputName": "RGBA", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 0.0, - "w": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0, - "w": 0.0 - }, - "m_Labels": [] -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Texture2DInputMaterialSlot", - "m_ObjectId": "39aef68c55e4405ba84cc37fa2aff80a", - "m_Id": 1, - "m_DisplayName": "mainTexture", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "mainTexture", - "m_StageCapability": 3, - "m_BareResource": false, - "m_Texture": { - "m_SerializedTexture": "{\"texture\":{\"instanceID\":0}}", - "m_Guid": "" - }, - "m_DefaultType": 0 -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", - "m_ObjectId": "3b7262b46c8b4b58933dd92f979576af", - "m_Id": 1, - "m_DisplayName": "X", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "X", - "m_StageCapability": 3, - "m_Value": 0.0, - "m_DefaultValue": 0.0, - "m_Labels": [] -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.SamplerStateMaterialSlot", @@ -691,42 +605,6 @@ "m_BareResource": false } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.PropertyNode", - "m_ObjectId": "46ec2c743f754ba3a5e358268c2f996e", - "m_Group": { - "m_Id": "" - }, - "m_Name": "Property", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -1331.0, - "y": 68.0, - "width": 145.0, - "height": 34.0 - } - }, - "m_Slots": [ - { - "m_Id": "4d16523b4cf642f6ab9beb2012d86269" - } - ], - "synonyms": [], - "m_Precision": 1, - "m_PreviewExpanded": true, - "m_DismissedVersion": 0, - "m_PreviewMode": 0, - "m_CustomColors": { - "m_SerializableColors": [] - }, - "m_Property": { - "m_Id": "06791df963534411a9fdb0cca88e5c55" - } -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.BlockNode", @@ -753,7 +631,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -776,189 +653,57 @@ "m_Labels": [] } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Texture2DMaterialSlot", - "m_ObjectId": "4d16523b4cf642f6ab9beb2012d86269", - "m_Id": 0, - "m_DisplayName": "_PaletteTex", - "m_SlotType": 1, - "m_Hidden": false, - "m_ShaderOutputName": "Out", - "m_StageCapability": 3, - "m_BareResource": false -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", "m_ObjectId": "4e978688fa454553aa315fec01ede59c", "m_Id": 0, "m_DisplayName": "Ambient Occlusion", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "Occlusion", - "m_StageCapability": 2, - "m_Value": 1.600000023841858, - "m_DefaultValue": 1.0, - "m_Labels": [] -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", - "m_ObjectId": "50e009027ab64e4ca6f82ad2a63a256b", - "m_Id": 3, - "m_DisplayName": "uTextSize", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "uTextSize", - "m_StageCapability": 3, - "m_Value": { - "x": 29.0, - "y": 27.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0 - }, - "m_Labels": [] -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", - "m_ObjectId": "56e0c38efe0a4a55941ab393af461417", - "m_Id": 2, - "m_DisplayName": "Y", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "Y", - "m_StageCapability": 3, - "m_Value": 0.0, - "m_DefaultValue": 0.0, - "m_Labels": [ - "Y" - ] -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", - "m_ObjectId": "58f3cd89dc564dce8585089f00cc9ba9", - "m_Id": 0, - "m_DisplayName": "Out", - "m_SlotType": 1, - "m_Hidden": false, - "m_ShaderOutputName": "Out", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0 - }, - "m_Labels": [] -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", - "m_ObjectId": "5ac2da3c82084425b6fd03e146a38c15", - "m_Id": 2, - "m_DisplayName": "False", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "False", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 0.0, - "w": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0, - "w": 0.0 - } -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Texture2DPropertiesNode", - "m_ObjectId": "5c66d28d62db41e8a6c61351587468bc", - "m_Group": { - "m_Id": "" - }, - "m_Name": "Texel Size", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -1441.9998779296875, - "y": 132.99993896484376, - "width": 184.0, - "height": 100.99999237060547 - } - }, - "m_Slots": [ - { - "m_Id": "c956fd1a147043f0951323e8e27944f5" - }, - { - "m_Id": "8feb70a0859a49f3b5fb6148bf4386a6" - }, - { - "m_Id": "125f52442f13424a8f461b1160c5b510" - } - ], - "synonyms": [], - "m_Precision": 0, - "m_PreviewExpanded": true, - "m_DismissedVersion": 0, - "m_PreviewMode": 0, - "m_CustomColors": { - "m_SerializableColors": [] - } -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", - "m_ObjectId": "625f59fb02f442adb6e1c71520b15a35", - "m_Id": 7, - "m_DisplayName": "A", - "m_SlotType": 1, + "m_SlotType": 0, "m_Hidden": false, - "m_ShaderOutputName": "A", + "m_ShaderOutputName": "Occlusion", "m_StageCapability": 2, - "m_Value": 0.0, - "m_DefaultValue": 0.0, + "m_Value": 1.600000023841858, + "m_DefaultValue": 1.0, "m_Labels": [] } { "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", - "m_ObjectId": "6c19325a4a3447639fc7596db042449a", + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "5ac2da3c82084425b6fd03e146a38c15", "m_Id": 2, - "m_DisplayName": "Offset", + "m_DisplayName": "False", "m_SlotType": 0, "m_Hidden": false, - "m_ShaderOutputName": "Offset", + "m_ShaderOutputName": "False", "m_StageCapability": 3, "m_Value": { "x": 0.0, - "y": 0.0 + "y": 0.0, + "z": 0.0, + "w": 0.0 }, "m_DefaultValue": { "x": 0.0, - "y": 0.0 - }, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "625f59fb02f442adb6e1c71520b15a35", + "m_Id": 7, + "m_DisplayName": "A", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 2, + "m_Value": 0.0, + "m_DefaultValue": 0.0, "m_Labels": [] } @@ -977,7 +722,6 @@ "m_GeneratePropertyBlock": true, "m_UseCustomSlotLabel": false, "m_CustomSlotLabel": "", - "m_DismissedVersion": 0, "m_Precision": 0, "overrideHLSLDeclaration": false, "hlslDeclarationOverride": 0, @@ -1056,7 +800,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1090,7 +833,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1185,55 +927,6 @@ "m_DefaultValue": false } -{ - "m_SGVersion": 1, - "m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode", - "m_ObjectId": "8114c0db2bac40aeb31a4b4651886cb6", - "m_Group": { - "m_Id": "" - }, - "m_Name": "BilinearSample (Custom Function)", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -1117.0001220703125, - "y": 16.000015258789064, - "width": 239.0, - "height": 350.0 - } - }, - "m_Slots": [ - { - "m_Id": "0cd3ed911d124e0e963654aa4e363bc1" - }, - { - "m_Id": "39aef68c55e4405ba84cc37fa2aff80a" - }, - { - "m_Id": "1c3ae21c981348b8905c64aa5d33e111" - }, - { - "m_Id": "50e009027ab64e4ca6f82ad2a63a256b" - }, - { - "m_Id": "39532d36bbaf401282c4636ebcb497b7" - } - ], - "synonyms": [], - "m_Precision": 0, - "m_PreviewExpanded": true, - "m_DismissedVersion": 0, - "m_PreviewMode": 0, - "m_CustomColors": { - "m_SerializableColors": [] - }, - "m_SourceType": 1, - "m_FunctionName": "BilinearSample", - "m_FunctionSource": "", - "m_FunctionBody": "float2 TextInterval = 1.0 / uTextSize;\r\n \r\nfloat tlPal = tex2D(mainTexture, uv).x;\r\nfloat trPal = tex2D(mainTexture, uv + float2(TextInterval.x, 0.0)).x;\r\nfloat blPal = tex2D(mainTexture, uv + float2(0.0, TextInterval.y)).x;\r\nfloat brPal = tex2D(mainTexture, uv + TextInterval).x;\r\n \r\nfloat4 transparent = float4(0.5, 0.5, 0.5, 0.0);\r\n \r\nfloat4 tl = tlPal == 0.0 ? transparent : float4(tex2D(palette, float2(tlPal, 1.0)).rgb, 1.0);\r\nfloat4 tr = trPal == 0.0 ? transparent : float4(tex2D(palette, float2(trPal, 1.0)).rgb, 1.0);\r\nfloat4 bl = blPal == 0.0 ? transparent : float4(tex2D(palette, float2(blPal, 1.0)).rgb, 1.0);\r\nfloat4 br = brPal == 0.0 ? transparent : float4(tex2D(palette, float2(brPal, 1.0)).rgb, 1.0);\r\n \r\nfloat2 f = frac(uv.xy * uTextSize);\r\nfloat4 tA = lerp(tl, tr, f.x);\r\nfloat4 tB = lerp(bl, br, f.y);\r\n \r\nRGBA = lerp(tA, tB, f.x);" -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", @@ -1274,7 +967,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1297,7 +989,6 @@ "m_GeneratePropertyBlock": true, "m_UseCustomSlotLabel": false, "m_CustomSlotLabel": "", - "m_DismissedVersion": 0, "m_Precision": 0, "overrideHLSLDeclaration": false, "hlslDeclarationOverride": 0, @@ -1359,38 +1050,92 @@ { "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", - "m_ObjectId": "8feb70a0859a49f3b5fb6148bf4386a6", - "m_Id": 2, - "m_DisplayName": "Height", - "m_SlotType": 1, - "m_Hidden": false, - "m_ShaderOutputName": "Height", - "m_StageCapability": 3, - "m_Value": 0.0, - "m_DefaultValue": 0.0, - "m_Labels": [] + "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", + "m_ObjectId": "8c97ee1cad1d4b56aeb628b879f9da0d", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Multiply", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -994.0000610351563, + "y": -392.0, + "width": 126.0, + "height": 118.0 + } + }, + "m_Slots": [ + { + "m_Id": "faf9cfa269cf4cd6b2f70b2093fb120a" + }, + { + "m_Id": "910a7d88e736444eabbc8e8be62367cb" + }, + { + "m_Id": "09516d09aa4945d58a5a7d5b7329038e" + } + ], + "synonyms": [ + "multiplication", + "times", + "x" + ], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + } } { "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", - "m_ObjectId": "9616b7be3d874f4895fa5c6a1a04ac04", - "m_Id": 3, - "m_DisplayName": "Out", - "m_SlotType": 1, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "910a7d88e736444eabbc8e8be62367cb", + "m_Id": 1, + "m_DisplayName": "B", + "m_SlotType": 0, "m_Hidden": false, - "m_ShaderOutputName": "Out", + "m_ShaderOutputName": "B", "m_StageCapability": 3, "m_Value": { - "x": 0.0, - "y": 0.0 + "e00": 2.0, + "e01": 2.0, + "e02": 2.0, + "e03": 2.0, + "e10": 2.0, + "e11": 2.0, + "e12": 2.0, + "e13": 2.0, + "e20": 2.0, + "e21": 2.0, + "e22": 2.0, + "e23": 2.0, + "e30": 2.0, + "e31": 2.0, + "e32": 2.0, + "e33": 2.0 }, "m_DefaultValue": { - "x": 0.0, - "y": 0.0 - }, - "m_Labels": [] + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } } { @@ -1443,7 +1188,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1453,71 +1197,6 @@ } } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2Node", - "m_ObjectId": "9b85546abe494c06a859e11abe48f24e", - "m_Group": { - "m_Id": "" - }, - "m_Name": "Vector 2", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -1244.9998779296875, - "y": 132.99993896484376, - "width": 128.0, - "height": 100.99999237060547 - } - }, - "m_Slots": [ - { - "m_Id": "3b7262b46c8b4b58933dd92f979576af" - }, - { - "m_Id": "56e0c38efe0a4a55941ab393af461417" - }, - { - "m_Id": "58f3cd89dc564dce8585089f00cc9ba9" - } - ], - "synonyms": [], - "m_Precision": 0, - "m_PreviewExpanded": true, - "m_DismissedVersion": 0, - "m_PreviewMode": 0, - "m_CustomColors": { - "m_SerializableColors": [] - }, - "m_Value": { - "x": 0.0, - "y": 0.0 - } -} - -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.UVMaterialSlot", - "m_ObjectId": "a44a22f8888c4a469e3b44c6e8f9287b", - "m_Id": 0, - "m_DisplayName": "UV", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "UV", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0 - }, - "m_Labels": [], - "m_Channel": 0 -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.CategoryData", @@ -1535,56 +1214,32 @@ }, { "m_Id": "6d9ce5407d8d4d2fbfa2d20fd0e8ca92" + }, + { + "m_Id": "173d0fc7f3b34f0dbc1ca5173e4ad1e1" } ] } { - "m_SGVersion": 1, - "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", - "m_ObjectId": "b0dde41a484b42b7bb61a5406275664f" + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "ad07e42333184e5b88adce591b795f2d", + "m_Id": 0, + "m_DisplayName": "_Alpha", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] } { - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.TilingAndOffsetNode", - "m_ObjectId": "bba8e1455ba9443dab309b652ac997c0", - "m_Group": { - "m_Id": "" - }, - "m_Name": "Tiling And Offset", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -1322.0, - "y": -89.00001525878906, - "width": 155.0, - "height": 142.00003051757813 - } - }, - "m_Slots": [ - { - "m_Id": "a44a22f8888c4a469e3b44c6e8f9287b" - }, - { - "m_Id": "f30bc455686e4ffaa06bfa61c5afcc1b" - }, - { - "m_Id": "6c19325a4a3447639fc7596db042449a" - }, - { - "m_Id": "9616b7be3d874f4895fa5c6a1a04ac04" - } - ], - "synonyms": [], - "m_Precision": 0, - "m_PreviewExpanded": false, - "m_DismissedVersion": 0, - "m_PreviewMode": 0, - "m_CustomColors": { - "m_SerializableColors": [] - } + "m_SGVersion": 1, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "b0dde41a484b42b7bb61a5406275664f" } { @@ -1599,10 +1254,10 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -1599.000244140625, - "y": -436.00006103515627, + "x": -1465.0, + "y": -436.0000305175781, "width": 134.0, - "height": 34.0 + "height": 33.999969482421878 } }, "m_Slots": [ @@ -1613,7 +1268,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1658,7 +1312,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": false, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1691,7 +1344,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1699,21 +1351,6 @@ "m_SerializedDescriptor": "SurfaceDescription.Smoothness" } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", - "m_ObjectId": "c956fd1a147043f0951323e8e27944f5", - "m_Id": 0, - "m_DisplayName": "Width", - "m_SlotType": 1, - "m_Hidden": false, - "m_ShaderOutputName": "Width", - "m_StageCapability": 3, - "m_Value": 0.0, - "m_DefaultValue": 0.0, - "m_Labels": [] -} - { "m_SGVersion": 1, "m_Type": "UnityEditor.ShaderGraph.ColorNode", @@ -1740,7 +1377,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1810,27 +1446,6 @@ "m_Labels": [] } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", - "m_ObjectId": "f30bc455686e4ffaa06bfa61c5afcc1b", - "m_Id": 1, - "m_DisplayName": "Tiling", - "m_SlotType": 0, - "m_Hidden": false, - "m_ShaderOutputName": "Tiling", - "m_StageCapability": 3, - "m_Value": { - "x": 1.0, - "y": 1.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0 - }, - "m_Labels": [] -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", @@ -1887,7 +1502,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1921,7 +1535,6 @@ "synonyms": [], "m_Precision": 0, "m_PreviewExpanded": true, - "m_DismissedVersion": 0, "m_PreviewMode": 0, "m_CustomColors": { "m_SerializableColors": [] @@ -1929,6 +1542,54 @@ "m_SerializedDescriptor": "VertexDescription.Tangent" } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", + "m_ObjectId": "faf9cfa269cf4cd6b2f70b2093fb120a", + "m_Id": 0, + "m_DisplayName": "A", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "A", + "m_StageCapability": 3, + "m_Value": { + "e00": 0.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 0.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 0.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 0.0 + }, + "m_DefaultValue": { + "e00": 1.0, + "e01": 0.0, + "e02": 0.0, + "e03": 0.0, + "e10": 0.0, + "e11": 1.0, + "e12": 0.0, + "e13": 0.0, + "e20": 0.0, + "e21": 0.0, + "e22": 1.0, + "e23": 0.0, + "e30": 0.0, + "e31": 0.0, + "e32": 0.0, + "e33": 1.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.ColorRGBAMaterialSlot", diff --git a/UnityClient/Assets/Scenes/CharSelection/CharSelectionController.cs b/UnityClient/Assets/Scenes/CharSelection/CharSelectionController.cs index b7b60836..e4e1c87b 100644 --- a/UnityClient/Assets/Scenes/CharSelection/CharSelectionController.cs +++ b/UnityClient/Assets/Scenes/CharSelection/CharSelectionController.cs @@ -93,9 +93,6 @@ private async void OnCharacterSelectionAccepted(ushort cmd, int size, InPacket p Session.StartSession(new Session(entity, NetworkClient.State.LoginInfo.AccountID)); DontDestroyOnLoad(entity.gameObject); - //var mapUI = Instantiate(MapUIPrefab); - //DontDestroyOnLoad(mapUI); - var loginInfo = NetworkClient.State.LoginInfo; new CZ.ENTER2(loginInfo.AccountID, selectedCharacter.GID, loginInfo.LoginID1, (int) new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(), loginInfo.Sex).Send(); } diff --git a/UnityClient/Assets/Scenes/Map/MapController.cs b/UnityClient/Assets/Scenes/Map/MapController.cs index b84a04eb..70957e82 100644 --- a/UnityClient/Assets/Scenes/Map/MapController.cs +++ b/UnityClient/Assets/Scenes/Map/MapController.cs @@ -51,6 +51,7 @@ private async void Awake() { GameManager.InitCamera(); var gameMap = await GameManager.BeginMapLoading(mapInfo.mapname); + PathFinding = gameMap.GetPathFinder(); NetworkClient.StartHeatBeat(); NetworkClient.ResumePacketHandling(); @@ -149,7 +150,7 @@ private async void OnEntityMoved(ushort cmd, int size, InPacket packet) { if (packet is ZC.NPCACK_MAPMOVE) { var pkt = packet as ZC.NPCACK_MAPMOVE; - if (pkt.MapName != Session.CurrentSession.CurrentMap) { + if (Path.GetFileNameWithoutExtension(pkt.MapName) != Session.CurrentSession.CurrentMap) { var entity = Session.CurrentSession.Entity as Entity; entity.StopMoving(); diff --git a/UnityClient/Assets/Scenes/Splashscreen/SplashScreenController.cs b/UnityClient/Assets/Scenes/Splashscreen/SplashScreenController.cs index 1e07c45f..346107c9 100644 --- a/UnityClient/Assets/Scenes/Splashscreen/SplashScreenController.cs +++ b/UnityClient/Assets/Scenes/Splashscreen/SplashScreenController.cs @@ -1,12 +1,14 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using ROIO; +using ROIO.Utils; using System.Collections; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.SceneManagement; +using UnityEngine.UI; public class SplashScreenController : MonoBehaviour { @@ -16,36 +18,58 @@ public class SplashScreenController : MonoBehaviour { [SerializeField] private TextMeshProUGUI labelText; + [SerializeField] + private TextMeshProUGUI DownloadSizeText; + + [SerializeField] + private Slider Slider; + void Start() { + StartCoroutine(Initialize()); + } + + private IEnumerator Initialize() { + labelText.text = "Checking for updates..."; + yield return Addressables.InitializeAsync(); + yield return new WaitForSeconds(1f); + StartCoroutine(PrefetchAssets()); } private IEnumerator PrefetchAssets() { #if !UNITY_EDITOR + var downloadSize = Addressables.GetDownloadSizeAsync(LabelsToPrefetch).WaitForCompletion(); + + if (downloadSize <= 0) { + yield return FetchConfigs(); + } + foreach (var label in LabelsToPrefetch) { var handle = Addressables.DownloadDependenciesAsync(label, true); while(!handle.IsDone) { var downloadStatus = handle.GetDownloadStatus(); - var downloadedMbs = downloadStatus.DownloadedBytes / 1024 / 1024; - var totalMbs = downloadStatus.TotalBytes / 1024 / 1024; - var progress = downloadedMbs / (totalMbs > 0 ? totalMbs : 1) * 100; + var downloadedMbs = downloadStatus.DownloadedBytes / 1024f / 1024f; + var totalMbs = (downloadStatus.TotalBytes / 1024f / 1024f); + + var progress = Conversions.SafeDivide(downloadedMbs, totalMbs); - var text = $"Downloading {label.labelString}\n{downloadedMbs}MB / {totalMbs}MB\n{progress}%"; + var text = $"Downloading {label.labelString}"; labelText.text = text; + DownloadSizeText.text = $"{downloadedMbs}MB / {totalMbs}MB"; + Slider.value = progress; + yield return null; } yield return handle; } #endif - yield return Addressables.InitializeAsync(); - yield return new WaitForSeconds(1f); - - StartCoroutine(FetchConfigs()); + yield return FetchConfigs(); } private IEnumerator FetchConfigs() { + labelText.text = "Fetching remote configuration..."; var localRequest = Addressables.LoadAssetAsync("LocalConfigs.json.txt"); yield return localRequest; diff --git a/UnityClient/Assets/Scenes/Splashscreen/SplashscreenScene.unity b/UnityClient/Assets/Scenes/Splashscreen/SplashscreenScene.unity index 94a7a2ca..055dbdbe 100644 --- a/UnityClient/Assets/Scenes/Splashscreen/SplashscreenScene.unity +++ b/UnityClient/Assets/Scenes/Splashscreen/SplashscreenScene.unity @@ -277,6 +277,8 @@ MonoBehaviour: - m_LabelString: Sprites - m_LabelString: DataTables labelText: {fileID: 1464341368} + DownloadSizeText: {fileID: 2122561538} + Slider: {fileID: 755204486} --- !u!4 &726516692 Transform: m_ObjectHideFlags: 0 @@ -292,6 +294,97 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &755204484 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 755204485} + - component: {fileID: 755204486} + m_Layer: 5 + m_Name: Slider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &755204485 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 755204484} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1347888241} + - {fileID: 1318469554} + - {fileID: 2122561537} + m_Father: {fileID: 1518520349} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: 0, y: 50} + m_SizeDelta: {x: -300, y: 60} + m_Pivot: {x: 0.5, y: 0} +--- !u!114 &755204486 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 755204484} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 0} + m_FillRect: {fileID: 2107491680} + m_HandleRect: {fileID: 0} + m_Direction: 0 + m_MinValue: 0 + m_MaxValue: 1 + m_WholeNumbers: 0 + m_Value: 0 + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] --- !u!1 &1129638895 GameObject: m_ObjectHideFlags: 0 @@ -440,6 +533,119 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1318469553 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1318469554} + m_Layer: 5 + m_Name: Fill Area + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1318469554 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1318469553} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2107491680} + m_Father: {fileID: 755204485} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.25} + m_AnchorMax: {x: 1, y: 0.75} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &1347888240 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1347888241} + - component: {fileID: 1347888243} + - component: {fileID: 1347888242} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1347888241 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1347888240} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 755204485} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.25} + m_AnchorMax: {x: 1, y: 0.75} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1347888242 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1347888240} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.49019608} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1347888243 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1347888240} + m_CullTransparentMesh: 1 --- !u!1 &1464341366 GameObject: m_ObjectHideFlags: 0 @@ -475,7 +681,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 100} m_SizeDelta: {x: 0, y: 50} m_Pivot: {x: 0.5, y: 0} --- !u!114 &1464341368 @@ -533,7 +739,7 @@ MonoBehaviour: m_fontSizeMax: 72 m_fontStyle: 0 m_HorizontalAlignment: 2 - m_VerticalAlignment: 1024 + m_VerticalAlignment: 512 m_textAlignment: 65535 m_characterSpacing: 0 m_wordSpacing: 0 @@ -669,6 +875,7 @@ RectTransform: m_Children: - {fileID: 1129638896} - {fileID: 1464341367} + - {fileID: 755204485} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -792,6 +999,217 @@ MonoBehaviour: m_ShadowLayerMask: 1 m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} +--- !u!1 &2107491679 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2107491680} + - component: {fileID: 2107491682} + - component: {fileID: 2107491681} + m_Layer: 5 + m_Name: Fill + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2107491680 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2107491679} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1318469554} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 10, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2107491681 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2107491679} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &2107491682 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2107491679} + m_CullTransparentMesh: 1 +--- !u!1 &2122561536 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2122561537} + - component: {fileID: 2122561539} + - component: {fileID: 2122561538} + m_Layer: 5 + m_Name: DownloadSize + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2122561537 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2122561536} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 755204485} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2122561538 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2122561536} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278190080 + m_fontColor: {r: 0, g: 0, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &2122561539 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2122561536} + m_CullTransparentMesh: 1 --- !u!1 &6849943526642155881 GameObject: m_ObjectHideFlags: 0 diff --git a/UnityClient/Assets/Scripts/Core/ItemManager.cs b/UnityClient/Assets/Scripts/Core/ItemManager.cs index 5fd74ac3..692ac9ed 100644 --- a/UnityClient/Assets/Scripts/Core/ItemManager.cs +++ b/UnityClient/Assets/Scripts/Core/ItemManager.cs @@ -184,7 +184,7 @@ private void OnItemSpamInGround(ushort cmd, int size, InPacket packet) { var z = pkt.y - 0.5 + pkt.subY / 12; var y = PathFinding.GetCellHeight((int) x, (int) z) + 5.0; - EntityManager.SpawnItem(new ItemSpawnInfo() { + _ = EntityManager.SpawnItem(new ItemSpawnInfo() { AID = pkt.id, mapID = pkt.mapID, Position = new Vector3((float) x, (float) y, (float) z), @@ -199,7 +199,7 @@ private void OnItemSpamInGround(ushort cmd, int size, InPacket packet) { var z = ITEM_ENTRY.y - 0.5 + ITEM_ENTRY.subY / 12; var y = PathFinding.GetCellHeight((int) x, (int) z) + 1.0; - EntityManager.SpawnItem(new ItemSpawnInfo() { + _ = EntityManager.SpawnItem(new ItemSpawnInfo() { AID = ITEM_ENTRY.id, mapID = ITEM_ENTRY.mapID, Position = new Vector3((float) x, (float) y, (float) z), diff --git a/UnityClient/Assets/Scripts/GameManager.cs b/UnityClient/Assets/Scripts/GameManager.cs index b68038b4..c83d79f4 100644 --- a/UnityClient/Assets/Scripts/GameManager.cs +++ b/UnityClient/Assets/Scripts/GameManager.cs @@ -117,13 +117,17 @@ public async void PlayBgm(string name) { //AudioSource.Play(); } + /** + * We do not want to pause/resume packet handling from here + * That side effect can bring unwanted behaviour like being able to see + * npcs vanishing and spawning + * + * So we leave for the caller the responsibility to pause/resume + */ public async Task BeginMapLoading(string mapName) { - SceneManager.LoadSceneAsync("LoadingScene", LoadSceneMode.Additive); - - NetworkClient.PausePacketHandling(); + await LoadScene("LoadingScene", LoadSceneMode.Additive); MapRenderer.Clear(); - EntityManager.ClearEntities(); if (CurrentMap != null) { Destroy(CurrentMap.gameObject); } @@ -135,14 +139,32 @@ public async Task BeginMapLoading(string mapName) { var mapPrefab = await Addressables.LoadAssetAsync($"data/maps/{Path.GetFileNameWithoutExtension(mapName)}.prefab").Task; CurrentMap = Instantiate(mapPrefab).GetComponent(); #endif - - NetworkClient.ResumePacketHandling(); - SceneManager.UnloadSceneAsync("LoadingScene"); + await UnloadScene("LoadingScene"); PlayBgm(Tables.MapTable[$"{mapName}.rsw"].mp3); return CurrentMap; } + private Task LoadScene(string sceneName, LoadSceneMode mode) { + var t = new TaskCompletionSource(); + + SceneManager.LoadSceneAsync(sceneName, mode).completed += delegate { + t.TrySetResult(true); + }; + + return t.Task; + } + + private Task UnloadScene(string sceneName) { + var t = new TaskCompletionSource(); + + SceneManager.UnloadSceneAsync(sceneName).completed += delegate { + t.TrySetResult(true); + }; + + return t.Task; + } + public void SetConfigurations(RemoteConfiguration remoteConfiguration, LocalConfiguration localConfiguration) { RemoteConfiguration = remoteConfiguration; LocalConfiguration = localConfiguration; diff --git a/UnityClient/Assets/Scripts/Renderer/DamageRenderer.cs b/UnityClient/Assets/Scripts/Renderer/DamageRenderer.cs index a308c13b..396b6b17 100644 --- a/UnityClient/Assets/Scripts/Renderer/DamageRenderer.cs +++ b/UnityClient/Assets/Scripts/Renderer/DamageRenderer.cs @@ -30,9 +30,13 @@ public class DamageRenderer : MonoBehaviour { float angle => MathHelper.ToRadians(_startingAngle); void Update() { + Ready = start < GameManager.Tick; + if (!Ready) return; + textMesh.enabled = Ready; + float perc = (float) ((GameManager.Tick - start) / Delay); if ((CurrentType & DamageType.COMBO) > 0) { @@ -64,7 +68,7 @@ public float Display(float amount, double tick, DamageType? type, Entity entity) } var color = new Color(); - color[3] = 1.0f; + color[3] = 0f; Delay = 1500; start = tick; @@ -86,7 +90,7 @@ public float Display(float amount, double tick, DamageType? type, Entity entity) } textMesh.color = color; - Ready = true; + Ready = false; stringBuilder.Append(""); @@ -106,6 +110,7 @@ public float Display(float amount, double tick, DamageType? type, Entity entity) textMesh.text = stringBuilder.ToString(); stringBuilder.Clear(); + textMesh.enabled = false; return Delay / 1000f; } diff --git a/UnityClient/Assets/Scripts/Renderer/Entities/Billboard.cs b/UnityClient/Assets/Scripts/Renderer/Entities/Billboard.cs index ac57f783..d4f15e11 100644 --- a/UnityClient/Assets/Scripts/Renderer/Entities/Billboard.cs +++ b/UnityClient/Assets/Scripts/Renderer/Entities/Billboard.cs @@ -10,22 +10,6 @@ private void Awake() { } public void LateUpdate() { - UpdateRotation(); - MaybeUpdateScale(); - } - - private void MaybeUpdateScale() { - if (CharacterCamera.ROCamera != null) { - float pitch = CharacterCamera.ROCamera.Pitch; - float y = 1 / Mathf.Cos(pitch); - transform.localScale = new Vector3(1, y, 1); - } - } - - private void UpdateRotation() { - transform.localRotation = GameManager.MainCamera.transform.rotation; - Vector3 euler = transform.localEulerAngles; - euler.x = 0; - transform.localEulerAngles = euler; + transform.localRotation = Camera.main.transform.rotation; } } \ No newline at end of file diff --git a/UnityClient/Assets/Scripts/Renderer/Entities/Entity.cs b/UnityClient/Assets/Scripts/Renderer/Entities/Entity.cs index bf83c1de..793a23b5 100644 --- a/UnityClient/Assets/Scripts/Renderer/Entities/Entity.cs +++ b/UnityClient/Assets/Scripts/Renderer/Entities/Entity.cs @@ -331,16 +331,16 @@ private void MaybeInitLayer( } public void Vanish(int type) { + StopMoving(); switch (type) { case 0: // Moved out of sight - // TODO start coroutine to fade-out entity - Destroy(gameObject); + StartCoroutine(DestroyWithFade()); break; case 1: // Died var isPC = Type == EntityType.PC; ChangeMotion(new EntityViewer.MotionRequest { Motion = SpriteMotion.Dead }); if (!isPC) { - StartCoroutine(DestroyAfterSeconds()); + StartCoroutine(DestroyAfterSecondsWithFade()); } break; default: @@ -349,12 +349,20 @@ public void Vanish(int type) { } } - private IEnumerator DestroyAfterSeconds() { + private IEnumerator DestroyAfterSecondsWithFade() { yield return new WaitForSeconds(1f); + IsReady = false; + yield return EntityViewer.FadeOut(); Destroy(gameObject); yield return null; } + private IEnumerator DestroyWithFade() { + IsReady = false; + yield return EntityViewer.FadeOut(); + Destroy(gameObject); + } + internal void OnSpriteChange(ZC.SPRITE_CHANGE2.LookType type, short value, short value2) { switch (type) { case ZC.SPRITE_CHANGE2.LookType.LOOK_BASE: @@ -446,6 +454,7 @@ private void OnEntityUseSkillToAttack(ushort cmd, int size, InPacket packet) { delay = 0 } ); + srcEntity.SetAttackSpeed((ushort) NOTIFY_SKILL2.attackMT); } if (dstEntity != null) { @@ -748,6 +757,7 @@ private void OnEntityAttack(EntityActionRequest pkt, Entity srcEntity, Entity ds new EntityViewer.MotionRequest { Motion = SpriteMotion.Attack }, new EntityViewer.MotionRequest { Motion = SpriteMotion.Standby, delay = GameManager.Tick + pkt.sourceSpeed } ); + srcEntity.SetAttackSpeed(pkt.sourceSpeed); } private void OnUseSkillResult(ushort cmd, int size, InPacket packet) { @@ -809,6 +819,7 @@ public uint GetEntityGID() { public void SetAttackSpeed(ushort speed) { Status.attackSpeed = speed; + EntityViewer.SetMotionSpeedMultipler(speed); } public EntityBaseStatus GetBaseStatus() { diff --git a/UnityClient/Assets/Scripts/Renderer/Entities/EntityManager.cs b/UnityClient/Assets/Scripts/Renderer/Entities/EntityManager.cs index 172081de..9f89639b 100644 --- a/UnityClient/Assets/Scripts/Renderer/Entities/EntityManager.cs +++ b/UnityClient/Assets/Scripts/Renderer/Entities/EntityManager.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading.Tasks; using UnityEngine; +using UnityEngine.AddressableAssets; using UnityEngine.Rendering; public class EntityManager : MonoBehaviour { @@ -60,12 +62,12 @@ public void VanishEntity(uint AID, int type) { entityCache.Remove(AID); } - public Entity SpawnItem(ItemSpawnInfo itemSpawnInfo) { + public async Task SpawnItem(ItemSpawnInfo itemSpawnInfo) { Item item = DBManager.GetItem(itemSpawnInfo.AID); string itemPath = DBManager.GetItemPath(itemSpawnInfo.AID, itemSpawnInfo.IsIdentified); - SpriteData spriteData = Resources.Load(Path.Combine("Sprites", itemPath)); + SpriteData spriteData = await Addressables.LoadAssetAsync($"{itemPath}.asset".SanitizeForAddressables()).Task; var itemGO = new GameObject(item.identifiedDisplayName); itemGO.layer = LayerMask.NameToLayer("Items"); diff --git a/UnityClient/Assets/Scripts/Renderer/Entities/EntityViewer.cs b/UnityClient/Assets/Scripts/Renderer/Entities/EntityViewer.cs index 1f26d0d8..d43ad8a1 100644 --- a/UnityClient/Assets/Scripts/Renderer/Entities/EntityViewer.cs +++ b/UnityClient/Assets/Scripts/Renderer/Entities/EntityViewer.cs @@ -1,10 +1,8 @@ using Assets.Scripts.Renderer.Sprite; -using ROIO; using ROIO.Models.FileTypes; using System; using System.Collections; using System.Collections.Generic; -using System.IO; using System.Linq; using UnityEngine; using UnityEngine.AddressableAssets; @@ -15,6 +13,7 @@ public class EntityViewer : MonoBehaviour { private const int AVERAGE_ATTACK_SPEED = 432; private const int AVERAGE_ATTACKED_SPEED = 288; + private const int MAX_ATTACK_SPEED = AVERAGE_ATTACKED_SPEED * 2; public Entity Entity; public EntityViewer Parent; @@ -28,7 +27,7 @@ public class EntityViewer : MonoBehaviour { public SpriteState State = SpriteState.Idle; public List Children = new List(); - private Dictionary Layers = new Dictionary(); + private Dictionary ColliderCache = new Dictionary(); private Dictionary MeshCache = new Dictionary(); private PaletteData CurrentPaletteData; @@ -42,14 +41,21 @@ public class EntityViewer : MonoBehaviour { private int ActionId = -1; private double previousFrame = 0; - private MeshCollider meshCollider; + private double motionSpeed = 4; + private double loopCountToAnimationFinish = 1; + private float motionSpeedMultiplier = 1f; + + private MeshCollider MeshCollider; + private MeshFilter MeshFilter; + private MeshRenderer MeshRenderer; + private SortingGroup SortingGroup; private Material SpriteMaterial; private Texture2D PaletteTexture; public void Start() { SpriteMaterial = Resources.Load("Materials/Sprites/SpriteMaterial") as Material; - Init(); + Init(); InitShadow(); } @@ -64,12 +70,18 @@ public async void Init(bool reloadSprites = false) { hair = Entity.Status.hair, clothesColor = Entity.Status.clothes_color }; - meshCollider = gameObject.GetOrAddComponent(); + + InitRenderers(); if (Entity.Type == EntityType.WARP) { return; } + if (Entity.Type == EntityType.ITEM) { + MeshRenderer.material = SpriteMaterial; + MeshRenderer.material.mainTexture = sprites[0].texture; + } + if (sprites == null || reloadSprites) { string path = ""; string palettePath = ""; @@ -112,10 +124,7 @@ public async void Init(bool reloadSprites = false) { if (ViewerType != ViewerType.BODY && ViewerType != ViewerType.HEAD && currentViewID <= 0) { currentACT = null; sprites = null; - Layers.Values.ToList().ForEach(Renderer => { - Destroy(Renderer.gameObject); - }); - Layers.Clear(); + ColliderCache.Clear(); MeshCache.Clear(); return; @@ -123,23 +132,16 @@ public async void Init(bool reloadSprites = false) { try { var spriteData = await Addressables.LoadAssetAsync(path + ".asset").Task; - - // Figure out a way of using palettes with shaders - //if (palettePath.Length > 0) { - // if (FileManager.Load(palettePath) is byte[] currentPalette) { - // PaletteTexture = new Texture2D(256, 1, TextureFormat.RGBA32, false) { - // filterMode = FilterMode.Point, - // wrapMode = TextureWrapMode.Clamp - // }; - // PaletteTexture.LoadRawTextureData(currentPalette); - // PaletteTexture.Apply(); - // } - //} + var atlas = await Addressables.LoadAssetAsync(path + ".png").Task; sprites = spriteData.sprites; currentACT = spriteData.act; - } catch { + MeshRenderer.material = SpriteMaterial; + MeshRenderer.material.mainTexture = atlas; + MeshRenderer.material.renderQueue -= 2; + } catch (Exception e) { Debug.LogError($"Could not load sprites for: {path}"); + Debug.LogException(e); currentACT = null; } } @@ -154,6 +156,17 @@ public async void Init(bool reloadSprites = false) { } } + private void InitRenderers() { + MeshCollider = gameObject.GetOrAddComponent(); + MeshFilter = gameObject.GetOrAddComponent(); + MeshRenderer = gameObject.GetOrAddComponent(); + SortingGroup = gameObject.GetOrAddComponent(); + + MeshRenderer.receiveShadows = false; + MeshRenderer.lightProbeUsage = LightProbeUsage.Off; + MeshRenderer.shadowCastingMode = ShadowCastingMode.Off; + } + void FixedUpdate() { if (currentACT == null || !Entity.IsReady) return; @@ -184,7 +197,6 @@ void FixedUpdate() { } UpdateMesh(frame); - RenderLayers(frame); PlaySound(frame); UpdateAnchorPoints(); } @@ -241,54 +253,50 @@ private void PlaySound(ACT.Frame frame) { } } - private void RenderLayers(ACT.Frame frame) { - // If current frame doesn't have layers, cleanup layer cache - Layers.Values.ToList().ForEach(Renderer => Renderer.sprite = null); - - for (int i = 0; i < frame.layers.Length; i++) { - var layer = frame.layers[i]; - var sprite = sprites[layer.index]; - - Layers.TryGetValue(i, out var spriteRenderer); - - if (spriteRenderer == null) { - var go = new GameObject($"Layer{i}"); - spriteRenderer = go.AddComponent(); - spriteRenderer.transform.SetParent(gameObject.transform, false); - SpriteMaterial.SetTexture("_PaletteTex", PaletteTexture); - - spriteRenderer.material = SpriteMaterial; - } - - CalculateSpritePositionScale(layer, sprite, out Vector3 scale, out Vector3 newPos, out Quaternion rotation); - - spriteRenderer.transform.localRotation = rotation; - spriteRenderer.transform.localPosition = newPos; - spriteRenderer.transform.localScale = scale; - - spriteRenderer.sprite = sprite; - spriteRenderer.material.color = layer.color; + private void UpdateMesh(ACT.Frame frame) { + // We need this mesh collider in order to have the raycast to hit the sprite + ColliderCache.TryGetValue(frame, out Mesh colliderMesh); + if (colliderMesh == null) { + colliderMesh = SpriteMeshBuilder.BuildColliderMesh(frame, sprites); + ColliderCache.Add(frame, colliderMesh); + } - if (!Layers.ContainsKey(i)) { - Layers.Add(i, spriteRenderer); - } + MeshCache.TryGetValue(frame, out Mesh rendererMesh); + if (rendererMesh == null) { + rendererMesh = SpriteMeshBuilder.BuildSpriteMesh(frame, sprites); + MeshCache.Add(frame, rendererMesh); } - } - private void UpdateMesh(ACT.Frame frame) { - // We need this mesh collider in order to have the raycast to hit the sprite - MeshCache.TryGetValue(frame, out Mesh mesh); - if (mesh == null) { - mesh = SpriteMeshBuilder.BuildColliderMesh(frame, sprites); - MeshCache.Add(frame, mesh); + foreach (var layer in frame.layers) { + MeshRenderer.material.SetFloat("_Alpha", layer.color.a); } - meshCollider.sharedMesh = mesh; + + MeshFilter.sharedMesh = null; + MeshFilter.sharedMesh = rendererMesh; + MeshCollider.sharedMesh = colliderMesh; } + /** + * Hammer time + */ private int GetCurrentFrame(long tm) { var isIdle = CurrentMotion.Motion == SpriteMotion.Idle || CurrentMotion.Motion == SpriteMotion.Sit; double animCount = currentAction.frames.Length; - long delay = GetDelay(); + + switch (CurrentMotion.Motion) { + case SpriteMotion.Attack: + case SpriteMotion.Attack1: + case SpriteMotion.Attack2: + case SpriteMotion.Attack3: + return GetAttackFrame(tm, isIdle, animCount); + default: + return GetEverythingElseFrame(tm, isIdle, animCount); + + } + } + + private int GetEverythingElseFrame(long tm, bool isIdle, double animCount) { + long delay = (long) GetDelay(); if (delay <= 0) { delay = (int) currentAction.delay; } @@ -338,13 +346,46 @@ private int GetCurrentFrame(long tm) { return (int) Math.Min(frame, animCount - 1); } + private int GetAttackFrame(long tm, bool isIdle, double animCount) { + if (isIdle) { + return 0; + } + + var stateCnt = tm / 24f; + double currentMotion; + if (!AnimationHelper.IsLoopingMotion(CurrentMotion.Motion)) { + var motionCount = animCount; + currentMotion = (int) (stateCnt / motionSpeed % animCount); + var loopCount = (stateCnt / motionSpeed) / motionCount; + + if (loopCount >= 1) { + currentMotion--; + if (loopCount >= loopCountToAnimationFinish && NextMotion.HasValue) { + ChangeMotion(NextMotion.Value); + } + } + } else { + currentMotion = (int) (stateCnt / motionSpeed % animCount); + } + + if (currentMotion <= 0) { + currentMotion = 0; + } + + return (int) currentMotion; + } + private IEnumerator ChangeMotionAfter(MotionRequest motion, float time) { yield return new WaitForSeconds(time); ChangeMotion(motion); } - private int GetDelay() { + private float GetDelay() { + if (currentACT == null || currentAction == null) { + return 4f; + } + if (ViewerType == ViewerType.BODY && CurrentMotion.Motion == SpriteMotion.Walk) { return (int) (currentAction.delay / 150 * Entity.Status.walkSpeed); } @@ -353,23 +394,19 @@ private int GetDelay() { CurrentMotion.Motion == SpriteMotion.Attack1 || CurrentMotion.Motion == SpriteMotion.Attack2 || CurrentMotion.Motion == SpriteMotion.Attack3) { - var delay = (int) (currentAction.delay * (Entity.Status.attackSpeed / AVERAGE_ATTACK_SPEED)); - return (delay > 0) ? delay : Entity.Status.attackSpeed / currentAction.FrameCount; + if (currentAction == null) { + return 4f; + } else if (currentAction.delay >= 100f) { + return 4f; + } else { + return currentAction.delay; + } } return (int) currentAction.delay; } - private void CalculateSpritePositionScale(ACT.Layer layer, Sprite sprite, out Vector3 scale, out Vector3 newPos, out Quaternion rotation) { - rotation = Quaternion.Euler(0, 0, -layer.angle); - scale = new Vector3(layer.scale.x * (layer.isMirror ? -1 : 1), layer.scale.y, 1); - var offsetX = (Mathf.RoundToInt(sprite.rect.width) % 2 == 1) ? 0.5f : 0f; - var offsetY = (Mathf.RoundToInt(sprite.rect.height) % 2 == 1) ? 0.5f : 0f; - - newPos = new Vector3(layer.pos.x - offsetX, -(layer.pos.y) + offsetY) / sprite.pixelsPerUnit; - } - public void ChangeMotion(MotionRequest motion, MotionRequest? nextMotion = null) { switch (motion.Motion) { case SpriteMotion.Dead: @@ -394,6 +431,16 @@ public void ChangeMotion(MotionRequest motion, MotionRequest? nextMotion = null) var attackActions = new SpriteMotion[] { SpriteMotion.Attack1, SpriteMotion.Attack2, SpriteMotion.Attack3 }; var action = DBManager.GetWeaponAction((Job) Entity.Status.jobId, Entity.Status.sex, Entity.EquipInfo.Weapon, Entity.EquipInfo.Shield); newAction = AnimationHelper.GetMotionIdForSprite(Entity.Type, attackActions[action]); + + /** + * Seems like og client makes entity look diagonally up + * when attacking from the sides + */ + if (Entity.Direction == Direction.East) { + Entity.Direction = Direction.NorthEast; + } else if (Entity.Direction == Direction.West) { + Entity.Direction = Direction.NorthWest; + } } else { newAction = AnimationHelper.GetMotionIdForSprite(Entity.Type, motion.Motion); } @@ -404,6 +451,13 @@ public void ChangeMotion(MotionRequest motion, MotionRequest? nextMotion = null) ActionId = newAction; AnimationStart = GameManager.Tick; previousFrame = 0; + motionSpeedMultiplier = 1; + + motionSpeed = GetDelay(); + if (motionSpeed < 1) { + motionSpeed = 1; + } + motionSpeed *= motionSpeedMultiplier; foreach (var child in Children) { child.ChangeMotion(motion, nextMotion); @@ -427,6 +481,7 @@ private async void InitShadow() { var spriteRenderer = shadow.AddComponent(); spriteRenderer.sprite = spriteData.sprites[0]; spriteRenderer.sortingOrder = -1; + spriteRenderer.material.renderQueue -= 2; spriteRenderer.material.color = new Color(1, 1, 1, 0.4f); } @@ -443,6 +498,15 @@ public Vector2 GetAnimationAnchor() { return Vector2.zero; } + public IEnumerator FadeOut() { + var currentAlpha = MeshRenderer.material.GetFloat("_Alpha"); + while (currentAlpha > 0f) { + currentAlpha -= 0.05f; + MeshRenderer.material.SetFloat("_Alpha", currentAlpha); + yield return new WaitForEndOfFrame(); + } + } + public struct MotionRequest { public SpriteMotion Motion; public double delay; @@ -453,4 +517,15 @@ public struct PaletteData { public int hairColor; public int clothesColor; } + + internal void SetMotionSpeedMultipler(ushort attackMT) { + //if (weapon is bow) + if (attackMT > MAX_ATTACK_SPEED) { + attackMT = MAX_ATTACK_SPEED; + } + //endif + + motionSpeedMultiplier = (float) attackMT / AVERAGE_ATTACK_SPEED; + motionSpeed *= motionSpeedMultiplier; + } } diff --git a/UnityClient/Assets/Scripts/Renderer/Sprite/SpriteMeshBuilder.cs b/UnityClient/Assets/Scripts/Renderer/Sprite/SpriteMeshBuilder.cs index fc13ba10..21ff7af2 100644 --- a/UnityClient/Assets/Scripts/Renderer/Sprite/SpriteMeshBuilder.cs +++ b/UnityClient/Assets/Scripts/Renderer/Sprite/SpriteMeshBuilder.cs @@ -137,7 +137,7 @@ public static Mesh BuildSpriteMesh(ACT.Frame motion, Sprite[] sprites) { for (var j = 0; j < verts.Length; j++) { var v = rotation * (verts[j] * scale); - outVertices.Add(v + new Vector3(layer.pos.x - offsetX, (layer.pos.y) + offsetY) / SPR.PIXELS_PER_UNIT); + outVertices.Add(v + new Vector3(layer.pos.x - offsetX, -(layer.pos.y) + offsetY) / SPR.PIXELS_PER_UNIT); outUvs.Add(uvs[j]); outColors.Add(layer.color); outNormals.Add(new Vector3(0, 0, -1)); diff --git a/UnityClient/Assets/Scripts/Utils/Extensions/RawImageExtensions.cs b/UnityClient/Assets/Scripts/Utils/Extensions/RawImageExtensions.cs index 3d72b07c..04c5a4fc 100644 --- a/UnityClient/Assets/Scripts/Utils/Extensions/RawImageExtensions.cs +++ b/UnityClient/Assets/Scripts/Utils/Extensions/RawImageExtensions.cs @@ -6,19 +6,25 @@ using UnityEngine.UI; public static class RawImageExtenions { - + private const string LOGIN_BACKGROUND_IMAGE = "bgi_temp.png"; private const int LOADING_SCREENS_LENGTH = 10; - + public async static Task SetLoginBackground(this RawImage image) { Texture2D texture = await Addressables.LoadAssetAsync($"{DBManager.INTERFACE_PATH}{LOGIN_BACKGROUND_IMAGE}").Task; - image.texture = texture; + + if (!image.IsDestroyed()) { + image.texture = texture; + } } - + public async static Task SetLoading(this RawImage image) { double index = Math.Floor(UnityEngine.Random.Range(0, 1.0f) * LOADING_SCREENS_LENGTH); - string imageName = "loading" + ( index < 10 ? "0" + $"{index}" : $"{index}" ) + ".png"; + string imageName = "loading" + (index < 10 ? "0" + $"{index}" : $"{index}") + ".png"; Texture2D texture = await Addressables.LoadAssetAsync($"{DBManager.INTERFACE_PATH}{imageName}").Task; - image.texture = texture; + + if (!image.IsDestroyed()) { + image.texture = texture; + } } } diff --git a/UnityClient/Assets/Scripts/Utils/OfflineUtility.cs b/UnityClient/Assets/Scripts/Utils/OfflineUtility.cs index 8a34c72b..be7dc4af 100644 --- a/UnityClient/Assets/Scripts/Utils/OfflineUtility.cs +++ b/UnityClient/Assets/Scripts/Utils/OfflineUtility.cs @@ -31,7 +31,8 @@ void Start() { MapLoadingTimes = new List(); MapNames = new List(); - SpawnCharacter(); + //SpawnCharacter(); + SpawnMob(); //GameManager.BeginMapLoading(MapName); var descriptors = FileManager.GetFileDescriptors(); @@ -87,9 +88,12 @@ void SpawnCharacter() { charCam.SetTarget(offlineEntity.EntityViewer.transform); offlineEntity.SetReady(true); - //var mob = EntityManager.Spawn(new EntityData() { job = 1002, name = "Poring", GID = 20001, speed = 697, PosDir = new int[] { 0, 0, 0 }, objecttype = EntityType.MOB }); - //mob.transform.position = new Vector3(150, 0, 155); - //mob.SetReady(true); + } + + private void SpawnMob() { + var mob = EntityManager.Spawn(new EntitySpawnData() { job = 1002, name = "Poring", GID = 20001, speed = 697, PosDir = new int[] { 0, 0, 0 }, objecttype = EntityType.MOB }); + mob.transform.position = new Vector3(150, 0, 155); + mob.SetReady(true); } public async Task LoadMap() {