fishnet installed

This commit is contained in:
2023-05-31 11:32:21 -04:00
parent 47b25269f1
commit a001fe1b04
1291 changed files with 126631 additions and 1 deletions

View File

@ -0,0 +1,39 @@
using UnityEngine.SceneManagement;
namespace FishNet.Managing.Scened
{
/// <summary>
/// Settings to apply when loading a scene.
/// </summary>
public class LoadOptions
{
/// <summary>
/// True if to automatically unload the loaded scenes when they are no longer being used by clients. This field only applies to scenes loaded for connections, not globally loaded scenes.
/// </summary>
[System.NonSerialized]
public bool AutomaticallyUnload = true;
/// <summary>
/// False if to only load scenes which are not yet loaded. When true a scene may load multiple times; this is known as scene stacking. Only the server is able to stack scenes; clients will load a single instance. Global scenes cannot be stacked.
/// </summary>
[System.NonSerialized]
public bool AllowStacking;
/// <summary>
/// LocalPhysics mode to use when loading this scene. Generally this will only be used when applying scene stacking. Only used by the server.
/// https://docs.unity3d.com/ScriptReference/SceneManagement.LocalPhysicsMode.html
/// </summary>
[System.NonSerialized]
public LocalPhysicsMode LocalPhysics = LocalPhysicsMode.None;
/// <summary>
/// True to reload a scene if it's already loaded.
/// This does not function yet.
/// </summary>
[System.Obsolete("This feature is not functional yet but will be at a later release.")]
public bool ReloadScenes;
/// <summary>
/// True if scenes should be loaded using addressables. This field only exists for optional use so the user may know if their queue data is using addressables.
/// </summary>
public bool Addressables;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1614453d3786b2a4eb18b69297da7dc9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
namespace FishNet.Managing.Scened
{
/// <summary>
/// Additional user-crafted data which can be included in scene load callbacks.
/// </summary>
public class LoadParams
{
/// <summary>
/// Objects which are included in callbacks on the server when loading a scene. Can be useful for including unique information about the scene, such as match id. These are not sent to clients; use ClientParams for this.
/// </summary>
[System.NonSerialized]
public object[] ServerParams = new object[0];
/// <summary>
/// Bytes which are sent to clients during scene loads. Can contain any information.
/// </summary>
public byte[] ClientParams = new byte[0];
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8b395f67f61b4e45830a70289a1901d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,51 @@
using FishNet.Connection;
using FishNet.Utility.Constant;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo(UtilityConstants.GENERATED_ASSEMBLY_NAME)]
namespace FishNet.Managing.Scened
{
/// <summary>
/// Data generated when loading a scene.
/// </summary>
public class LoadQueueData
{
/// <summary>
/// Clients which receive this SceneQueueData. If Networked, all clients do. If Connections, only the specified Connections do.
/// </summary>
[System.NonSerialized]
public SceneScopeType ScopeType;
/// <summary>
/// Connections to load scenes for. Only valid on the server and when ScopeType is Connections.
/// </summary>
[System.NonSerialized]
public NetworkConnection[] Connections = new NetworkConnection[0];
/// <summary>
/// SceneLoadData to use.
/// </summary>
public SceneLoadData SceneLoadData = null;
/// <summary>
/// Current global scenes.
/// </summary>
public string[] GlobalScenes = new string[0];
/// <summary>
/// True if to iterate this queue data as server.
/// </summary>
[System.NonSerialized]
public readonly bool AsServer;
public LoadQueueData() { }
internal LoadQueueData(SceneScopeType scopeType, NetworkConnection[] conns, SceneLoadData sceneLoadData, string[] globalScenes, bool asServer)
{
ScopeType = scopeType;
Connections = conns;
SceneLoadData = sceneLoadData;
GlobalScenes = globalScenes;
AsServer = asServer;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8fb4183af628f754b800dfdbb1ba9bf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@

namespace FishNet.Managing.Scened
{
/// <summary>
/// How to replace scenes when loading.
/// </summary>
public enum ReplaceOption : byte
{
/// <summary>
/// Replace all scenes, online and offline.
/// </summary>
All,
/// <summary>
/// Only replace scenes loaded using the SceneManager.
/// </summary>
OnlineOnly,
/// <summary>
/// Do not replace any scenes, additional scenes will be loaded as additive.
/// </summary>
None
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cb8e2c0fe3b9d3344a05810936861555
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,201 @@
using FishNet.Object;
using FishNet.Serializing.Helping;
using System.Collections.Generic;
using System.IO;
using UnityEngine.SceneManagement;
namespace FishNet.Managing.Scened
{
/// <summary>
/// Data about which scenes to load.
/// </summary>
public class SceneLoadData
{
/// <summary>
/// When specified this scene will be set as the active scene after loading occurs.
/// </summary>
public SceneLookupData PreferredActiveScene = null;
/// <summary>
/// SceneLookupData for each scene to load.
/// </summary>
public SceneLookupData[] SceneLookupDatas = new SceneLookupData[0];
/// <summary>
/// NetworkObjects to move to the new scenes. Objects will be moved to the first scene.
/// </summary>
public NetworkObject[] MovedNetworkObjects = new NetworkObject[0];
/// <summary>
/// How to replace current scenes with new ones. When replacing scenes the first scene loaded will be set as the active scene, and the rest additive.
/// </summary>
public ReplaceOption ReplaceScenes = ReplaceOption.None;
/// <summary>
/// Parameters which may be set and will be included in load callbacks.
/// </summary>
public LoadParams Params = new LoadParams();
/// <summary>
/// Additional options to use for loaded scenes.
/// </summary>
public LoadOptions Options = new LoadOptions();
public SceneLoadData() { }
/// <summary>
///
/// </summary>
/// <param name="scene">Scene to load.</param>
public SceneLoadData(Scene scene) : this(new Scene[] { scene }, null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneName">Scene to load by name.</param>
public SceneLoadData(string sceneName) : this(new string[] { sceneName }, null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneHandle">Scene to load by handle.</param>
public SceneLoadData(int sceneHandle) : this(new int[] { sceneHandle }, null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneHandle">Scene to load by handle.</param>
/// <param name="sceneName">Scene to load by name.</param>
public SceneLoadData(int sceneHandle, string sceneName) : this(new SceneLookupData(sceneHandle, sceneName)) { }
/// <summary>
///
/// </summary>
/// <param name="sceneLookupData">Scene to load by SceneLookupData.</param>
public SceneLoadData(SceneLookupData sceneLookupData) : this(new SceneLookupData[] { sceneLookupData }) { }
/// <summary>
///
/// </summary>
/// <param name="scenes">Scenes to load.</param>
public SceneLoadData(List<Scene> scenes) : this(scenes.ToArray(), null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneNames">Scenes to load by name.</param>
public SceneLoadData(List<string> sceneNames) : this(sceneNames.ToArray(), null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneHandles">Scenes to load by handle.</param>
public SceneLoadData(List<int> sceneHandles) : this(sceneHandles.ToArray(), null) { }
/// <summary>
///
/// </summary>
/// <param name="scenes">Scenes to load.</param>
public SceneLoadData(Scene[] scenes) : this(scenes, null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneNames">Scenes to load by name.</param>
public SceneLoadData(string[] sceneNames) : this(sceneNames, null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneHandles">Scenes to load by handle.</param>
public SceneLoadData(int[] sceneHandles) : this(sceneHandles, null) { }
/// <summary>
///
/// </summary>
/// <param name="sceneLookupDatas">Scenes to load by SceneLookupDatas.</param>
public SceneLoadData(SceneLookupData[] sceneLookupDatas) : this(sceneLookupDatas, null) { }
/// <summary>
///
/// </summary>
/// <param name="scene">Scene to load.</param>
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
public SceneLoadData(Scene scene, NetworkObject[] movedNetworkObjects)
{
SceneLookupData data = SceneLookupData.CreateData(scene);
Construct(new SceneLookupData[] { data }, movedNetworkObjects);
}
/// <summary>
///
/// </summary>
/// <param name="scenes">Scenes to load.</param>
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
public SceneLoadData(Scene[] scenes, NetworkObject[] movedNetworkObjects)
{
SceneLookupData[] datas = SceneLookupData.CreateData(scenes);
Construct(datas, movedNetworkObjects);
}
/// <summary>
///
/// </summary>
/// <param name="sceneNames">Scenes to load by Name.</param>
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
public SceneLoadData(string[] sceneNames, NetworkObject[] movedNetworkObjects)
{
SceneLookupData[] datas = SceneLookupData.CreateData(sceneNames);
Construct(datas, movedNetworkObjects);
}
/// <summary>
///
/// </summary>
/// <param name="sceneHandles">Scenes to load by handle.</param>
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
public SceneLoadData(int[] sceneHandles, NetworkObject[] movedNetworkObjects)
{
SceneLookupData[] datas = SceneLookupData.CreateData(sceneHandles);
Construct(datas, movedNetworkObjects);
}
/// <summary>
///
/// </summary>
/// <param name="sceneLookupDatas">Scenes to load by SceneLookupDatas.</param>
/// <param name="movedNetworkObjects">NetworkObjects to move to the first specified scene.</param>
public SceneLoadData(SceneLookupData[] sceneLookupDatas, NetworkObject[] movedNetworkObjects)
{
Construct(sceneLookupDatas, movedNetworkObjects);
}
/// <summary>
/// Called at the end of every constructor.
/// </summary>
private void Construct(SceneLookupData[] datas, NetworkObject[] movedNetworkObjects)
{
SceneLookupDatas = datas;
if (movedNetworkObjects == null)
movedNetworkObjects = new NetworkObject[0];
MovedNetworkObjects = movedNetworkObjects;
}
/// <summary>
/// Gets the first Scene in SceneLookupDatas.
/// </summary>
/// <returns></returns>
public Scene GetFirstLookupScene()
{
foreach (SceneLookupData sld in SceneLookupDatas)
{
Scene result = sld.GetScene(out _);
if (!string.IsNullOrEmpty(result.name))
return result;
}
return default;
}
/// <summary>
/// Returns if any data is invalid, such as null entries.
/// </summary>
/// <returns></returns>
internal bool DataInvalid()
{
//Null values.
if (Params == null || MovedNetworkObjects == null || SceneLookupDatas == null ||
Options == null)
return true;
//No lookups.
if (SceneLookupDatas.Length == 0)
return true;
return false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ecd4065158ab62047a074c594f245d90
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
namespace FishNet.Managing.Scened
{
/// <summary>
/// Type of scopes for a scene load or unload.
/// </summary>
public enum SceneScopeType : byte
{
/// <summary>
/// Scene action occured for all clients.
/// </summary>
Global = 0,
/// <summary>
/// Scene action occurred for specified clients.
/// </summary>
Connections = 1
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2be621eb04519a14eb2297a666b1bc2c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,116 @@
using System.Collections.Generic;
using UnityEngine.SceneManagement;
namespace FishNet.Managing.Scened
{
/// <summary>
/// Data about which scenes to unload.
/// </summary>
public class SceneUnloadData
{
/// <summary>
/// When specified this scene will be set as the active scene after unloading occurs.
/// </summary>
public SceneLookupData PreferredActiveScene = null;
/// <summary>
/// SceneLookupData for each scene to load.
/// </summary>
public SceneLookupData[] SceneLookupDatas = new SceneLookupData[0];
/// <summary>
/// Parameters which may be set and will be included in load callbacks.
/// </summary>
public UnloadParams Params = new UnloadParams();
/// <summary>
/// Additional options to use for loaded scenes.
/// </summary>
public UnloadOptions Options = new UnloadOptions();
/// <summary>
///
/// </summary>
public SceneUnloadData() { }
/// <summary>
///
/// </summary>
/// <param name="scene">Scene to unload.</param>
public SceneUnloadData(Scene scene) : this(new Scene[] { scene }) { }
/// <summary>
///
/// </summary>
/// <param name="sceneName">Scene to unload by name.</param>
public SceneUnloadData(string sceneName) : this(new string[] { sceneName }) { }
/// <summary>
///
/// </summary>
/// <param name="sceneHandle">Scene to unload by handle.</param>
public SceneUnloadData(int sceneHandle) : this(new int[] { sceneHandle }) { }
/// <summary>
///
/// </summary>
/// <param name="scenes">Scenes to unload.</param>
public SceneUnloadData(List<Scene> scenes) : this(scenes.ToArray()) { }
/// <summary>
///
/// </summary>
/// <param name="sceneNames">Scenes to unload by names.</param>
public SceneUnloadData(List<string> sceneNames) : this(sceneNames.ToArray()) { }
/// <summary>
///
/// </summary>
/// <param name="sceneHandles">Scenes to unload by handles.</param>
public SceneUnloadData(List<int> sceneHandles) : this(sceneHandles.ToArray()) { }
/// <summary>
///
/// </summary>
/// <param name="scenes">Scenes to unload.</param>
public SceneUnloadData(Scene[] scenes)
{
SceneLookupDatas = SceneLookupData.CreateData(scenes);
}
/// <summary>
///
/// </summary>
/// <param name="sceneNames">Scenes to unload by names.</param>
public SceneUnloadData(string[] sceneNames)
{
SceneLookupDatas = SceneLookupData.CreateData(sceneNames);
}
/// <summary>
///
/// </summary>
/// <param name="sceneHandles">Scenes to unload by handles.</param>
public SceneUnloadData(int[] sceneHandles)
{
SceneLookupDatas = SceneLookupData.CreateData(sceneHandles);
}
/// <summary>
///
/// </summary>
/// <param name="sceneLookupDatas">Scenes to unload by SceneLookupDatas.</param>
public SceneUnloadData(SceneLookupData[] sceneLookupDatas)
{
SceneLookupDatas = sceneLookupDatas;
}
/// <summary>
/// Returns if any data is invalid, such as null entries.
/// </summary>
/// <returns></returns>
internal bool DataInvalid()
{
//Null values.
if (Params == null || SceneLookupDatas == null ||
Options == null)
return true;
//No lookups.
if (SceneLookupDatas.Length == 0)
return true;
return false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77cbfeea232e4ab44a4315b003ce6742
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,36 @@

namespace FishNet.Managing.Scened
{
/// <summary>
/// Settings to apply when loading a scene.
/// </summary>
public class UnloadOptions
{
/// <summary>
/// Conditions to unloading a scene on the server.
/// </summary>
public enum ServerUnloadMode
{
/// <summary>
/// Unloads the scene if no more connections are within it.
/// </summary>
UnloadUnused = 0,
/// <summary>
/// Unloads scenes for connections but keeps scene loaded on server even if no connections are within it.
/// </summary>
KeepUnused = 1,
}
/// <summary>
/// How to unload scenes on the server. UnloadUnused will unload scenes which have no more clients in them. KeepUnused will not unload a scene even when empty. ForceUnload will unload a scene regardless of if clients are still connected to it.
/// </summary>
[System.NonSerialized]
public ServerUnloadMode Mode = ServerUnloadMode.UnloadUnused;
/// <summary>
/// True if scenes should be loaded using addressables. This field only exists for optional use so the user may know if their queue data is using addressables.
/// </summary>
public bool Addressables;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3de31d76de313bc49aefba61135fdffc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
namespace FishNet.Managing.Scened
{
/// <summary>
/// Additional user-crafted data which can be included in scene unload callbacks.
/// </summary>
public class UnloadParams
{
/// <summary>
/// Objects which are included in callbacks on the server when unloading a scene. Can be useful for including unique information about the scene, such as match id. These are not sent to clients; use ClientParams for this.
/// </summary>
[System.NonSerialized]
public object[] ServerParams = new object[0];
/// <summary>
/// Bytes which are sent to clients during scene unloads. Can contain any information.
/// </summary>
public byte[] ClientParams = new byte[0];
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3bba3fbbe6ffbae4bb18d50c8c9b3b30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
using FishNet.Connection;
using FishNet.Utility.Constant;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo(UtilityConstants.GENERATED_ASSEMBLY_NAME)]
namespace FishNet.Managing.Scened
{
/// <summary>
/// Data generated when unloading a scene.
/// </summary>
public class UnloadQueueData
{
/// <summary>
/// Clients which receive this SceneQueueData. If Networked, all clients do. If Connections, only the specified Connections do.
/// </summary>
[System.NonSerialized]
public readonly SceneScopeType ScopeType;
/// <summary>
/// Connections to unload scenes for. Only valid on the server and when ScopeType is Connections.
/// </summary>
[System.NonSerialized]
public NetworkConnection[] Connections;
/// <summary>
/// SceneUnloadData to use.
/// </summary>
public SceneUnloadData SceneUnloadData = null;
/// <summary>
/// Current global scenes.
/// </summary>
public string[] GlobalScenes = new string[0];
/// <summary>
/// True if to iterate this queue data as server.
/// </summary>
[System.NonSerialized]
public readonly bool AsServer;
public UnloadQueueData() { }
internal UnloadQueueData(SceneScopeType scopeType, NetworkConnection[] conns, SceneUnloadData sceneUnloadData, string[] globalScenes, bool asServer)
{
ScopeType = scopeType;
Connections = conns;
SceneUnloadData = sceneUnloadData;
GlobalScenes = globalScenes;
AsServer = asServer;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ea9c20d60381ea74f974fb87a7e78297
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: