networking basics

This commit is contained in:
2022-05-09 18:08:56 +03:00
parent c4f5d4d4d2
commit 3b8a226fdc
17 changed files with 466 additions and 783 deletions

View File

@@ -1,65 +0,0 @@
{
"ID": "74681ad5400d069f5faeafaf9de27a73",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6215,
"Data": [
{
"ID": "16c934314cd7f81e22561ba4391c6872",
"TypeName": "FlaxEngine.PostFxVolume",
"Name": "CommonScenePrefab",
"Transform": {
"Translation": {
"X": -97.18594360351563,
"Y": 0.0,
"Z": -216.60525512695313
}
},
"Size": {
"X": 100.0,
"Y": 100.0,
"Z": 100.0
},
"IsBounded": false,
"Settings": {
"AO": {
"Enabled": false
},
"Bloom": {
"Enabled": false
},
"ToneMapping": {},
"ColorGrading": {},
"EyeAdaptation": {
"OverrideFlags": 1,
"Mode": 0
},
"CameraArtifacts": {
"OverrideFlags": 41,
"VignetteIntensity": 0.0,
"GrainAmount": 0.0,
"GrainSpeed": 0.010000050067901612
},
"LensFlares": {
"Intensity": 0.0,
"Ghosts": 0,
"HaloWidth": 0.0
},
"DepthOfField": {
"OverrideFlags": 129,
"BokehEnabled": false
},
"MotionBlur": {
"OverrideFlags": 1,
"Enabled": false
},
"SSR": {},
"AA": {
"OverrideFlags": 1,
"Mode": 3,
"TAA_JitterSpread": 0.10000000149011612
},
"PostFxMaterials": {}
}
}
]
}

View File

@@ -1,34 +0,0 @@
{
"ID": "c11d68fa43cb5b17c51f6c8c3ec51f08",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6216,
"Data": [
{
"ID": "46375015427f291423cbfea902e110bc",
"TypeName": "FlaxEngine.UICanvas",
"ParentID": "00000000000000000000000000000000",
"Name": "ConsoleCanvas",
"V": {
"Order": -9999999,
"Size": {
"X": 1465.0,
"Y": 891.0
}
}
},
{
"ID": "ae020482484dfe1d95be308832d58e56",
"TypeName": "MyCore.ConsoleScript",
"ParentID": "46375015427f291423cbfea902e110bc",
"V": {
"consoleFont": "ab96b25a49461d9f4f819484cf5c8213",
"backgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.8039216
}
}
}
]
}

View File

@@ -1,45 +0,0 @@
{
"ID": "327f82d44b3114035981f68c3ad0f793",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6216,
"Data": [
{
"ID": "b2779da2451cf5ce88400d8663df4963",
"TypeName": "FlaxEngine.UICanvas",
"ParentID": "00000000000000000000000000000000",
"Name": "ConsoleUICanvas",
"Transform": {
"Orientation": {
"X": 1.0,
"Y": 4.3711388286737938e-8,
"Z": 4.3711388286737938e-8,
"W": 1.910685465164705e-15
}
},
"V": {
"Order": -999999999,
"Size": {
"X": 1456.0,
"Y": 813.0
}
}
},
{
"ID": "13d32654469ac6b38052ff937edbe9a0",
"TypeName": "Cabrito.ConsoleScript",
"ParentID": "b2779da2451cf5ce88400d8663df4963",
"V": {
"ConsoleHeight": 0.635,
"ConsoleFont": "43f32bec443158643f53699f07b2e09c",
"BackgroundTexture": "16a2d3f1465e834c8ac965bd072c1dca",
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 1.0
},
"LineSpacing": 1.0
}
}
]
}

View File

@@ -1,141 +1,133 @@
{
"ID": "6a855e524d1809b93599278b910921b3",
"ID": "cb74184545f392e5c67815808bc63e58",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6216,
"EngineBuild": 6332,
"Data": [
{
"ID": "d902f53245e68d652dfe928706dd976f",
"ID": "9e1b61dc44338f962e69f78ecb3d0536",
"TypeName": "FlaxEngine.UICanvas",
"ParentID": "00000000000000000000000000000000",
"Name": "DefaultHudPrefab",
"Transform": {
"Translation": {
"X": -35.90293884277344,
"Y": 0.0,
"Z": -89.94500732421875
},
"Orientation": {
"X": 1.0,
"Y": 4.371138828673793e-8,
"Z": 4.371138828673793e-8,
"Y": 4.3711388286737938e-8,
"Z": 4.3711388286737938e-8,
"W": 1.910685465164705e-15
}
},
"V": {
"Size": {
"X": 1458.0,
"Y": 828.0
}
}
"V": {}
},
{
"ID": "2e2a7beb4ad7ce04b9c776948c457ddc",
"TypeName": "MyCore.ConsoleScript",
"ParentID": "d902f53245e68d652dfe928706dd976f",
"ID": "d64fff8743e0d5893c235c94e7070976",
"TypeName": "Cabrito.FpsScript",
"ParentID": "9e1b61dc44338f962e69f78ecb3d0536",
"V": {
"consoleFont": "ab96b25a49461d9f4f819484cf5c8213",
"backgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.8055556
}
}
"control": "74464027453c88b3203fa79333f0730e"
}
},
{
"ID": "5658891f4b25b2573beed4912c8fb409",
"ID": "0c7588dd41779a8ada6f57974d94e073",
"TypeName": "Cabrito.ConsoleScript",
"ParentID": "9e1b61dc44338f962e69f78ecb3d0536",
"V": {
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 1.0
},
"ConsoleFont": "43f32bec443158643f53699f07b2e09c"
}
},
{
"ID": "74464027453c88b3203fa79333f0730e",
"TypeName": "FlaxEngine.UIControl",
"ParentID": "d902f53245e68d652dfe928706dd976f",
"ParentID": "9e1b61dc44338f962e69f78ecb3d0536",
"Name": "FPSUIControl",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 26.0,
"Y": 716.0,
"Z": 0.0
}
},
"Control": "FlaxEngine.GUI.Label",
"Data": {
"Text": "fps?",
"TextColor": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"TextColorHighlighted": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"HorizontalAlignment": 1,
"VerticalAlignment": 1,
"Wrapping": 0,
"Font": {
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Margin": {
"Left": 0.0,
"Right": 0.0,
"Top": 0.0,
"Bottom": 0.0
},
"ClipText": false,
"AutoWidth": true,
"AutoHeight": true,
"AutoFitText": false,
"AutoFitTextRange": {
"X": 0.1,
"Y": 100.0
},
"ClipChildren": true,
"CullChildren": true,
"AnchorMin": {
"X": 0.0,
"Y": 0.0
},
"AnchorMax": {
"X": 0.0,
"Y": 0.0
},
"Offsets": {
"Left": 0.0,
"Right": 25.0,
"Top": 26.0,
"Bottom": 16.0
},
"Scale": {
"X": 1.0,
"Y": 1.0
},
"Pivot": {
"X": 0.5,
"Y": 0.5
},
"Shear": {
"X": 0.0,
"Y": 0.0
},
"Rotation": 0.0,
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.0
},
"Enabled": true,
"Visible": true,
"AutoFocus": false
}
},
{
"ID": "7ae6fbc24d3c0133ec0b8a8f3cabeee5",
"TypeName": "MyCore.FpsScript",
"ParentID": "5658891f4b25b2573beed4912c8fb409",
"V": {
"control": "5658891f4b25b2573beed4912c8fb409"
}
"Text": "eFPS: 121 uTime: 116.42902\nuFPS: 120 uTime: 0\nrFPS: 120 rTime: 0\npFPS: 30 pTime: 0",
"TextColor": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"TextColorHighlighted": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"HorizontalAlignment": 0,
"VerticalAlignment": 0,
"Wrapping": 0,
"Font": {
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Material": null,
"Margin": {
"Left": 0.0,
"Right": 0.0,
"Top": 0.0,
"Bottom": 0.0
},
"ClipText": false,
"AutoWidth": true,
"AutoHeight": true,
"AutoFitText": false,
"AutoFitTextRange": {
"X": 0.1,
"Y": 100.0
},
"ClipChildren": true,
"CullChildren": true,
"AnchorMin": {
"X": 0.0,
"Y": 1.0
},
"AnchorMax": {
"X": 0.0,
"Y": 1.0
},
"Offsets": {
"Left": 0.0,
"Right": 161.0,
"Top": -97.0,
"Bottom": 64.0
},
"Scale": {
"X": 1.0,
"Y": 1.0
},
"Pivot": {
"X": 0.5,
"Y": 0.5
},
"Shear": {
"X": 0.0,
"Y": 0.0
},
"Rotation": 0.0,
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.0
},
"Enabled": true,
"Visible": true,
"AutoFocus": false
}
}
]
}

View File

@@ -1,191 +0,0 @@
{
"ID": "44b0e2e14042c518372ad4a713c03554",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6225,
"Data": [
{
"ID": "4cf08e994b0aba2a1f27d78581801a15",
"TypeName": "FlaxEngine.UICanvas",
"ParentID": "00000000000000000000000000000000",
"Name": "DefaultHudPrefab",
"Transform": {
"Orientation": {
"X": 1.0,
"Y": 4.3711388286737938e-8,
"Z": 4.3711388286737938e-8,
"W": 1.910685465164705e-15
}
},
"V": {}
},
{
"ID": "f07ac47945765b274830ab9d017a39cb",
"TypeName": "Cabrito.FpsScript",
"ParentID": "4cf08e994b0aba2a1f27d78581801a15",
"V": {
"control": "86b4047b47495cc4b736bf99c1e400ac"
}
},
{
"ID": "1792e2ec40703885e1d1329311f35adc",
"TypeName": "Cabrito.ConsoleScript",
"ParentID": "4cf08e994b0aba2a1f27d78581801a15",
"V": {
"ConsoleFont": "43f32bec443158643f53699f07b2e09c",
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 1.0
}
}
},
{
"ID": "86b4047b47495cc4b736bf99c1e400ac",
"TypeName": "FlaxEngine.UIControl",
"ParentID": "4cf08e994b0aba2a1f27d78581801a15",
"Name": "FPSUIControl",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 730.0,
"Z": 0.0
}
},
"Control": "FlaxEngine.GUI.Label",
"Data": {
"Text": "eFPS: 528\nuFPS: 531\nrFPS: 528\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 13.01433MB",
"TextColor": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"TextColorHighlighted": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"HorizontalAlignment": 0,
"VerticalAlignment": 0,
"Wrapping": 0,
"Font": {
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Material": null,
"Margin": {
"Left": 0.0,
"Right": 0.0,
"Top": 0.0,
"Bottom": 0.0
},
"ClipText": false,
"AutoWidth": true,
"AutoHeight": true,
"AutoFitText": false,
"AutoFitTextRange": {
"X": 0.1,
"Y": 100.0
},
"ClipChildren": true,
"CullChildren": true,
"AnchorMin": {
"X": 0.0,
"Y": 1.0
},
"AnchorMax": {
"X": 0.0,
"Y": 1.0
},
"Offsets": {
"Left": 0.0,
"Right": 143.0,
"Top": -80.0,
"Bottom": 112.0
},
"Scale": {
"X": 1.0,
"Y": 1.0
},
"Pivot": {
"X": 0.5,
"Y": 0.5
},
"Shear": {
"X": 0.0,
"Y": 0.0
},
"Rotation": 0.0,
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.0
},
"Enabled": true,
"Visible": true
}
},
{
"ID": "20a15fd74b0072c52e00fc85ba8d62a1",
"TypeName": "FlaxEngine.UIControl",
"ParentID": "4cf08e994b0aba2a1f27d78581801a15",
"Name": "UIControl"
},
{
"ID": "b2561bca4e5afe01ec2e4a96cef38c0b",
"TypeName": "FlaxEngine.UIControl",
"ParentID": "4cf08e994b0aba2a1f27d78581801a15",
"Name": "ContainerControl 0",
"Transform": {
"Translation": {
"X": 45644.0,
"Y": -1.0,
"Z": 0.0
}
},
"Control": "FlaxEngine.GUI.ContainerControl",
"Data": {
"ClipChildren": true,
"CullChildren": true,
"AnchorMin": {
"X": 1.0,
"Y": 0.5
},
"AnchorMax": {
"X": 1.0,
"Y": 0.5
},
"Offsets": {
"Left": 44188.0,
"Right": 100.0,
"Top": -406.0,
"Bottom": 30.0
},
"Scale": {
"X": 1.0,
"Y": 1.0
},
"Pivot": {
"X": 0.5,
"Y": 0.5
},
"Shear": {
"X": 0.0,
"Y": 0.0
},
"Rotation": 0.0,
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.0
},
"Enabled": true,
"Visible": true
}
}
]
}

View File

@@ -1,7 +1,7 @@
{
"ID": "82e58c9d462fba5a0df1a599417ff684",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6331,
"EngineBuild": 6332,
"Data": [
{
"ID": "a50f3639419a8306036ecfab7115e772",
@@ -41,6 +41,7 @@
"ID": "51c770f24232abbb112cc98b296820d8",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "e590615440a1c571c7b1b4956f55078b",
"IsActive": false,
"Name": "CameraHolder",
"Transform": {
"Translation": {
@@ -104,6 +105,7 @@
"ID": "56eddcef4698702bd3cb0b8a1fb3396f",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "a50f3639419a8306036ecfab7115e772",
"IsActive": false,
"Name": "ViewModelHolder",
"Transform": {
"Translation": {
@@ -123,76 +125,30 @@
}
},
{
"ID": "111ba6ba4129558d16c0629bb31a55f9",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "56eddcef4698702bd3cb0b8a1fb3396f",
"Name": "DummyWeapon",
"Transform": {
"Translation": {
"X": 7.394217491149902,
"Y": -11.22248649597168,
"Z": -3.27701997756958
},
"Orientation": {
"X": 0.6691311001777649,
"Y": 0.0,
"Z": 0.0,
"W": 0.7431443929672241
},
"Scale": {
"X": 0.07999999821186066,
"Y": 0.431741327047348,
"Z": 0.07999999821186066
}
},
"StaticFlags": 0,
"Layer": 2,
"Model": "223aa9894e90973780ab508621517526",
"ID": "9ef0c1b8412a19d04d298c840ca4f456",
"PrefabID": "7f0707924e86984317e6a78b55e68245",
"PrefabObjectID": "056a93524632b9e0d83c6fbcbd020680",
"ParentID": "56eddcef4698702bd3cb0b8a1fb3396f"
},
{
"ID": "743289494a7bd68f6a28df86ea7a04c8",
"PrefabID": "7f0707924e86984317e6a78b55e68245",
"PrefabObjectID": "bb8115cf4fd8d0906b1e928a171763c5",
"ParentID": "9ef0c1b8412a19d04d298c840ca4f456",
"Buffer": {
"Entries": [
{
"Material": "ae5c8a4b4f723b60b8b31290a9dfb21a",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
{}
]
}
},
{
"ID": "99a5bfe4459e3ac2c3f0198ede38a587",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "56eddcef4698702bd3cb0b8a1fb3396f",
"Name": "DummyWeapon 0",
"Transform": {
"Translation": {
"X": 7.35720682144165,
"Y": -9.197076797485352,
"Z": 15.981095314025879
},
"Orientation": {
"X": 0.6691311001777649,
"Y": 0.0,
"Z": 0.0,
"W": 0.7431443929672241
},
"Scale": {
"X": 0.09000000357627869,
"Y": 0.05855093151330948,
"Z": 0.09000000357627869
}
},
"StaticFlags": 0,
"Layer": 2,
"Model": "223aa9894e90973780ab508621517526",
"ID": "002d17944803ee2ca1f3cd88bc76b68e",
"PrefabID": "7f0707924e86984317e6a78b55e68245",
"PrefabObjectID": "a54aa52147b86b56df27fdaa9ba7ca52",
"ParentID": "9ef0c1b8412a19d04d298c840ca4f456",
"Buffer": {
"Entries": [
{
"Material": "ae5c8a4b4f723b60b8b31290a9dfb21a",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
{}
]
}
},

View File

@@ -0,0 +1,86 @@
{
"ID": "7f0707924e86984317e6a78b55e68245",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6332,
"Data": [
{
"ID": "056a93524632b9e0d83c6fbcbd020680",
"TypeName": "FlaxEngine.EmptyActor",
"Name": "RocketLauncher"
},
{
"ID": "bb8115cf4fd8d0906b1e928a171763c5",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "056a93524632b9e0d83c6fbcbd020680",
"Name": "Cylinder1",
"Transform": {
"Translation": {
"X": 7.394218921661377,
"Y": -11.22248649597168,
"Z": -3.27702260017395
},
"Orientation": {
"X": 0.6691311001777649,
"Y": 0.0,
"Z": 0.0,
"W": 0.7431443929672241
},
"Scale": {
"X": 0.07999999821186066,
"Y": 0.431741327047348,
"Z": 0.07999999821186066
}
},
"StaticFlags": 0,
"Layer": 2,
"Model": "223aa9894e90973780ab508621517526",
"Buffer": {
"Entries": [
{
"Material": "ae5c8a4b4f723b60b8b31290a9dfb21a",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
]
}
},
{
"ID": "a54aa52147b86b56df27fdaa9ba7ca52",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "056a93524632b9e0d83c6fbcbd020680",
"Name": "Cylinder2",
"Transform": {
"Translation": {
"X": 7.35720682144165,
"Y": -9.197076797485352,
"Z": 15.981095314025879
},
"Orientation": {
"X": 0.6691311001777649,
"Y": 0.0,
"Z": 0.0,
"W": 0.7431443929672241
},
"Scale": {
"X": 0.09000000357627869,
"Y": 0.05855093151330948,
"Z": 0.09000000357627869
}
},
"StaticFlags": 0,
"Layer": 2,
"Model": "223aa9894e90973780ab508621517526",
"Buffer": {
"Entries": [
{
"Material": "ae5c8a4b4f723b60b8b31290a9dfb21a",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
]
}
}
]
}

View File

@@ -27,22 +27,15 @@
},
{
"ID": "ff6b6db54b5aa08e7286ef86246149ef",
"TypeName": "FlaxEngine.UICanvas",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "9e1b61dc44338f962e69f78ecb3d0536",
"ParentID": "194e05f445ece24ec5448d886e1334df",
"Name": "DefaultHudPrefab",
"Transform": {
"Orientation": {
"X": 1.0,
"Y": 4.371138828673793e-8,
"Z": 4.371138828673793e-8,
"W": 1.910685465164705e-15
}
},
"V": {}
},
{
"ID": "791756db4da9af04d7513f9f305e4652",
"TypeName": "Cabrito.FpsScript",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "d64fff8743e0d5893c235c94e7070976",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"V": {
"control": "d15fa816476f9d66ebdfc7ae25c3c6ea"
@@ -50,23 +43,16 @@
},
{
"ID": "b20f2b0a486762a15e6a7caf72ae66c2",
"TypeName": "Cabrito.ConsoleScript",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "0c7588dd41779a8ada6f57974d94e073",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"V": {
"ConsoleFont": "43f32bec443158643f53699f07b2e09c",
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 1.0
}
}
"V": {}
},
{
"ID": "d15fa816476f9d66ebdfc7ae25c3c6ea",
"TypeName": "FlaxEngine.UIControl",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "74464027453c88b3203fa79333f0730e",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"Name": "FPSUIControl",
"Transform": {
"Translation": {
"X": 0.0,
@@ -74,81 +60,8 @@
"Z": 0.0
}
},
"Control": "FlaxEngine.GUI.Label",
"Data": {
"Text": "eFPS: 120 uTime: 0.1533353\nuFPS: -2147483648 uTime: 0.00833330024033785\nrFPS: -2147483648 rTime: 0\npFPS: -2147483648 pTime: 0",
"TextColor": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"TextColorHighlighted": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"HorizontalAlignment": 0,
"VerticalAlignment": 0,
"Wrapping": 0,
"Font": {
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Material": null,
"Margin": {
"Left": 0.0,
"Right": 0.0,
"Top": 0.0,
"Bottom": 0.0
},
"ClipText": false,
"AutoWidth": true,
"AutoHeight": true,
"AutoFitText": false,
"AutoFitTextRange": {
"X": 0.1,
"Y": 100.0
},
"ClipChildren": true,
"CullChildren": true,
"AnchorMin": {
"X": 0.0,
"Y": 1.0
},
"AnchorMax": {
"X": 0.0,
"Y": 1.0
},
"Offsets": {
"Left": 0.0,
"Right": 284.0,
"Top": -97.0,
"Bottom": 64.0
},
"Scale": {
"X": 1.0,
"Y": 1.0
},
"Pivot": {
"X": 0.5,
"Y": 0.5
},
"Shear": {
"X": 0.0,
"Y": 0.0
},
"Rotation": 0.0,
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.0
},
"Enabled": true,
"Visible": true,
"AutoFocus": false
"Text": "eFPS: 120 uTime: 4.1501515\nuFPS: 120 uTime: 0\nrFPS: 120 rTime: 0\npFPS: 30 pTime: 0"
}
},
{
@@ -201,137 +114,6 @@
},
"PostFxMaterials": {}
}
},
{
"ID": "59cc65774b36b4a58a274fb7b4e9d490",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "a50f3639419a8306036ecfab7115e772",
"ParentID": "194e05f445ece24ec5448d886e1334df",
"V": {}
},
{
"ID": "d61703984dca52b9af97dda26bb87c0e",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "bc518e2f40ec06a4523d78b52809c668",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490",
"V": {}
},
{
"ID": "229033d34bad347b1982ac9a6dcf66f4",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "e590615440a1c571c7b1b4956f55078b",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
},
{
"ID": "f4ab880f47cab1ca423ce8b04f524ac2",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "51c770f24232abbb112cc98b296820d8",
"ParentID": "229033d34bad347b1982ac9a6dcf66f4"
},
{
"ID": "5a8b2a254a497d86d38aceac8daea934",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "25fbe7024ef684d3b5141eaf9713c973",
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2",
"V": {}
},
{
"ID": "5a96096947dadddc8576978ffc6ee455",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "1b648b37406d810fecb8e1ba45a51c84",
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2",
"V": {}
},
{
"ID": "86dbba284fbe908c9e62b89493e9a83f",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "eb46ab96465957dc67a052bd0e2ad1e5",
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2"
},
{
"ID": "3aeb375e4a99e66e88cfe996c97d2a5b",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "bf565fad465085439630808350b1be4d",
"ParentID": "86dbba284fbe908c9e62b89493e9a83f",
"V": {
"camera": "711a0025492161a44f48afa6e591b6ab"
}
},
{
"ID": "711a0025492161a44f48afa6e591b6ab",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "0e2e8a4f4623887ca2be699fe858beb2",
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2"
},
{
"ID": "4bedd9724ad22177fbf75f9bf51cc27f",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "262c688d49caaf66eb7e6a97f0d01206",
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2"
},
{
"ID": "f3b9d1594b1f2fc5b793adb5f144ab46",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "56eddcef4698702bd3cb0b8a1fb3396f",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
},
{
"ID": "8ef08cf4468a34df2e97d8a971d5a2dd",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "195f796349961ef9a9d46a8657fc693b",
"ParentID": "f3b9d1594b1f2fc5b793adb5f144ab46",
"V": {}
},
{
"ID": "d267a9954013a72391bd3a921d214639",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "111ba6ba4129558d16c0629bb31a55f9",
"ParentID": "f3b9d1594b1f2fc5b793adb5f144ab46",
"Buffer": {
"Entries": [
{}
]
}
},
{
"ID": "0bf71acc46ee83ac2cfffbb9269bcd11",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "99a5bfe4459e3ac2c3f0198ede38a587",
"ParentID": "f3b9d1594b1f2fc5b793adb5f144ab46",
"Buffer": {
"Entries": [
{}
]
}
},
{
"ID": "b8dde5a34570002b6b5666a89d6a70cb",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "a5850c1640208268c45f2892fe6b9e45",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
},
{
"ID": "3673873e4300efe664dfc7b743fa1b80",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "0dcd9f8d42d9e574e45af8b8bdad373d",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
},
{
"ID": "1c9fb3124b9c1ae1e704f59267d3e687",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "3932111d4c6f925a7b4a2e912307c82a",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
},
{
"ID": "fd4a1e8447db1c20c62974aa57fc205f",
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
"PrefabObjectID": "12cd95b64f5145dcae7b28b7404ef512",
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490",
"Buffer": {
"Entries": [
{}
]
}
}
]
}

View File

@@ -1,7 +1,7 @@
{
"ID": "af2e52554f7faed7b4937181dd22d166",
"TypeName": "FlaxEditor.Content.Settings.BuildSettings",
"EngineBuild": 6331,
"EngineBuild": 6332,
"Data": {
"MaxAssetsPerPackage": 4096,
"MaxPackageSizeMB": 1024,
@@ -12,7 +12,8 @@
"AdditionalAssetFolders": [
"Content/Materials",
"Content/Textures",
"Content/Audio"
"Content/Audio",
"Content/Common"
],
"ShadersNoOptimize": false,
"ShadersGenerateDebugData": false,

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FlaxEngine;
using FlaxEngine.Networking;
@@ -6,17 +8,28 @@ using Console = Cabrito.Console;
namespace Game
{
public enum GameModeMessageType : byte
{
SpawnPlayer,
PlayerInput,
}
public static class GameModeManager
{
private static Dictionary<uint, PlayerActor> players;
public static void Init()
{
NetworkManager.OnMessage += OnClientConnected;
players = new Dictionary<uint, PlayerActor>();
NetworkManager.OnMessage += OnMessage;
Level.SceneLoaded += OnLevelLoaded;
}
public static void Cleanup()
{
NetworkManager.OnMessage -= OnClientConnected;
NetworkManager.OnMessage -= OnMessage;
Level.SceneLoaded -= OnLevelLoaded;
}
@@ -25,22 +38,107 @@ namespace Game
Console.Print("level loaded");
}
public static bool OnClientConnected(NetworkMessage message)
public static bool OnMessage(ref NetworkEvent networkEvent)
{
Console.Print("client connected");
byte messageTypeByte = networkEvent.Message.ReadByte();
if (!Enum.IsDefined(typeof(GameModeMessageType), messageTypeByte))
{
//Console.PrintError($"GameModeManager: Unsupported message type received from client: {messageTypeByte}");
return false;
}
GameModeMessageType messageType = (GameModeMessageType)messageTypeByte;
//Console.Print($"GameModeManager: {messageType}");
switch (messageType)
{
case GameModeMessageType.SpawnPlayer:
{
SpawnPlayer(networkEvent.Message.ReadUInt32(),
new Vector3(networkEvent.Message.ReadSingle(), networkEvent.Message.ReadSingle(), networkEvent.Message.ReadSingle()),
new Vector3(networkEvent.Message.ReadSingle(), networkEvent.Message.ReadSingle(), networkEvent.Message.ReadSingle()));
break;
}
case GameModeMessageType.PlayerInput:
{
uint playerId = networkEvent.Sender.ConnectionId;
PlayerInputState inputState = new PlayerInputState();
inputState.frame = networkEvent.Message.ReadUInt64();
inputState.viewDeltaX = networkEvent.Message.ReadSingle();
inputState.viewDeltaY = networkEvent.Message.ReadSingle();
inputState.moveForward = networkEvent.Message.ReadSingle();
inputState.moveRight = networkEvent.Message.ReadSingle();
inputState.attacking = networkEvent.Message.ReadBoolean();
inputState.jumping = networkEvent.Message.ReadBoolean();
UpdatePlayerInput(playerId, inputState);
break;
}
default:
Console.PrintError($"GameModeManager: Unhandled message type: {messageType}");
return false;
}
return true;
}
public static bool OnClientConnecting(NetworkConnection connection)
{
return true;
}
public static bool OnClientConnected(NetworkConnection connection)
{
var spawns = Level.GetActors<Actor>().Where(x => x.Name.StartsWith("PlayerSpawn_")).ToArray();
Console.Print($"found {spawns.Length} spawns");
var randomSpawn = spawns.First();
PlayerActor localPlayerActor = Level.FindActor<PlayerActor>();
uint playerId = connection.ConnectionId;
Vector3 position = randomSpawn.Position + new Vector3(0f, 4.1f, 0f);
Vector3 eulerAngles = randomSpawn.Orientation.EulerAngles;
localPlayerActor.Teleport(randomSpawn.Position + new Vector3(0f, 4.1f, 0f), randomSpawn.Orientation.EulerAngles);
players.Add(playerId, null);
SpawnPlayer(playerId, position, eulerAngles);
{
NetworkMessage message = NetworkManager.ServerBeginSendMessage();
message.WriteByte((byte)GameModeMessageType.SpawnPlayer);
message.WriteUInt32(playerId);
message.WriteSingle(position.X);
message.WriteSingle(position.Y);
message.WriteSingle(position.Z);
message.WriteSingle(eulerAngles.X);
message.WriteSingle(eulerAngles.Y);
message.WriteSingle(eulerAngles.Z);
NetworkManager.ServerEndSendMessage(ref message, connection);
}
return true;
}
private static void SpawnPlayer(uint playerId, Vector3 position, Vector3 eulerAngles)
{
if (NetworkManager.IsLocalClient)
return; // Handled by listenserver
string workDir = Directory.GetCurrentDirectory();
string prefabPath = Path.Combine(workDir, "Content", "Common");
var playerPrefab = Content.Load<Prefab>(Path.Combine(prefabPath, "PlayerPrefab.prefab"));
if (playerPrefab == null)
Console.PrintError("GameModeManager: Failed to find PlayerPrefab");
PlayerActor playerActor = PrefabManager.SpawnPrefab(playerPrefab).As<PlayerActor>();
playerActor.Initialize(playerId);
playerActor.Teleport(position, eulerAngles);
players[playerId] = playerActor;
}
private static void UpdatePlayerInput(uint playerId, PlayerInputState inputState)
{
PlayerActor playerActor = players[playerId];
playerActor.UpdateNetworkInput(inputState);
}
}
}

View File

@@ -30,12 +30,12 @@ namespace Game
public static partial class NetworkManager
{
public delegate bool OnMessageDecl(NetworkMessage message);
public delegate bool OnMessageDecl(ref NetworkEvent networkEvent);
private static bool initialized;
private static NetworkPeer server;
private static NetworkPeer client;
public static NetworkPeer server;
public static NetworkPeer client;
private static readonly ushort ServerPort = 59183;
private static string ServerAddress;
@@ -43,6 +43,9 @@ namespace Game
private static readonly ushort MaximumClients = 32;
public static OnMessageDecl OnMessage;
public static bool IsServer => server != null;
public static bool IsLocalClient = false; // Context dependant, true when message is handled by local client
public static void Init()
{
if (initialized)
@@ -104,7 +107,7 @@ namespace Game
initialized = false;
}
private static void OnNetworkMessage(NetworkEvent networkEvent)
private static void OnNetworkMessage(ref NetworkEvent networkEvent)
{
byte messageTypeByte = networkEvent.Message.ReadByte();
if (!Enum.IsDefined(typeof(NetworkMessageType), messageTypeByte))
@@ -129,7 +132,7 @@ namespace Game
foreach (OnMessageDecl func in OnMessage.GetInvocationList()
.Cast<OnMessageDecl>().ToArray())
{
bool ret = func.Invoke(networkEvent.Message);
bool ret = func.Invoke(ref networkEvent);
if (ret)
break;
}

View File

@@ -60,9 +60,16 @@ namespace Game
}
case NetworkEventType.Message:
{
OnNetworkMessage(networkEvent);
client.RecycleMessage(networkEvent.Message);
try
{
IsLocalClient = IsServer;
OnNetworkMessage(ref networkEvent);
}
finally
{
IsLocalClient = false;
client.RecycleMessage(networkEvent.Message);
}
break;
}
default:

View File

@@ -68,6 +68,30 @@ namespace Game
return true;
}
public static NetworkMessage ServerBeginSendMessage()
{
NetworkMessage message = server.BeginSendMessage();
message.WriteByte((byte)NetworkMessageType.Message);
return message;
}
public static void ServerEndSendMessage(ref NetworkMessage message, NetworkConnection connection)
{
server.EndSendMessage(NetworkChannelType.Reliable, message, connection);
}
public static NetworkMessage ClientBeginSendMessage()
{
NetworkMessage message = client.BeginSendMessage();
message.WriteByte((byte)NetworkMessageType.Message);
return message;
}
public static void ClientEndSendMessage(ref NetworkMessage message)
{
client.EndSendMessage(NetworkChannelType.Reliable, message);
}
private static void OnServerUpdate()
{
using Utilities.ScopeProfiler _ = Utilities.ProfileScope("NetworkManager_OnServerUpdate");
@@ -77,18 +101,18 @@ namespace Game
{
case NetworkEventType.Connected:
{
Console.Print($"Client({networkEvent.Sender.ConnectionId}) connected!");
Console.Print($"Client({networkEvent.Sender.ConnectionId}) is trying to connect");
ConnectedClients.Add(networkEvent.Sender);
Console.Print("Connected clients: " + ConnectedClients.Count);
// Send hello message to the client back
if (GameModeManager.OnClientConnecting(networkEvent.Sender))
{
NetworkMessage sendmessage = server.BeginSendMessage();
sendmessage.WriteByte((byte)NetworkMessageType.Message);
//sendmessage.WriteString($"Welcome, ({networkEvent.Sender.ConnectionId})");
server.EndSendMessage(NetworkChannelType.Reliable, sendmessage, networkEvent.Sender);
ConnectedClients.Add(networkEvent.Sender);
Console.Print($"Client({networkEvent.Sender.ConnectionId}) connected. Total clients: {ConnectedClients.Count}");
GameModeManager.OnClientConnected(networkEvent.Sender);
}
else
Console.Print($"Client({networkEvent.Sender.ConnectionId}) connection refused");
break;
}
case NetworkEventType.Disconnected:
@@ -102,8 +126,14 @@ namespace Game
}
case NetworkEventType.Message:
{
OnNetworkMessage(networkEvent);
server.RecycleMessage(networkEvent.Message);
try
{
OnNetworkMessage(ref networkEvent);
}
finally
{
server.RecycleMessage(networkEvent.Message);
}
break;
}
default:

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Cabrito;
using FlaxEngine;
#if FLAX_EDITOR
using FlaxEditor.CustomEditors.Dedicated;
@@ -57,6 +58,22 @@ namespace Game
playerRigidBody = FindActor<RigidBody>();
}
public void Initialize(uint playerId)
{
playerMovement.SetInput(playerId);
if (playerId == NetworkManager.LocalPlayerClientId)
{
FindActor("CameraHolder").IsActive = true;
FindActor("ViewModelHolder").IsActive = true;
}
}
public void UpdateNetworkInput(PlayerInputState inputState)
{
if (playerMovement.input is PlayerInputNetwork)
(playerMovement.input as PlayerInputNetwork).currentState.input = inputState;
}
public void SetPosition(Vector3 newPosition)
{
Position = newPosition;

View File

@@ -12,6 +12,8 @@ namespace Game
protected List<PlayerInputState> buffer = new List<PlayerInputState>();
protected FileStream demoFileStream;
public bool IsNetworked => NetworkManager.client != null;
public PlayerInputLocal()
{
}
@@ -59,6 +61,20 @@ namespace Game
buffer.Add(currentState.input);
}
if (IsNetworked)
{
var message = NetworkManager.ClientBeginSendMessage();
message.WriteByte((byte)GameModeMessageType.PlayerInput);
message.WriteUInt64(currentState.input.frame);
message.WriteSingle(currentState.input.viewDeltaX);
message.WriteSingle(currentState.input.viewDeltaY);
message.WriteSingle(currentState.input.moveForward);
message.WriteSingle(currentState.input.moveRight);
message.WriteBoolean(currentState.input.attacking);
message.WriteBoolean(currentState.input.jumping);
NetworkManager.ClientEndSendMessage(ref message);
}
// Reset anything accumulatable here
currentState.input.viewDeltaX = 0;
currentState.input.viewDeltaY = 0;

View File

@@ -83,7 +83,7 @@ namespace Game
private int currentInputFrame2;
private Vector3 currentVelocity;
private PlayerInput input;
public PlayerInput input;
//private bool physicsInteractions = false;
@@ -117,6 +117,8 @@ namespace Game
//private Vector3 safePosition;
public uint PlayerId = 0;
[ReadOnly]
public float CurrentVelocity
{
@@ -139,16 +141,10 @@ namespace Game
public override void OnAwake()
{
base.OnAwake();
Console.Print("player awake");
bool record = false;
//record = true;
if (record)
input = new PlayerInputLocal(@"C:\dev\GoakeFlax\testdemo.gdem"); // record
else
input = new PlayerInputLocal();
//input = new PlayerInputDemo(@"C:\dev\GoakeFlax\testdemo.gdem"); //playback
//input = new PlayerInputDemo(@"C:\dev\GoakeFlax\testdemo_desync.gdem"); //playback
// Setup input with no controller
SetInput(PlayerId);
onExit.Triggered += () =>
{
@@ -167,6 +163,29 @@ namespace Game
startupTime = Time.TimeSinceStartup;
}
public void SetInput(uint playerId)
{
if (playerId == 0)
input = new PlayerInput();
else if (playerId == NetworkManager.LocalPlayerClientId)
{
Console.Print("local player: " + playerId.ToString());
input = new PlayerInputLocal(); // TODO: support recording
PlayerId = playerId;
}
else
{
Console.Print("network player: " + playerId.ToString());
input = new PlayerInputNetwork();
PlayerId = playerId;
}
}
public void SetInput(string demoFile)
{
input = new PlayerInputDemo(demoFile);
}
public override void OnDisable()
{
base.OnDisable();
@@ -363,9 +382,15 @@ namespace Game
private static bool SweepPlayerCollider(Actor actor, Vector3 start, Vector3 end, out RayCastHit[] hits)
{
Vector3 delta = end - start;
float maxDistance = delta.Length;
float distance = delta.Length;
Vector3 direction = delta.Normalized;
if (distance < 0.00000001f)
{
hits = Array.Empty<RayCastHit>();
return false;
}
bool collided = false;
CapsuleCollider capsuleCollider = actor.GetChild<CapsuleCollider>();
BoxCollider boxCollider = actor.GetChild<BoxCollider>();
@@ -373,24 +398,26 @@ namespace Game
if (capsuleCollider && capsuleCollider.IsActive)
collided = Physics.CapsuleCastAll(start,
capsuleCollider.Radius, capsuleCollider.Height,
direction, out hits, capsuleCollider.Orientation, maxDistance,
direction, out hits, capsuleCollider.Orientation, distance,
uint.MaxValue,
false);
else if (meshCollider && meshCollider.IsActive)
collided = Physics.ConvexCastAll(start,
meshCollider.CollisionData, meshCollider.Scale,
direction, out hits, meshCollider.Orientation, maxDistance,
direction, out hits, meshCollider.Orientation, distance,
uint.MaxValue,
false);
else if (boxCollider && boxCollider.IsActive)
collided = Physics.BoxCastAll(start,
boxCollider.OrientedBox.Extents,
direction, out hits, boxCollider.Orientation, maxDistance,
direction, out hits, boxCollider.Orientation, distance,
uint.MaxValue,
false);
else
throw new Exception("Player does not have a collider");
return collided;
}

View File

@@ -29,11 +29,14 @@ public class GameTarget : GameProjectTarget
public override string GetOutputFilePath(BuildOptions options, TargetOutputType? outputType = null)
{
// For IDE builds only, these do not work during cooking (fails to update cooked files in multiple ways)
if (options.Configuration == TargetConfiguration.Development)
options.OutputFolder = @"C:\dev\GoakeFlax\Output\WindowsDevelopment";
else if (options.Configuration == TargetConfiguration.Release)
options.OutputFolder = @"C:\dev\GoakeFlax\Output\WindowsRelease";
if (!Environment.CommandLine.Contains("Cooker")) // Hacky way to detect if this is run during cooking
{
// Output files directly to cooked folders (used only during development)
if (options.Configuration == TargetConfiguration.Development)
options.OutputFolder = @"C:\dev\GoakeFlax\Output\WindowsDevelopment";
else if (options.Configuration == TargetConfiguration.Release)
options.OutputFolder = @"C:\dev\GoakeFlax\Output\WindowsRelease";
}
return base.GetOutputFilePath(options, outputType);
}