Add StickGame Assets
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using FishNet.Documenting;
|
||||
using FishNet.Managing;
|
||||
using FishNet.Object;
|
||||
|
||||
namespace FishNet.Utility.Extension
|
||||
{
|
||||
[APIExclude]
|
||||
public static class NetworksFN
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns if logic could have potentially called already on server side, and is calling a second time for clientHost side.
|
||||
/// </summary>
|
||||
public static bool DoubleLogic(this NetworkObject nob, bool asServer) => (!asServer && nob.NetworkManager.IsServer);
|
||||
/// <summary>
|
||||
/// Returns if logic could have potentially called already on server side, and is calling a second time for clientHost side.
|
||||
/// </summary>
|
||||
public static bool DoubleLogic(this NetworkManager manager, bool asServer) => (!asServer && manager.IsServer);
|
||||
/// <summary>
|
||||
/// Returns if logic could have potentially called already on server side, and is calling a second time for clientHost side.
|
||||
/// </summary>
|
||||
public static bool DoubleLogic(this NetworkBehaviour nb, bool asServer) => (!asServer && nb.NetworkManager.IsServer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbd3adaae5d34a14ab9cf68726b3bd3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
using FishNet.Object;
|
||||
using GameKit.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace FishNet.Utility.Extension
|
||||
{
|
||||
|
||||
public static class Scenes
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all NetworkObjects in a scene.
|
||||
/// </summary>
|
||||
/// <param name="s">Scene to get objects in.</param>
|
||||
/// <param name="firstOnly">True to only return the first NetworkObject within an object chain. False will return nested NetworkObjects.</param>
|
||||
/// <param name="cache">ListCache of found NetworkObjects.</param>
|
||||
/// <returns></returns>
|
||||
public static void GetSceneNetworkObjects(Scene s, bool firstOnly, ref List<NetworkObject> result)
|
||||
{
|
||||
List<NetworkObject> nobCacheA = CollectionCaches<NetworkObject>.RetrieveList();
|
||||
List<NetworkObject> nobCacheB = CollectionCaches<NetworkObject>.RetrieveList();
|
||||
List<GameObject> gameObjectCache = CollectionCaches<GameObject>.RetrieveList();
|
||||
//Iterate all root objects for the scene.
|
||||
s.GetRootGameObjects(gameObjectCache);
|
||||
foreach (GameObject go in gameObjectCache)
|
||||
{
|
||||
//Get NetworkObjects within children of each root.
|
||||
go.GetComponentsInChildren<NetworkObject>(true, nobCacheA);
|
||||
//If network objects are found.
|
||||
if (nobCacheA.Count > 0)
|
||||
{
|
||||
//Add only the first networkobject
|
||||
if (firstOnly)
|
||||
{
|
||||
/* The easiest way to see if a nob is nested is to
|
||||
* get nobs in parent and if the count is greater than 1, then
|
||||
* it is nested. The technique used here isn't exactly fast but
|
||||
* it will only occur during scene loads, so I'm trading off speed
|
||||
* for effort and readability. */
|
||||
foreach (NetworkObject nob in nobCacheA)
|
||||
{
|
||||
nob.GetComponentsInParent<NetworkObject>(true, nobCacheB);
|
||||
//No extra nobs, only this one.
|
||||
if (nobCacheB.Count == 1)
|
||||
result.Add(nob);
|
||||
}
|
||||
}
|
||||
//Not first only, add them all.
|
||||
else
|
||||
{
|
||||
result.AddRange(nobCacheA);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a02f3d03f737e304e9854278f4e9211d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,80 @@
|
||||
using FishNet.Documenting;
|
||||
using FishNet.Object;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FishNet.Utility.Extension
|
||||
{
|
||||
[APIExclude]
|
||||
public static class TransformFN
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets values of TransformProperties to a transforms world properties.
|
||||
/// </summary>
|
||||
public static TransformProperties GetWorldProperties(this Transform t)
|
||||
{
|
||||
TransformProperties tp = new TransformProperties(t.position, t.rotation, t.localScale);
|
||||
return tp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets values of TransformPropertiesCls to a transforms world properties.
|
||||
/// </summary>
|
||||
public static void SetWorldProperties(this TransformPropertiesCls tp, Transform t)
|
||||
{
|
||||
tp.Position = t.position;
|
||||
tp.Rotation = t.rotation;
|
||||
tp.LocalScale = t.localScale;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the offset values of target from a transform.
|
||||
/// </summary>
|
||||
/// <param name="pos">Position offset result.</param>
|
||||
/// <param name="rot">Rotation offset result.</param>
|
||||
public static void SetTransformOffsets(this Transform t, Transform target, ref Vector3 pos, ref Quaternion rot)
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
pos = (target.position - t.position);
|
||||
rot = (target.rotation * Quaternion.Inverse(t.rotation));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the offset values of target from a transform.
|
||||
/// </summary>
|
||||
/// <param name="pos">Position offset result.</param>
|
||||
/// <param name="rot">Rotation offset result.</param>
|
||||
public static TransformProperties GetTransformOffsets(this Transform t, Transform target)
|
||||
{
|
||||
if (target == null)
|
||||
return default;
|
||||
|
||||
return new TransformProperties(
|
||||
(target.position - t.position),
|
||||
(target.rotation * Quaternion.Inverse(t.rotation)),
|
||||
(target.localScale - t.localScale)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets local position and rotation for a transform.
|
||||
/// </summary>
|
||||
public static void SetLocalPositionAndRotation(this Transform t, Vector3 pos, Quaternion rot)
|
||||
{
|
||||
t.localPosition = pos;
|
||||
t.localRotation = rot;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets local position, rotation, and scale for a transform.
|
||||
/// </summary>
|
||||
public static void SetLocalPositionRotationAndScale(this Transform t, Vector3 pos, Quaternion rot, Vector3 scale)
|
||||
{
|
||||
t.localPosition = pos;
|
||||
t.localRotation = rot;
|
||||
t.localScale = scale;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d311fc1bf09b9e4fbc5a17a9c50ab0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user