gg.easy.airship 0.1.2126 → 0.1.2128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/Artifacts/AirshipLocalArtifactDatabase.cs +5 -0
- package/Editor/Artifacts/AirshipReconciliationService.cs +10 -2
- package/Editor/TypescriptServices/Compiler/TypescriptCompilationService.cs +3 -0
- package/Runtime/Code/AirshipConst.cs +2 -2
- package/Runtime/Code/Auth/Socket/SocketManager.cs +10 -0
- package/Runtime/Code/Bundles/CrossSceneState.cs +1 -0
- package/Runtime/Code/Http/HttpResponse.cs +1 -1
- package/Runtime/Code/Luau/ReflectionList.cs +1 -0
- package/Runtime/Code/LuauAPI/Bridge.cs +27 -0
- package/Runtime/Code/MainMenu/DisconnectedScreen.cs +22 -0
- package/Runtime/Code/Misc/InternalCameraScreenshotRecorder.cs +130 -128
- package/Runtime/Code/Network/Simulation/AirshipNetworkedObject.cs +81 -0
- package/Runtime/Code/Network/Simulation/AirshipNetworkedObject.cs.meta +3 -0
- package/Runtime/Code/Network/Simulation/AirshipOfflineRigidbody.cs +55 -0
- package/Runtime/Code/Network/Simulation/AirshipOfflineRigidbody.cs.meta +3 -0
- package/Runtime/Code/Network/Simulation/AirshipSimulationManager.cs +349 -0
- package/Runtime/Code/Network/Simulation/AirshipSimulationManager.cs.meta +3 -0
- package/Runtime/Code/Network/Simulation/History.cs +255 -0
- package/Runtime/Code/Network/Simulation/History.cs.meta +3 -0
- package/Runtime/Code/Network/Simulation.meta +3 -0
- package/Runtime/Code/Network/StateSystem/AirshipNetworkedStateManager.cs +1091 -0
- package/Runtime/Code/Network/StateSystem/AirshipNetworkedStateManager.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovement.cs +106 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovement.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementInput.cs +26 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementInput.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementState.cs +43 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementState.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestNetworkedStateManager.cs +43 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestNetworkedStateManager.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations.meta +3 -0
- package/Runtime/Code/Network/StateSystem/NetworkedStateSystem.cs +87 -0
- package/Runtime/Code/Network/StateSystem/NetworkedStateSystem.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Structures/InputCommand.cs +24 -0
- package/Runtime/Code/Network/StateSystem/Structures/InputCommand.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Structures/StateSnapshot.cs +35 -0
- package/Runtime/Code/Network/StateSystem/Structures/StateSnapshot.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Structures.meta +3 -0
- package/Runtime/Code/Network/StateSystem.meta +3 -0
- package/Runtime/Code/Network/SyncedBlob.cs +26 -0
- package/Runtime/Code/Network/SyncedBlob.cs.meta +3 -0
- package/Runtime/Code/Platform/Shared/AirshipPlatformUrl.cs +4 -0
- package/Runtime/Code/Player/Character/Animation/CharacterAnimationHelper.cs +317 -246
- package/Runtime/Code/Player/Character/Animation/CharacterAnimationHelper.cs.meta +2 -2
- package/Runtime/Code/Player/Character/Animation/ClipReplacer/AnimatorClipReplacer.cs +0 -1
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterAnimationSyncData.cs +41 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterAnimationSyncData.cs.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovement.cs +1447 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovement.cs.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovementSettings.cs +175 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovementSettings.cs.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterNetworkedStateManager.cs +43 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterNetworkedStateManager.cs.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterPhysics.cs +441 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterPhysics.cs.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterInputData.cs +47 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterInputData.cs.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterSnapshotData.cs +189 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterSnapshotData.cs.meta +2 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character.meta +3 -0
- package/Runtime/Code/Player/Character/MovementSystems.meta +3 -0
- package/Runtime/Code/Player/Entity/Animation/Editor/EntityDebugAnimator.cs +1 -0
- package/Runtime/Code/Player/PlayerInfo.cs +1 -2
- package/Runtime/Code/Player/PlayerManagerBridge.cs +1 -1
- package/Runtime/Code/PreventCodeStripping.cs +1 -1
- package/Runtime/Code/TSCodeGen/Editor/CsToTs/TypeScript/Helper.cs +22 -12
- package/Runtime/Code/TSCodeGen/TypeGenerator.cs +7 -6
- package/Runtime/Code/VoiceChat/AirshipUniVoiceNetwork.cs +69 -15
- package/Runtime/Code/VoxelWorld/VoxelWorld.cs +20 -0
- package/Runtime/Code/VoxelWorld/VoxelWorldChunk.cs +11 -0
- package/Runtime/Code/VoxelWorld/VoxelWorldCollision.cs +60 -2
- package/Runtime/Prefabs/Network.prefab +5 -5
- package/Runtime/Scenes/CoreScene.unity +350 -375
- package/Runtime/Scenes/Disconnected.unity +810 -98
- package/ThirdParty/Mirror/Core/NetworkConnectionToClient.cs +1 -1
- package/ThirdParty/UniVoice/Runtime/ChatroomAgent.cs +3 -2
- package/ThirdParty/UniVoice/Runtime/Interfaces/IChatroomNetwork.cs +2 -2
- package/URP/AirshipURPAsset.asset +1 -1
- package/package.json +1 -1
- package/Runtime/Code/Player/Character/API/CharacterAction.cs +0 -5
- package/Runtime/Code/Player/Character/API/CharacterAction.cs.meta +0 -3
- package/Runtime/Code/Player/Character/API/CharacterMovementData.cs +0 -188
- package/Runtime/Code/Player/Character/API/CharacterMovementData.cs.meta +0 -3
- package/Runtime/Code/Player/Character/API/CharacterPhysics.cs +0 -322
- package/Runtime/Code/Player/Character/API/CharacterPhysics.cs.meta +0 -3
- package/Runtime/Code/Player/Character/API.meta +0 -3
- package/Runtime/Code/Player/Character/MovementSystem/CharacterAnimationSyncData.cs +0 -36
- package/Runtime/Code/Player/Character/MovementSystem/CharacterAnimationSyncData.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/CharacterMovement.cs +0 -1437
- package/Runtime/Code/Player/Character/MovementSystem/CharacterMovement.cs.meta +0 -14
- package/Runtime/Code/Player/Character/MovementSystem/CharacterMovementTests.cs +0 -68
- package/Runtime/Code/Player/Character/MovementSystem/CharacterMovementTests.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictedController.cs +0 -825
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictedController.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictedState.cs +0 -23
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictedState.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictionManager.cs +0 -431
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictionManager.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictionRPC.cs +0 -39
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictionRPC.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictionRigidbodyController.cs +0 -91
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/AirshipPredictionRigidbodyController.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement/AirshipPredictedCharacterMovement.cs +0 -313
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement/AirshipPredictedCharacterMovement.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement/AirshipPredictionCharacterMovementRPC.cs +0 -19
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement/AirshipPredictionCharacterMovementRPC.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement/CharacterMovementState.cs +0 -87
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement/CharacterMovementState.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/CharacterMovement.meta +0 -8
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/Rigidbody/AirshipPredictedRigidbody.cs +0 -188
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/Rigidbody/AirshipPredictedRigidbody.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/Rigidbody/AirshipPredictedRigidbodyState.cs +0 -32
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/Rigidbody/AirshipPredictedRigidbodyState.cs.meta +0 -2
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction/Rigidbody.meta +0 -8
- package/Runtime/Code/Player/Character/MovementSystem/ClientPrediction.meta +0 -8
- package/Runtime/Code/Player/Character/MovementSystem.meta +0 -8
- package/Runtime/Code/Player/Character/Net/MoveInputData.cs +0 -42
- package/Runtime/Code/Player/Character/Net/MoveInputData.cs.meta +0 -3
- package/Runtime/Code/Player/Character/Net.meta +0 -3
- /package/Runtime/Code/Player/Character/{CharacterRig.cs → Animation/CharacterRig.cs} +0 -0
- /package/Runtime/Code/Player/Character/{CharacterRig.cs.meta → Animation/CharacterRig.cs.meta} +0 -0
|
@@ -112,6 +112,11 @@ namespace Airship.Editor {
|
|
|
112
112
|
[SerializeField] internal List<ComponentScriptAssetData> scripts = new();
|
|
113
113
|
[SerializeField] internal List<ComponentData> components = new();
|
|
114
114
|
|
|
115
|
+
/// <summary>
|
|
116
|
+
/// Returns if the Database is empty - if it is, it's likely the project is new or freshly pulled
|
|
117
|
+
/// </summary>
|
|
118
|
+
internal static bool isEmpty => instance.scripts.Count == 0 && instance.components.Count == 0;
|
|
119
|
+
|
|
115
120
|
/// <summary>
|
|
116
121
|
/// Gets or creates the script asset data in the artifact database for the given script
|
|
117
122
|
/// </summary>
|
|
@@ -322,11 +322,19 @@ namespace Airship.Editor {
|
|
|
322
322
|
private static void OnComponentReconcile(AirshipReconcileEventData eventData) {
|
|
323
323
|
// Components must have guids
|
|
324
324
|
if (string.IsNullOrEmpty(eventData.Component.guid)) eventData.Component.guid = Guid.NewGuid().ToString();
|
|
325
|
+
|
|
326
|
+
// If an initial setup (e.g. first pull, or new template project)
|
|
327
|
+
if (AirshipLocalArtifactDatabase.isEmpty) {
|
|
328
|
+
// We can run a default reconcile, it wont matter tbh.
|
|
329
|
+
var component = eventData.Component;
|
|
330
|
+
ReconcileComponent(component);
|
|
331
|
+
component.componentHash = component.scriptHash;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
325
334
|
|
|
326
335
|
if (ReconcilerVersion == ReconcilerVersion.Version2) {
|
|
327
336
|
var component = eventData.Component;
|
|
328
|
-
|
|
329
|
-
|
|
337
|
+
|
|
330
338
|
var isPrefab = PrefabUtility.IsPartOfAnyPrefab(component);
|
|
331
339
|
var prefabOriginalComponent = PrefabUtility.GetCorrespondingObjectFromOriginalSource(component);
|
|
332
340
|
if (isPrefab && prefabOriginalComponent.script != null) {
|
|
@@ -21,6 +21,7 @@ using Newtonsoft.Json.Linq;
|
|
|
21
21
|
using ParrelSync;
|
|
22
22
|
using UnityEditor;
|
|
23
23
|
using UnityEngine;
|
|
24
|
+
using UnityEngine.Android;
|
|
24
25
|
using UnityEngine.PlayerLoop;
|
|
25
26
|
using UnityEngine.Serialization;
|
|
26
27
|
using Debug = UnityEngine.Debug;
|
|
@@ -55,6 +56,7 @@ using Object = UnityEngine.Object;
|
|
|
55
56
|
/// </summary>
|
|
56
57
|
// [InitializeOnLoad]
|
|
57
58
|
public static class TypescriptCompilationService {
|
|
59
|
+
private const int ExitCodeKill = 137;
|
|
58
60
|
private const string TsCompilerService = "Typescript Compilation Service";
|
|
59
61
|
|
|
60
62
|
/// <summary>
|
|
@@ -768,6 +770,7 @@ using Object = UnityEngine.Object;
|
|
|
768
770
|
|
|
769
771
|
proc.Exited += (_, _) => {
|
|
770
772
|
if (proc.ExitCode <= 0) return;
|
|
773
|
+
if (proc.ExitCode == ExitCodeKill) return;
|
|
771
774
|
|
|
772
775
|
Debug.Log("Compiler process exited with code " + proc.ExitCode);
|
|
773
776
|
var progressId = TypescriptProjectsService.Project!.ProgressId;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// ReSharper disable InconsistentNaming
|
|
2
2
|
namespace Code {
|
|
3
3
|
public static class AirshipConst {
|
|
4
|
-
public const int playerVersion =
|
|
4
|
+
public const int playerVersion = 5;
|
|
5
5
|
|
|
6
6
|
/// <summary>
|
|
7
7
|
/// The server will kick clients that have a playerVersion lower than this value.
|
|
8
8
|
/// </summary>
|
|
9
|
-
public const int minAcceptedPlayerVersionOnServer =
|
|
9
|
+
public const int minAcceptedPlayerVersionOnServer = 5;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -106,6 +106,16 @@ public class SocketManager : Singleton<SocketManager> {
|
|
|
106
106
|
await Awaitable.MainThreadAsync();
|
|
107
107
|
Instance.OnDisconnected?.Invoke(s);
|
|
108
108
|
};
|
|
109
|
+
|
|
110
|
+
Instance.socket.OnError += async (sender, s) => {
|
|
111
|
+
if (s.StartsWith("User does not have \"GC Edge\" access")) {
|
|
112
|
+
Debug.Log("User does not have \"GC Edge\" access");
|
|
113
|
+
await Awaitable.MainThreadAsync();
|
|
114
|
+
CrossSceneState.kickForceLogout = true;
|
|
115
|
+
TransferManager.Instance.Disconnect(true, "User does not have permission to access Airship");
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
if (!Instance.socket.Connected) {
|
|
@@ -19,6 +19,7 @@ public static class CrossSceneState
|
|
|
19
19
|
public static ServerTransferData ServerTransferData;
|
|
20
20
|
public static bool UseLocalBundles = false;
|
|
21
21
|
public static string kickMessage = "";
|
|
22
|
+
public static bool kickForceLogout = false;
|
|
22
23
|
public static bool disconnectKicked = false;
|
|
23
24
|
|
|
24
25
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
|
@@ -389,6 +389,33 @@ public static class Bridge {
|
|
|
389
389
|
public static void UnloadGlobalSceneByName(string sceneName) {
|
|
390
390
|
// InstanceFinder.SceneManager.UnloadGlobalScenes(new SceneUnloadData(sceneName));
|
|
391
391
|
}
|
|
392
|
+
|
|
393
|
+
[LuauAPI(LuauContext.Protected)]
|
|
394
|
+
public static bool IsLowEndDevice() {
|
|
395
|
+
// CPU check
|
|
396
|
+
string cpu = SystemInfo.processorType.ToLower();
|
|
397
|
+
if (cpu.Contains("celeron") || cpu.Contains("pentium") || cpu.Contains("atom")) {
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// GPU check
|
|
402
|
+
string gpu = SystemInfo.graphicsDeviceName.ToLower();
|
|
403
|
+
if (gpu.Contains("intel") || gpu.Contains("uhd") || gpu.Contains("hd graphics")) {
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// RAM check
|
|
408
|
+
if (SystemInfo.systemMemorySize < 8000) { // Less than 8GB RAM
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// GPU memory check
|
|
413
|
+
if (SystemInfo.graphicsMemorySize < 2000) { // Less than 2GB VRAM
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
392
419
|
|
|
393
420
|
public static void MoveGameObjectToScene(GameObject gameObject, Scene scene) {
|
|
394
421
|
if (LuauCore.IsProtectedScene(scene) && LuauCore.CurrentContext == LuauContext.Game) {
|
|
@@ -5,13 +5,35 @@ using UnityEngine.SceneManagement;
|
|
|
5
5
|
|
|
6
6
|
public class DisconnectedScreen : MonoBehaviour {
|
|
7
7
|
public TMP_Text reasonText;
|
|
8
|
+
public GameObject continueButton;
|
|
9
|
+
public GameObject logoutButton;
|
|
10
|
+
public GameObject quitButton;
|
|
8
11
|
|
|
9
12
|
private void Start() {
|
|
10
13
|
this.reasonText.text = CrossSceneState.kickMessage;
|
|
11
14
|
Cursor.lockState = CursorLockMode.None;
|
|
15
|
+
if (CrossSceneState.kickForceLogout) {
|
|
16
|
+
CrossSceneState.kickForceLogout = false;
|
|
17
|
+
this.continueButton.SetActive(false);
|
|
18
|
+
this.logoutButton.SetActive(true);
|
|
19
|
+
this.quitButton.SetActive(true);
|
|
20
|
+
} else {
|
|
21
|
+
this.continueButton.SetActive(true);
|
|
22
|
+
this.logoutButton.SetActive(false);
|
|
23
|
+
this.quitButton.SetActive(false);
|
|
24
|
+
}
|
|
12
25
|
}
|
|
13
26
|
|
|
14
27
|
public void ContinueButton_OnClick() {
|
|
15
28
|
SceneManager.LoadScene("MainMenu");
|
|
16
29
|
}
|
|
30
|
+
|
|
31
|
+
public void QuitButton_OnClick() {
|
|
32
|
+
Application.Quit();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void LogoutButton_OnClick() {
|
|
36
|
+
AuthManager.ClearSavedAccount();
|
|
37
|
+
SceneManager.LoadScene("Login");
|
|
38
|
+
}
|
|
17
39
|
}
|
|
@@ -11,153 +11,155 @@ public class CameraScreenshotResponse{
|
|
|
11
11
|
public string extension = "";
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
public
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
public SaveFolder saveFolder = SaveFolder.PicturesFolder;
|
|
23
|
-
public bool shouldSaveCaptures = true;
|
|
24
|
-
public int resWidth = 1920;
|
|
25
|
-
public int resHeight = 1080;
|
|
26
|
-
|
|
27
|
-
private const int resDepth = 24;
|
|
28
|
-
private static Texture2D screenShot;
|
|
29
|
-
private static RenderTexture rt;
|
|
30
|
-
|
|
31
|
-
public delegate void OnPictureTaken(Texture2D screenshot);
|
|
32
|
-
public static OnPictureTaken onPictureTaken;
|
|
33
|
-
|
|
34
|
-
public static Texture2D GetScreenshotTexture {
|
|
35
|
-
get {
|
|
36
|
-
return screenShot;
|
|
14
|
+
namespace Assets.Code.Misc {
|
|
15
|
+
[LuauAPI(LuauContext.Protected)]
|
|
16
|
+
public class InternalCameraScreenshotRecorder : Singleton<InternalCameraScreenshotRecorder> {
|
|
17
|
+
public enum SaveFolder {
|
|
18
|
+
ApplicationData,
|
|
19
|
+
PicturesFolder,
|
|
20
|
+
Documents,
|
|
37
21
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return string.Format("{0}/Airship/", folderPath);
|
|
22
|
+
|
|
23
|
+
public SaveFolder saveFolder = SaveFolder.PicturesFolder;
|
|
24
|
+
public bool shouldSaveCaptures = true;
|
|
25
|
+
public int resWidth = 1920;
|
|
26
|
+
public int resHeight = 1080;
|
|
27
|
+
|
|
28
|
+
private const int resDepth = 24;
|
|
29
|
+
private static Texture2D screenShot;
|
|
30
|
+
private static RenderTexture rt;
|
|
31
|
+
|
|
32
|
+
public delegate void OnPictureTaken(Texture2D screenshot);
|
|
33
|
+
public static OnPictureTaken onPictureTaken;
|
|
34
|
+
|
|
35
|
+
public static Texture2D GetScreenshotTexture {
|
|
36
|
+
get {
|
|
37
|
+
return screenShot;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public string ScreenShotName(int width, int height, bool png) {
|
|
42
|
+
return FolderName + string.Format("screen_{0}x{1}_{2}.{3}",
|
|
43
|
+
width, height,
|
|
44
|
+
System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"), png?"png":"jpg");
|
|
62
45
|
}
|
|
63
|
-
}
|
|
64
46
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
public string ScreenShotName(string filename, bool png) {
|
|
48
|
+
return FolderName + filename + (png?".png":".jpg");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public string FolderName{
|
|
52
|
+
get {
|
|
53
|
+
string folderPath = Application.persistentDataPath;
|
|
54
|
+
switch (saveFolder) {
|
|
55
|
+
case SaveFolder.PicturesFolder:
|
|
56
|
+
folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
|
|
57
|
+
break;
|
|
58
|
+
case SaveFolder.Documents:
|
|
59
|
+
folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
|
60
|
+
break;
|
|
61
|
+
};
|
|
62
|
+
return string.Format("{0}/Airship/", folderPath);
|
|
63
|
+
}
|
|
68
64
|
}
|
|
69
|
-
}
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
private void InitFolder() {
|
|
67
|
+
if (!Directory.Exists (FolderName)) {
|
|
68
|
+
Directory.CreateDirectory(FolderName);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
SaveScreenshot(fileName, superSampleSize, png);
|
|
81
|
-
}
|
|
72
|
+
public static void TakeScreenshot(string fileName = "", int superSampleSize = 1, bool png = true) {
|
|
73
|
+
Instance.InitFolder();
|
|
74
|
+
Instance.StartCoroutine(Instance.TakeScreenshotCo(fileName, superSampleSize, png));
|
|
75
|
+
}
|
|
82
76
|
|
|
77
|
+
private IEnumerator TakeScreenshotCo(string fileName = "", int superSampleSize = 1, bool png = true) {
|
|
78
|
+
//Have to capture at end of frame for ScreenCapture to work
|
|
79
|
+
yield return new WaitForEndOfFrame();
|
|
80
|
+
screenShot = ScreenCapture.CaptureScreenshotAsTexture(superSampleSize);
|
|
81
|
+
SaveScreenshot(fileName, superSampleSize, png);
|
|
82
|
+
}
|
|
83
83
|
|
|
84
|
-
public static void TakeCameraScreenshot(Camera camera, string fileName = "", int superSampleSize = 1) {
|
|
85
|
-
Instance.InitFolder();
|
|
86
|
-
Instance.StartCoroutine(Instance.TakeCameraScreenshotCo(camera, fileName, superSampleSize));
|
|
87
|
-
}
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// Have to capture at end of frame for ScreenCapture to work
|
|
93
|
-
yield return new WaitForEndOfFrame();
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
screenShot = new Texture2D(resWidth * superSampleSize, resHeight * superSampleSize, TextureFormat.RGB24, false);
|
|
97
|
-
rt = new RenderTexture(resWidth, resHeight, resDepth);
|
|
98
|
-
camera.enabled = true;
|
|
99
|
-
camera.targetTexture = rt;
|
|
100
|
-
camera.Render();
|
|
101
|
-
RenderTexture.active = rt;
|
|
102
|
-
} catch(Exception e) {
|
|
103
|
-
Debug.LogError("Error saving: " + e.Message);
|
|
85
|
+
public static void TakeCameraScreenshot(Camera camera, string fileName = "", int superSampleSize = 1) {
|
|
86
|
+
Instance.InitFolder();
|
|
87
|
+
Instance.StartCoroutine(Instance.TakeCameraScreenshotCo(camera, fileName, superSampleSize));
|
|
104
88
|
}
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
rt = null;
|
|
112
|
-
|
|
113
|
-
if (shouldSaveCaptures) {
|
|
114
|
-
SaveScreenshot(fileName, superSampleSize, true);
|
|
115
|
-
}
|
|
90
|
+
public IEnumerator TakeCameraScreenshotCo(Camera camera, string fileName = "", int superSampleSize = 1) {
|
|
91
|
+
bool enabled = camera.enabled;
|
|
92
|
+
|
|
93
|
+
// Have to capture at end of frame for ScreenCapture to work
|
|
94
|
+
yield return new WaitForEndOfFrame();
|
|
116
95
|
|
|
117
|
-
|
|
118
|
-
|
|
96
|
+
try {
|
|
97
|
+
screenShot = new Texture2D(resWidth * superSampleSize, resHeight * superSampleSize, TextureFormat.RGB24, false);
|
|
98
|
+
rt = new RenderTexture(resWidth, resHeight, resDepth);
|
|
99
|
+
camera.enabled = true;
|
|
100
|
+
camera.targetTexture = rt;
|
|
101
|
+
camera.Render();
|
|
102
|
+
RenderTexture.active = rt;
|
|
103
|
+
} catch(Exception e) {
|
|
104
|
+
Debug.LogError("Error saving: " + e.Message);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Save the render textures data to a texture2D
|
|
108
|
+
screenShot.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
|
|
109
|
+
camera.targetTexture = null;
|
|
110
|
+
RenderTexture.active = null;
|
|
111
|
+
rt.Release();
|
|
112
|
+
rt = null;
|
|
113
|
+
|
|
114
|
+
if (shouldSaveCaptures) {
|
|
115
|
+
SaveScreenshot(fileName, superSampleSize, true);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if(onPictureTaken != null){
|
|
119
|
+
onPictureTaken(screenShot);
|
|
120
|
+
}
|
|
121
|
+
camera.enabled = enabled;
|
|
119
122
|
}
|
|
120
|
-
camera.enabled = enabled;
|
|
121
|
-
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
private void SaveScreenshot(string fileName, int superSampleSize, bool png) {
|
|
125
|
+
if (!screenShot || screenShot.width <= 0) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
SaveTexture(screenShot, fileName, png);
|
|
129
|
+
screenShot.Apply();
|
|
126
130
|
}
|
|
127
|
-
SaveTexture(screenShot, fileName, png);
|
|
128
|
-
screenShot.Apply();
|
|
129
|
-
}
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
public CameraScreenshotResponse SaveRenderTexture(RenderTexture rt, string fileName, bool png){
|
|
133
|
+
if(!rt){
|
|
134
|
+
return new CameraScreenshotResponse();
|
|
135
|
+
}
|
|
136
|
+
RenderTexture.active = rt;
|
|
137
|
+
var texture = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);
|
|
138
|
+
texture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
|
|
139
|
+
RenderTexture.active = null;
|
|
140
|
+
return SaveTexture(texture, fileName, png);
|
|
134
141
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
|
|
143
|
+
public CameraScreenshotResponse SaveTexture(Texture2D texture, string fileName, bool png){
|
|
144
|
+
try {
|
|
145
|
+
//Debug.Log("Saving Texture size: " + texture.width +", " + texture.height);
|
|
146
|
+
string filePath = string.IsNullOrEmpty(fileName)
|
|
147
|
+
? ScreenShotName(texture.width, texture.height, png)
|
|
148
|
+
: ScreenShotName(fileName, png);
|
|
149
|
+
byte[] bytes = png ? texture.EncodeToPNG() : texture.EncodeToJPG();
|
|
150
|
+
string directoryPath = Path.GetDirectoryName(filePath);
|
|
151
|
+
if(!Directory.Exists(directoryPath)){
|
|
152
|
+
Directory.CreateDirectory(directoryPath);
|
|
153
|
+
}
|
|
154
|
+
File.WriteAllBytes(filePath, bytes);
|
|
155
|
+
Debug.Log(string.Format("Saved screenshot to: {0}", filePath));
|
|
156
|
+
return new CameraScreenshotResponse(){filesize = bytes.Length, extension = Path.GetExtension(filePath), path = filePath};
|
|
157
|
+
} catch (Exception e) {
|
|
158
|
+
Debug.LogError("Error saving texture: " + e.Message);
|
|
152
159
|
}
|
|
153
|
-
|
|
154
|
-
Debug.Log(string.Format("Saved screenshot to: {0}", filePath));
|
|
155
|
-
return new CameraScreenshotResponse(){filesize = bytes.Length, extension = Path.GetExtension(filePath), path = filePath};
|
|
156
|
-
} catch (Exception e) {
|
|
157
|
-
Debug.LogError("Error saving texture: " + e.Message);
|
|
160
|
+
return new CameraScreenshotResponse();
|
|
158
161
|
}
|
|
159
|
-
|
|
160
|
-
}
|
|
162
|
+
}
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using Mirror;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Code.Network.Simulation
|
|
6
|
+
{
|
|
7
|
+
struct TransformSnapshot
|
|
8
|
+
{
|
|
9
|
+
public Vector3 position;
|
|
10
|
+
public Quaternion rotation;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This component is used to allow lag compensation, prediction, and other networked state systems to
|
|
15
|
+
* work with a networked object controlled by the server.
|
|
16
|
+
*
|
|
17
|
+
* When this component is placed on a object being networked with Mirror, the server can include it
|
|
18
|
+
* in lag compensation and clients can resimulate their predictions more accurately.
|
|
19
|
+
*/
|
|
20
|
+
public class AirshipNetworkedObject : NetworkBehaviour
|
|
21
|
+
{
|
|
22
|
+
private History<TransformSnapshot> history;
|
|
23
|
+
|
|
24
|
+
private void Start()
|
|
25
|
+
{
|
|
26
|
+
if (isServer && authority)
|
|
27
|
+
{
|
|
28
|
+
history = new History<TransformSnapshot>(NetworkServer.sendRate);
|
|
29
|
+
AirshipSimulationManager.Instance.OnCaptureSnapshot += this.CaptureSnapshot;
|
|
30
|
+
AirshipSimulationManager.Instance.OnSetSnapshot += this.SetSnapshot;
|
|
31
|
+
AirshipSimulationManager.Instance.OnLagCompensationCheck += this.LagCompensationCheck;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (isClient && !authority)
|
|
35
|
+
{
|
|
36
|
+
history = new History<TransformSnapshot>(NetworkClient.sendRate);
|
|
37
|
+
AirshipSimulationManager.Instance.OnCaptureSnapshot += this.CaptureSnapshot;
|
|
38
|
+
AirshipSimulationManager.Instance.OnSetSnapshot += this.SetSnapshot;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private void OnDestroy()
|
|
43
|
+
{
|
|
44
|
+
AirshipSimulationManager.Instance.OnCaptureSnapshot -= this.CaptureSnapshot;
|
|
45
|
+
AirshipSimulationManager.Instance.OnSetSnapshot -= this.SetSnapshot;
|
|
46
|
+
AirshipSimulationManager.Instance.OnLagCompensationCheck -= this.LagCompensationCheck;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private void CaptureSnapshot(double time, bool replay)
|
|
50
|
+
{
|
|
51
|
+
if (replay)
|
|
52
|
+
{
|
|
53
|
+
var state = this.history.Get(time);
|
|
54
|
+
this.transform.position = state.position;
|
|
55
|
+
this.transform.rotation = state.rotation;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.history.Add(time, new TransformSnapshot()
|
|
60
|
+
{
|
|
61
|
+
position = this.transform.position,
|
|
62
|
+
rotation = this.transform.rotation
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private void SetSnapshot(object objTime)
|
|
67
|
+
{
|
|
68
|
+
if (objTime is double time) {
|
|
69
|
+
var snapshot = this.history.Get(time);
|
|
70
|
+
this.transform.position = snapshot.position;
|
|
71
|
+
this.transform.rotation = snapshot.rotation;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private void LagCompensationCheck(int clientId, double time, double latency)
|
|
76
|
+
{
|
|
77
|
+
var bufferedTime = time - latency - NetworkClient.bufferTime;
|
|
78
|
+
this.SetSnapshot(bufferedTime);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace Code.Network.Simulation
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* Disables a rigidbodies physics (sets it to kinematic) when resimulation or lag compensation is taking place.
|
|
8
|
+
*/
|
|
9
|
+
public class AirshipOfflineRigidbody : MonoBehaviour
|
|
10
|
+
{
|
|
11
|
+
public Rigidbody rigidbody;
|
|
12
|
+
private bool kinematicSetting = false;
|
|
13
|
+
|
|
14
|
+
private Vector3 position;
|
|
15
|
+
private Quaternion rotation;
|
|
16
|
+
private Vector3 linearVelocity;
|
|
17
|
+
private Vector3 angularVelocity;
|
|
18
|
+
|
|
19
|
+
public void Start()
|
|
20
|
+
{
|
|
21
|
+
this.rigidbody = this.GetComponent<Rigidbody>();
|
|
22
|
+
AirshipSimulationManager.Instance.OnSetPaused += OnPause;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private void OnDestroy()
|
|
26
|
+
{
|
|
27
|
+
AirshipSimulationManager.Instance.OnSetPaused -= OnPause;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private void OnPause(bool paused)
|
|
31
|
+
{
|
|
32
|
+
if (this.rigidbody == null) return;
|
|
33
|
+
if (paused)
|
|
34
|
+
{
|
|
35
|
+
this.kinematicSetting = this.rigidbody.isKinematic;
|
|
36
|
+
this.rigidbody.isKinematic = true;
|
|
37
|
+
this.position = this.rigidbody.position;
|
|
38
|
+
this.rotation = this.rigidbody.rotation;
|
|
39
|
+
this.linearVelocity = this.rigidbody.linearVelocity;
|
|
40
|
+
this.angularVelocity = this.rigidbody.angularVelocity;
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
{
|
|
44
|
+
this.rigidbody.isKinematic = this.kinematicSetting;
|
|
45
|
+
this.rigidbody.position = this.position;
|
|
46
|
+
this.rigidbody.rotation = this.rotation;
|
|
47
|
+
if (!this.kinematicSetting)
|
|
48
|
+
{
|
|
49
|
+
this.rigidbody.linearVelocity = this.linearVelocity;
|
|
50
|
+
this.rigidbody.angularVelocity = this.angularVelocity;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|