For the complete documentation index, see llms.txt. This page is also available as Markdown.

KS.Reactor.Client.Unity

Namespaces

KS.Reactor.Client.Unity.Editor

Classes

ksReactorConfig.BuildConfigs

Build settings.

ksReactorConfig.ClusterConfigs

Local cluster settings

ksWSConnection.ConfigSettings

ConvexHullCalculator

An implementation of the quickhull algorithm for generating 3d convex hulls.

The algorithm works like this: you start with an initial "seed" hull, that is just a simple tetrahedron made up of four points in the point cloud. This seed hull is then grown until it all the points in the point cloud is inside of it, at which point it will be the convex hull for the entire set.

All of the points in the point cloud is divided into two parts, the "open set" and the "closed set". The open set consists of all the points outside of the tetrahedron, and the closed set is all of the points inside the tetrahedron. After each iteration of the algorithm, the closed set gets bigger and the open set get smaller. When the open set is empty, the algorithm is finished.

Each point in the open set is assigned to a face that it lies outside of. To grow the hull, the point in the open set which is farthest from it's face is chosen. All faces which are facing that point (I call them "lit faces" in the code, because if you imagine the point as a point light, it's the set of points which would be lit by that point light) are removed, and a "horizon" of edges is found from where the faces were removed. From this horizon, new faces are constructed in a "cone" like fashion connecting the point to the edges.

To keep track of the faces, I use a struct for each face which contains the three vertices of the face in CCW order, as well as the three triangles which share an edge. I was considering doing a half-edge structure to store the mesh, but it's not needed. Using a struct for each face and neighbors simplify the algorithm and makes it easy to export it as a mesh.

The most subtle part of the algorithm is finding the horizon. In order to properly construct the cone so that all neighbors are kept consistent, you can do a depth-first search from the first lit face. If the depth-first search always proceeeds in a counter-clockwise fashion, it guarantees that the horizon will be found in a counter-clockwise order, which makes it easy to construct the cone of new faces.

There are a number of things you could possibly optimize in this version of the algorithm, but this should be correct and reasonably fast.

A note: the code uses a right-handed coordinate system, where the cross-product uses the right-hand rule and the faces are in CCW order. At the end of the algorithm, the hull is exported in a Unity-friendly fashion, with a left-handed mesh.

ksEntity.Indicator

Our non-standard colliders generate collision meshes which are attached as hidden children to the game object. We attach this indicator to those child game objects to indicate that we should check the parent to find the ksEntityComponent for that game object.

ksReactorConfig.ServerConfigs

Local server settings.

ksReactorConfig.URLConfigs

Web API URLs.

ksProxyScript.UnsupportedType

ksAnimationSync

Syncs animation parameters and optionally layer states for an entity that has an owner with the PROPERTIES permission. Each animation parameter (and layer if SyncLayerStates is true) is synced as an entity property, starting at id AnimationPropertiesStart.

ksAssetAttribute

Attribute to indicate a scriptable object browser should only show the assets tab and not the scene tab. Unity by default opens the scene tab when browsing for scriptable objects, which is unfortunate because scriptable objects can't exist in the scene.

ksAssetLoader

Asset loader that loads ksScriptAssets from ksProxyScriptAssets.

ksAutoSpawn

Automatically spawns an entity for the game object when it is instantiated. Can only be used with entity prefabs in Resources or asset bundles. It first checks it's ancestors for a connected room to spawn in that has AllowPlayerSpawning set to true. If it does not find one, It will look for a room in the same scene to spawn in. If it does not find one, it will spawn an entity the first time a connection is made to a room in that scene with auto spawning enabled. If it finds more than one, it will not spawn and will log a warning.

If placed on a prefab entity that is part of the initial scene and has SpawnOwned set to true, the entity will not be written to the scene config and instead will be spawned per-player when they connect.

When the entity it is linked to is destroyed and DestroyWithServer is false, if the entity was destroyed because of a disconnect, it will try to respawn in a different room or wait until there is a room to respawn in. If it was destroyed for any other reason, the script will disable itself, and you must reenable it if you want it to respawn.

ksBaseUnityRigidBody

Base class for classes that wrap a Unity Rigidbody for use with Reactor.

ksBoolVectorAttribute

Attribute to indicate an int vector should be drawn as checkboxes in the inspector, with true=1 and false=0.

ksClientInputPredictorAsset

Predictor asset that creates instances of ksClientInputPredictor when assigned in the entity or room type inspector.

ksClientSpawnParams

Parameters for spawning entities on the client.

ksClientSpawnParams2D

Parameters for spawning entities on the client with 2D transform values.

ksColliderData

A hidden component that contains a mapping from a collider to its PhysX simulation flag value and collision filter override.

ksCollisionFilterAsset

The collsion filter uses 3 mask properties (Group, Notify, Collide) to determine interaction and notifications during the physics simulation. This is used as a proxy asset to save data for a ksCollisionFilter in Unity.

ksConeCollider

Cone collider component.

ksConeMeshFactory

Factory for generating cone meshes. Caches meshes for resuse.

ksConnect

Reactor Connection component for connecting to Reactor server rooms and registering event handlers.

ksConnectionHUD

Self contained GUI designed to help new reactor users establish connection to servers for the first time.

ksConvergingInputPredictorAsset

Predictor asset that creates instances of ksConvergingInputPredictor when assigned in the entity or room type inspector.

ksConvexHull

Stores a convex hull created from a mesh.

ksCylinderCollider

Cylinder collider component.

ksCylinderMeshFactory

Factory for generating cylinder meshes. Caches meshes for resuse.

ksDirectConnection

ksDisplayNameAttribute

Attribute to change a field's display name in the inspector.

ksEntity

Unity implementation of ksBaseEntity. Entities are objects create, updated, and destroyed by a server and replicated to clients.

ksEntityComponent

Attach this to your GameObjects to make the server aware of them when you publish your scene.

ksEntityFactory

Factory for creating game objects for entities. Use this class to implement your own entity factory and assign it to ksRoom.EntityFactory.

ksEntityLinker

Maps entity ids to game objects that existed in the scene before joining a room, and room type names to room types.

ksEntityPhysicsSettings

PhysX settings common to static, kinematic, and dynamic entities. These values may be set on a scene or entity. A value of -1f, or 0 for iteration values, means that the value should be inherited. If set on an ksEntityComponent component then the value will be inherited from the room ksPhysicsSettings component. If set on a ksPhysicsSettings component, then the default values will be used.

ksEntityScript

Base class for scripts attached to entities.

ksEnumAttribute

Attribute to indicate an enum is using our naming standard (ENUM_VALUE) so we know in the editor to convert it to a more readable format (Enum Value).

ksFlagsAttribute

Attribute to indicate a flag mask enum is using our naming standard (ENUM_VALUE) so we know in the editor to convert it to a more readable format (Enum Value). Composite flag values are not shown.

ksGhost

Attach this script to a Reactor entity game object to have it spawn an associated ghost object. The ghost object will update its trasform to match the entity server transform. This allows the entity server transform to be compared to its client transform, include prediction and smoothing adjustements.

ksHideInOwnershipManagerAttribute

Class tag that hides components from the ksOwnershipScriptManager inspector. If a base class has this tag, derived classes will also be hidden. A derived class can pass false to the constructor to make itself visible to the ksOwnershipScriptManager inspector.

ksInputManager

Unity implementation of ksIInputManager. Translates Unity inputs to ksInput and integrates it with direct input.

ksLateUpdateHook

Provides access to Unity's LateUpdate MonoBehaviour event. This script is separate from ksUpdateHook so they can use different script execution times. Used by ksReactor to call events on non-Unity objects.

ksLinearPredictorAsset

Predictor asset that creates instances of ksLinearPredictor when assigned in the entity or room type inspector.

ksMenuGroups

Menu group priority constants. Lower priority shows first. Groups must be separated by more than 10 to have a line drawn between them.

ksMenuNames

Menu name constants.

ksMonoScript<Parent, Script>

Base class for Reactor MonoBehaviour scripts.

ksNetStatsMonitor

Calculates and optionally logs bandwidth and other network counts per second at regular intervals. Which stats are calculated is configurable using CounterTypes. If attached to a room object, will calculate the stats for just that room from NetStats. Otherwise it will calculate the total stats for all rooms from NetStats. If you have other code that clears the ksNetStats counters, the calculate stats will be inaccurate.

ksNewClientEntityScript

When attached in the editor, the custom inspector will delete this script and open a new client entity script dialog. We use a monobehaviour for this to get an icon in the component menu.

ksNewClientPlayerScript

When attached in the editor, the custom inspector will delete this script and open a new client player script dialog. We use a monobehaviour for this to get an icon in the component menu.

ksNewClientRoomScript

When attached in the editor, the custom inspector will delete this script and open a new client room script dialog. We use a monobehaviour for this to get an icon in the component menu.

ksNewServerEntityScript

When attached in the editor, the custom inspector will delete this script and open a new server entity script dialog. We use a monobehaviour for this to get an icon in the component menu.

ksNewServerPlayerScript

When attached in the editor, the custom inspector will delete this script and open a new server player script dialog. We use a monobehaviour for this to get an icon in the component menu.

ksNewServerRoomScript

When attached in the editor, the custom inspector will delete this script and open a new server room script dialog.We use a monobehaviour for this to get an icon in the component menu.

ksOwnershipScriptManager

Controls what happens to components and/or child objects when the local player owns or doesn't own the entity. Attach this script to an object with a ksEntityComponent or one of its descendants.

ksPhysicsAdaptor

ksBasePhysics implementation that uses Unity physics.

ksPhysicsSettings

Physics configuration settings. For more information about these properties see the PhysX documentation. https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Index.html

ksPlayer

Unity implementation of ksBasePlayer. A player represents a client.

ksPlayerAPIExtensions

Extend ksPlayerAPI with helper functions specific to Unity.

ksPlayerComponent

Player component. This adds no functionality that's not already in the generic base class, but we need this class because Unity does not allow you to attach generic Monobehaviours.

ksPlayerControllerAsset

ksPlayerScript

Base class for scripts attached to players. These can be attached to game objects with ksRoomType in the editor, but they won't run on those game objects. They are copied to player game objects for players in rooms of the given room type.

ksPredictor

Base class for developers to write custom predictors for smoothing object movement and property data. Predictors are scriptable objects. You must create an asset from a predictor (Create > Reactor > PredictorClassName) to use it, then assign it to an entity component or the room type to make it the default predictor.

ksPrefabCache

Manages caching and loading and entity prefabs.

ksProxyEntityScript

ksProxyPlayerScript

Proxy to attach to ksRoomType game objects in place of server player scripts.

ksProxyRoomScript

Proxy to attach to ksRoomType game objects in place of server room scripts.

ksProxyScript

Proxy scripts are attached to gameobjects to represent server scripts and provide editing of server script properties.

ksProxyScriptAsset

Proxy scripts assets store data used in server script assets.

ksReactor

Manages Reactor Unity features including: Service initialization, input binding managers, web API calls, prefab/entity caching, and room/scene states.

ksReactorConfig

Reactor configuration setttings.

ksReadOnlyAttribute

Monobehaviour and scriptable object properties marked with this attribute will be displayed as a read only string.

ksResourceRangeAttribute

Exponential range attribute for resources. As the property value increases, the step size will increases by powers of 2.

ksRoom

Unity implementation of ksBaseRoom. Rooms are used to connect to server rooms. The room maintains a simulation state that is regularly synced with the server.

ksRoomComponent

Room component. This adds no functionality that's not already in the generic base class, but we need this class because Unity does not allow you to attach generic Monobehaviours.

ksRoomScript

Base class for scripts attached to rooms. These can be attached to game objects with ksRoomType in the editor, but they won't run on those game objects. They are copied to room game objects for rooms of the given room type.

ksRoomType

Room types hold room configuration data. Room and player scripts can be attached to game objects with room types.

ksScriptsComponent<Parent, Script>

Component that manages ksMonoScripts. ksMonoScript%602 will look for a component when initialized.

ksSerializableMultiType

Wraps a ksMultiType so it can be serialized by Unity and edited in the inspector.

ksShapeUtils

Collision shape utils.

ksTransformPrecisions

Precision used by the server to determine if an update needs to be sent to connected clients. These values may be set on a scene or entity. A value of -1f means that the value should be inherited. If set on a ksEntityComponent component then the value will be inherited from the room ksRoomType component. If set on a ksRoomType component, then the default values will be used.

ksUnityCharacterController

Class that wraps a Unity character controller and implements the ksICharacterController interface.

ksUnityCollider

Wraps a Unity collider for use with Reactor.

ksUnityReflectionUtils

Cloning and reflection utility functions.

ksUnityRigidBody

Wraps a Unity Rigidbody for use with Reactor.

ksUnityRigidBody2DView

Wraps a Unity Rigidbody for use with Reactor using a 2D interface.

ksUnityTransformExtension

Adds a Teleport extension method to the Unity Transform.

ksUnityWebRequest

Handles web requests using the Unity UnityWebRequest object.

ksUpdateHook

Provides access to Unity's Update and OnApplicationQuit MonoBehaviour events. Used by ksReactor to call events on non-Unity objects.

ksWSConnection

Network stream connection using a KinematicSoup javascript websocket library.

ksWarningAttribute

Tag proxy script classes to display a warning message in the inspector for the class.

Structs

ksConnect.ConnectEvent

Connect event passed to OnConnect event handlers.

ksConnect.DisconnectEvent

Disconnect event passed to OnDisconnect event handlers.

ksConnect.GetRoomsEvent

Get rooms event passed to OnGetRooms event handlers.

ksLinearPredictorAsset.PropertyBehaviour

Describes how to predict a property.

ksConvergingInputPredictorAsset.PropertyBehaviour

Describes how to predict a property.

ksCylinderData

Cylinder dimension data used as a key in mesh caches.

ksScriptAssetReference<T>

A reference to a ksScriptAsset that Unity can serialize. References a ksProxyScriptAsset which is used to load a ksScriptAsset of type T.

Interfaces

ksICloneableScript

Interface for scripts that can copy their values onto another script.

ksIUnityCollider

Interface for getting data from our colliders or Unity's colliders.

Enums

ksConnect.ConnectModes

List of methods the connection script uses to find a server.

ksConnect.ConnectProtocols

List of protocols the connection script uses to connect to a server.

ksNetStatsMonitor.CounterType

Counter type flags

ksSerializableMultiType.LegacyTypes

Legacy types that could be serialized in the inspector. Some pseudo types weren't real and only changed how the data was shown in the inspector but internally used a different type, such as vectors using float arrays internally.

ksPlayerScript.PlayerTypes

Player types

ksOwnershipScriptManager.Rules

Object rules to apply based on entity ownership.

ksPhysicsSettings.SolverTypes

PhysX solvers used for physics simulations.

ksExistenceModes

Does the component exist on the client, server, or both?

Delegates

ksUpdateHook.Callback

Void delegate used for OnQuit events.

ksUnityReflectionUtils.Filter

Delegate for filtering which fields get copied.

ksScriptsComponent<Parent, Script>.PreAttachHandler

Pre attach scripts handler.

ksReactor.RoomConnectHandler

Room connect handler

ksReactor.RoomDisconnectHandler

Room disconnect handler

ksReactor.RoomInitializedHandler

Room initialized handler

ksUpdateHook.UpdateCallback

Update delegate use for Update events.

ksInputManager.Validator

Input validation handler.

ksInputManager.ValueGetter

Callback to get an input value.

Last updated