Photon Bolt Engine API 1.3

Static Public Member Functions | Properties | List of all members
Photon.Bolt.BoltNetwork Class Reference

Global methods and properties to control Photon Bolt. More...

Static Public Member Functions

static void Accept (UdpEndPoint endpoint)
 Signal bolt to accept an incoming client connection request More...
 
static void Accept (UdpEndPoint endpoint, IProtocolToken acceptToken)
 Signal bolt to accept an incoming client connection request More...
 
static void AddGlobalEventCallback< T > (Action< T > callback)
 Manually add a global event callback More...
 
static void AddGlobalEventListener (MonoBehaviour mb)
 Manually add a global event listener More...
 
static GameObject Attach (GameObject gameObject)
 Manually attach an Entity. More...
 
static GameObject Attach (GameObject gameObject, IProtocolToken token)
 Manually attach an Entity. More...
 
static void Connect (UdpEndPoint endpoint, IProtocolToken token=null)
 Connect to a server using their listening endpoint More...
 
static void Connect (ushort port, IProtocolToken token=null)
 Connect to a server running on a specific port. This game server must be running on the local machine. More...
 
static UdpChannelName CreateStreamChannel (string name, UdpChannelMode mode, int priority)
 Creating a new binary streaming channel More...
 
static void Destroy (GameObject gameObject)
 Remove a gameObject from the bolt simulation. More...
 
static void Destroy (GameObject gameObject, IProtocolToken token)
 Remove a gameObject from the bolt simulation. More...
 
static void Detach (GameObject gameObject)
 Manually detach an Entity. More...
 
static void Detach (GameObject gameObject, IProtocolToken token)
 Manually detach an Entity. More...
 
static void DisableLanBroadcast ()
 Disable LAN broadcasting More...
 
static void EnableLanBroadcast (ushort port=60000)
 Enable LAN broadcasting More...
 
static bool FindConnection (uint connectionId, out BoltConnection boltConnection)
 Looks at the BoltConnection list for a specific connection reference based on its ID. More...
 
static BoltEntity FindEntity (NetworkId id)
 Find an entity based on unique id More...
 
static BoltEntity Instantiate (GameObject prefab)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (GameObject prefab, IProtocolToken token)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (GameObject prefab, IProtocolToken token, Vector3 position, Quaternion rotation)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (GameObject prefab, Vector3 position, Quaternion rotation)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (PrefabId prefabId)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (PrefabId prefabId, IProtocolToken token)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (PrefabId prefabId, IProtocolToken token, Vector3 position, Quaternion rotation)
 Create a new entity in the simuation from a prefab More...
 
static BoltEntity Instantiate (PrefabId prefabId, Vector3 position, Quaternion rotation)
 Create a new entity in the simuation from a prefab More...
 
static void LoadScene (string scene)
 Load a scene based on name, only possible on the Server More...
 
static void LoadScene (string scene, IProtocolToken token)
 Load a scene based on name, only possible on the Server More...
 
static void LoadSceneSync ()
 Use this method to sync the local scene on the Client with the remote scene from the Server. This method can only be invoked on the Client and it's only useful if you have the Auto Scene Load disabled. More...
 
static BoltPhysicsHits OverlapSphereAll (Vector3 origin, float radius)
 Perform a sphere overlap against Bolt hitboxes More...
 
static BoltPhysicsHits OverlapSphereAll (Vector3 origin, float radius, int frame)
 Perform a sphere overlap against Bolt hitboxes More...
 
static Vector3 PositionAtFrame (BoltHitboxBody hitboxBody, int frame)
 Perform a hitbox rewind to get transform position at a given frame. More...
 
static void PreLoadPrefabDatabase ()
 Async load Bolt Entity prefabs More...
 
static BoltPhysicsHits RaycastAll (Ray ray)
 Perform a raycast against Bolt hitboxes More...
 
static BoltPhysicsHits RaycastAll (Ray ray, int frame)
 Perform a raycast against Bolt hitboxes More...
 
static void Refuse (UdpEndPoint endpoint)
 Signal bolt to refuse an incoming connection request More...
 
static void Refuse (UdpEndPoint endpoint, IProtocolToken token)
 Signal bolt to refuse an incoming connection request More...
 
static void RegisterTokenClass< T > ()
 Registers a type as a potential protocol token More...
 
static void RemoveGlobalEventCallback< T > (Action< T > callback)
 Manually remove a global event callback More...
 
static void RemoveGlobalEventListener (MonoBehaviour mb)
 Manually remove a global event listener More...
 
static void SetCanReceiveEntities (bool canReceiveEntities)
 Whether the local simulation can receive entities instantiated from other connections More...
 
static void SetEventFilter (IEventFilter filter)
 Sets bolt to use a filter to accept or reject certain events based on custom filtering More...
 
static void SetNetworkSimulation (float loss, int pingMin, int pingMax)
 Sets the simulated network loss/ping settings for this peer. More...
 
static void SetPrefabPool (IPrefabPool pool)
 Sets a custom implementation for pooling prefabs More...
 
static void Shutdown ()
 Shutdown this instance. More...
 
static void ShutdownImmediate ()
 Shutdowns Bolt Immediately. More...
 
static void UpdateCurrentScene ()
 Updates the internal loaded scene information. This is useful if Bolt is not used to manage Scenes and this is done externally by the developer. If the active Scene was changed, this must be invoked in order to signal that the internal data must be updated. More...
 
static void UpdateSceneObjectsLookup ()
 Updates the scene objects for fast lookup. More...
 
static void UpdateSessionList (Map< Guid, UdpSession > sessions)
 Updates the session list from an external source More...
 

Properties

static IEnumerable< BoltConnectionClients [get]
 All clients connected to this host More...
 
static IEnumerable< BoltConnectionConnections [get]
 All the connections connected to this host More...
 
static AsyncOperation CurrentAsyncOperation [get]
 Gets the current async operation. More...
 
static string CurrentVersion [get]
 Gets the current Bolt version as string. More...
 
static IEnumerable< BoltEntityEntities [get]
 Returns an IEnumerable list of all Bolt Entities currently loaded into the scene More...
 
static int Frame [get]
 The current local simulation frame number More...
 
static float FrameAlpha [get]
 Normalized value of how much time have passed since the last FixedUpdate More...
 
static float FrameBeginTime [get]
 The time the last fixed update begain, same as Time.fixedTime More...
 
static float FrameDeltaTime [get]
 The fixed frame delta, same as Time.fixedDeltaTime More...
 
static int FramesPerSecond [get]
 How many FixedUpdate frames per second bolt is configured to run More...
 
static GameObject GlobalObject [get]
 The global object that all global behaviours will be attached to More...
 
static bool IsClient [get]
 Returns true if this host is a client More...
 
static bool IsConnected [get]
 Returns true if this instance is a server or a client with at least one valid connection. More...
 
static bool IsDebugMode [get]
 Returns true if Bolt was compiled in debug mode More...
 
static bool IsRunning [get]
 Signal if Bolt is running. More...
 
static bool IsServer [get]
 Returns true if this host is a server More...
 
static bool IsSinglePlayer [get]
 Returns true if this host is running in single player mode. More...
 
static int? MaxConnections [get]
 The max number of client connections to the server More...
 
static IEnumerable< BoltEntitySceneObjects [get]
 A list of all BoltEntities in the server simulation More...
 
static ScopeMode ScopeMode [get]
 The scoping mode active More...
 
static BoltConnection Server [get]
 The server connection More...
 
static int ServerFrame [get]
 On the server this returns the local frame, on a client this returns the currently estimated frame of all server objects we have received More...
 
static float ServerTime [get]
 The current server simulation time More...
 
static Map< Guid, UdpSessionSessionList [get]
 Gets the list of UdpSession received by the system. More...
 
static float Time [get]
 The local time, same as Time.time More...
 
static UdpSocket UdpSocket [get]
 Gets the current UDP socket. More...
 
static Version Version [get]
 The current Photon Bolt assembly version number. More...
 
static string??? VersionConfiguration [get]
 Gets the Bolt Version description. More...
 
static string??? VersionInfo [get]
 Extra info of the Current Bolt version. More...
 

Detailed Description

Global methods and properties to control Photon Bolt.

Example: How to load a map on the server and instantiate a server controlled player.

void LoadMap(string mapName) {
BoltNetwork.LoadScene(mapName);
var serverPlayer = BoltNetwork.Instantiate(BoltPrefabs.Player) as GameObject;
Configure(serverPlayer);
}

Example: How to connect to a server with known IP and port number.

void ConnectToServer(string host, int port) {
UdpEndPoint serverAddr = UdpEndPoint(UdpIPv4Address.Parse(host), (ushort)port);
BoltNetwork.Connect(server);
}

Example: How to use the BoltNetwork frame property in an Update loop. Here we recalculate the player path 3 times per second.

void Update() {
if(BoltNetwork.frame % 20) == 0) {
playerMotor.Repath(targetPos);
}
}

Member Function Documentation

◆ Accept() [1/2]

static void Photon.Bolt.BoltNetwork.Accept ( UdpEndPoint  endpoint)
inlinestatic

Signal bolt to accept an incoming client connection request

Parameters
endpointThe UDP address of incoming client connection

Example: Accepting an incoming connection.

public override void ConnectRequest(UdpEndPoint endpoint) {
BoltNetwork.Accept(endPoint);
}

◆ Accept() [2/2]

static void Photon.Bolt.BoltNetwork.Accept ( UdpEndPoint  endpoint,
IProtocolToken  acceptToken 
)
inlinestatic

Signal bolt to accept an incoming client connection request

Parameters
endpointThe UDP address of incoming client connection
acceptTokenA data token from the server

Example: Accepting an incoming connection and passing a data token to tell the client the preferred reconnect timeout.

public override void ConnectRequest(BoltConnection connection) {
ConnectionToken token = new ConnectionToken();
connectionToken.retryTimeout = 30f;
BoltNetwork.Accept(connection.remoteEndPoint, token);
}

◆ AddGlobalEventCallback< T >()

static void Photon.Bolt.BoltNetwork.AddGlobalEventCallback< T > ( Action< T >  callback)
inlinestatic

Manually add a global event callback

Type Constraints
T :Bolt.Event 

◆ AddGlobalEventListener()

static void Photon.Bolt.BoltNetwork.AddGlobalEventListener ( MonoBehaviour  mb)
inlinestatic

Manually add a global event listener

Parameters
mbThe monobehaviour to invoke events on

◆ Attach() [1/2]

static GameObject Photon.Bolt.BoltNetwork.Attach ( GameObject  gameObject)
inlinestatic

Manually attach an Entity.

Parameters
gameObjectGame object.
Returns
The Entity to attach.

◆ Attach() [2/2]

static GameObject Photon.Bolt.BoltNetwork.Attach ( GameObject  gameObject,
IProtocolToken  token 
)
inlinestatic

Manually attach an Entity.

Parameters
gameObjectGame object.
tokenToken.
Returns
The attach.

◆ Connect() [1/2]

static void Photon.Bolt.BoltNetwork.Connect ( UdpEndPoint  endpoint,
IProtocolToken  token = null 
)
inlinestatic

Connect to a server using their listening endpoint

BOLT PRO ONLY

Parameters
endpointServer end point to connect to
tokenOptional Token used when connecting to server, this can be the client credentials

Example: A method to connect to any server ip and port as a client.

void Connect(string host, int port) {
UdpEndPoint serverAddr = new UdpEndPoint(UdpIPv4Address.Parse(host), (ushort)port);
Credentials cred = new Credentials("DevUser01", "DevPassword");
BoltNetwork.Connect(serverAddr, cred);
}

◆ Connect() [2/2]

static void Photon.Bolt.BoltNetwork.Connect ( ushort  port,
IProtocolToken  token = null 
)
inlinestatic

Connect to a server running on a specific port. This game server must be running on the local machine.

Parameters
portConnect to a local server using its port
tokenOptional Token used when connecting to server, this can be the client credentials

Example: A method to connect to any server using only its port as a client.

void Connect(int port) {
BoltNetwork.Connect(port);
}

◆ CreateStreamChannel()

static UdpChannelName Photon.Bolt.BoltNetwork.CreateStreamChannel ( string  name,
UdpChannelMode  mode,
int  priority 
)
inlinestatic

Creating a new binary streaming channel

Parameters
nameChannel name
modeReliability mode
priorityBandwidth priority
Returns
Channel name struct

Example: Creating an unreliable stream channel for voice and a reliable stream channel for sending custom player icons.

public static UdpKit.UdpChannelName Voice;
public static UdpKit.UdpChannelName CustomPlayerIcon;
public override void BoltStartBegin() {
Voice = BoltNetwork.CreateStreamChannel("Voice", UdpKit.UdpChannelMode.Unreliable, 1});
CustomPlayerIcon = BoltNetwork.CreateStreamChannel("CustomPlayerIcon", UdpKit.UdpChannelMode.Reliable, 4});
}

◆ Destroy() [1/2]

static void Photon.Bolt.BoltNetwork.Destroy ( GameObject  gameObject)
inlinestatic

Remove a gameObject from the bolt simulation.

Parameters
gameObjectThe gameObject to remove

Example: Destroying all player entities using a foreach loop over BoltNetwork.SceneObjects.

void DestroyAllPlayers() {
foreach(var entity in BoltNetwork.SceneObjects) {
if(entity.StateIs<IPlayerState>()) {
BoltNetwork.Destroy(entity.gameObject);
}
}
}

◆ Destroy() [2/2]

static void Photon.Bolt.BoltNetwork.Destroy ( GameObject  gameObject,
IProtocolToken  token 
)
inlinestatic

Remove a gameObject from the bolt simulation.

Parameters
gameObjectThe gameObject to remove
tokenOptional Token used when destroying an Entity, this can be used to send information about the destruction.

Example: Destroying all player entities using a foreach loop over BoltNetwork.SceneObjects and sending a death recap message as a protocol token.

void DestroyAllPlayers() {
foreach(var entity in BoltNetwork.SceneObjects) {
if(entity.StateIs<IPlayerState>()) {
DeathRecap recap = new DeathRecap("Destroyed By Server");
BoltNetwork.Destroy(entity.gameObject, recap);
}
}
}

◆ Detach() [1/2]

static void Photon.Bolt.BoltNetwork.Detach ( GameObject  gameObject)
inlinestatic

Manually detach an Entity.

Parameters
gameObjectGame object.

◆ Detach() [2/2]

static void Photon.Bolt.BoltNetwork.Detach ( GameObject  gameObject,
IProtocolToken  token 
)
inlinestatic

Manually detach an Entity.

Parameters
gameObjectGame object.
tokenToken.

◆ DisableLanBroadcast()

static void Photon.Bolt.BoltNetwork.DisableLanBroadcast ( )
inlinestatic

Disable LAN broadcasting

Example: Disabling LAN broadcasting at the end of a game.

void GameOver() {
foreach(var client in BoltNetwork.clients) {
client.Disconnect();
}
BoltNetwork.DisableLanBroadcast();
}

◆ EnableLanBroadcast()

static void Photon.Bolt.BoltNetwork.EnableLanBroadcast ( ushort  port = 60000)
inlinestatic

Enable LAN broadcasting

Parameters
portThe port to use for LAN broadcast. Default is 60000.

Example: Enabling LAN broadcast after starting a new server using a specified port.

void StartServer(int port, string map) {
BoltLauncher.StartServer(serverAddr);
BoltNetwork.EnableLanBroadcast(port);
BoltNetwork.LoadScene(map);
}

◆ FindConnection()

static bool Photon.Bolt.BoltNetwork.FindConnection ( uint  connectionId,
out BoltConnection  boltConnection 
)
inlinestatic

Looks at the BoltConnection list for a specific connection reference based on its ID.

Parameters
connectionIdConnection ID to check
boltConnectionReference to a BoltConnection if the ID is valid
Returns
True if a BoltConnection was found

◆ FindEntity()

static BoltEntity Photon.Bolt.BoltNetwork.FindEntity ( NetworkId  id)
inlinestatic

Find an entity based on unique id

Parameters
idThe id to look up
Returns
The entity if one was found, otherwise null

Example: Locating an entity within the scene using an id provided by the input command.

public override void ExecuteCommand(Bolt.Command cmd, bool resetState) {
AttackCommand atkCmd = (AttackCommand)cmd;
vNetworkId targetId = atkCmd.Input.targetId;
BoltEntity target = BoltNetwork.FindEntity(targetId);
activeWeapon.Fire(entity, target);
}

◆ Instantiate() [1/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( GameObject  prefab)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabThe prefab to clone into the simulation
Returns
A reference to the new bolt entity

Example: How to instantiate and configure a player entity inside a Bolt.GlobalEventListener on the server using a public editor variable playerPrefab as the player prefab object.

public GameObject playerPrefab;
public override void SceneLoadRemoteDone(BoltConnection connection) {
var player = BoltNetwork.Instantiate(playerPrefab);
player.transform.position = spawnPoint.transform.position;
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
Configure(player, initData);
player.AssignControl(connection);
}

◆ Instantiate() [2/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( GameObject  prefab,
IProtocolToken  token 
)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabThe prefab to clone into the simulation
tokenA data token of max size 512 bytes
Returns
A reference to the new bolt entity

Example: How to instantiate a player entity and allow to to configure itself with some initial data.

public GameObject playerPrefab;
public override void SceneLoadRemoteDone(BoltConnection connection) {
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
var player = BoltNetwork.Instantiate(playerPrefab, initData);
player.AssignControl(connection);
}

◆ Instantiate() [3/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( GameObject  prefab,
IProtocolToken  token,
Vector3  position,
Quaternion  rotation 
)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabThe prefab to clone into the simulation
tokenA data token of max size 512 bytes
positionA position vector
rotationA rotation quaternion
Returns
A reference to the new bolt entity

Example: How to instantiate and configure a player entity with both an initial data token and a given position / rotation.

public GameObject playerPrefab;
public override void SceneLoadRemoteDone(BoltConnection connection) {
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
var player = BoltNetwork.Instantiate(playerPrefab, spawnPoint.position, spawnPoint.rotation);
player.AssignControl(connection);
}

◆ Instantiate() [4/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( GameObject  prefab,
Vector3  position,
Quaternion  rotation 
)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabThe prefab to clone into the simulation
positionA position vector
rotationA rotation quaternion
Returns
A reference to the new bolt entity

Example: How to instantiate and configure a player entity with the position and rotation set to match that of the spawnPoint transform reference.

public GameObject playerPrefab;
public override void SceneLoadRemoteDone(BoltConnection connection) {
var player = BoltNetwork.Instantiate(playerPrefab, spawnPoint.position, spawnPoint.rotation);
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
Configure(player, initData);
player.AssignControl(connection);
}

◆ Instantiate() [5/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( PrefabId  prefabId)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabIdThe prefab to clone into the simulation
Returns
A reference to the new bolt entity

Example: How to instantiate a player entity using the static BoltPrefabs class as a shortcut to the player prefab object.

public override void SceneLoadRemoteDone(BoltConnection connection) {
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
var player = BoltNetwork.Instantiate(BoltPrefabs.Player, initData);
player.AssignControl(connection);
}

◆ Instantiate() [6/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( PrefabId  prefabId,
IProtocolToken  token 
)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabIdThe prefab to clone into the simulation
tokenA data token of max size 512 bytes
Returns
A reference to the new bolt entity

Example: How to instantiate a player entity and allow to to configure itself with some initial data using static BoltPrefabs class as a shortcut to the player prefab object.

public override void SceneLoadRemoteDone(BoltConnection connection) {
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
var player = BoltNetwork.Instantiate(BoltPrefabs.Player, initData);
player.AssignControl(connection);
}

◆ Instantiate() [7/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( PrefabId  prefabId,
IProtocolToken  token,
Vector3  position,
Quaternion  rotation 
)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabIdThe prefab to clone into the simulation
tokenA data token of max size 512 bytes
positionA position vector
rotationA rotation quaternion
Returns
A reference to the new bolt entity

Example: How to instantiate and configure a player entity inside a Bolt.GlobalEventListener on the server using initial data and the static BoltPrefabs class as a shortcut to the player prefab id.

public override void SceneLoadRemoteDone(BoltConnection connection) {
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
var player = BoltNetwork.Instantiate(BoltPrefabs.Player, spawnPoint.position, spawnPoint.rotation);
player.AssignControl(connection);
}

◆ Instantiate() [8/8]

static BoltEntity Photon.Bolt.BoltNetwork.Instantiate ( PrefabId  prefabId,
Vector3  position,
Quaternion  rotation 
)
inlinestatic

Create a new entity in the simuation from a prefab

Parameters
prefabIdThe prefab to clone into the simulation
positionA position vector
rotationA rotation quaternion
Returns
A reference to the new bolt entity

Example: How to instantiate a player entity from the static BoltPrefabs class with a given position and rotation.

public override void SceneLoadRemoteDone(BoltConnection connection) {
var player = BoltNetwork.Instantiate(BoltPrefabs.Player, spawnPoint.position, spawnPoint.rotation);
var initData = prototype.GetNewPlayer(GameLogic.PlayableClass.Mercenary);
Configure(player, initData);
player.AssignControl(connection);
}

◆ LoadScene() [1/2]

static void Photon.Bolt.BoltNetwork.LoadScene ( string  scene)
inlinestatic

Load a scene based on name, only possible on the Server

Parameters
sceneThe scene to load

Example: A utility function to start a server and initialize the first map.

public void StartServer(UdpEndPoint addr, string map) {
BoltLauncher.StartServer(addr);
BoltNetwork.LoadScene(map);
}

◆ LoadScene() [2/2]

static void Photon.Bolt.BoltNetwork.LoadScene ( string  scene,
IProtocolToken  token 
)
inlinestatic

Load a scene based on name, only possible on the Server

Parameters
sceneThe scene to load
tokenA data token from the server

Example: Passing a random tip to display to each client while the new map is loading.

public void ChangeMap(string map) {
ServerMessage message = new ServerMessage("Loading Map ...", GameTips.GetNext());
BoltNetwork.LoadScene(map, message);
}

◆ LoadSceneSync()

static void Photon.Bolt.BoltNetwork.LoadSceneSync ( )
inlinestatic

Use this method to sync the local scene on the Client with the remote scene from the Server. This method can only be invoked on the Client and it's only useful if you have the Auto Scene Load disabled.

Example: Receiving a signal from the server to sync scenes.

// On the game server, send an event when the player count reaches 3
public override void Connected(BoltConnection connection)
{
if (BoltNetwork.Connections.Count() == 3)
{
LoadSceneEvent.Create().Send();
}
}
// On any GlobalEventListener on the client
public override void OnEvent(LoadSceneEvent evnt)
{
BoltLog.Info("Received load scene");
BoltNetwork.LoadSceneSync();
}

◆ OverlapSphereAll() [1/2]

static BoltPhysicsHits Photon.Bolt.BoltNetwork.OverlapSphereAll ( Vector3  origin,
float  radius 
)
inlinestatic

Perform a sphere overlap against Bolt hitboxes

Parameters
originThe origin of the sphere
radiusThe radius of the sphere
Returns
The hitboxes that overlapped with the sphere

Example: Calculating the blast radius of a grenade.

void GrenadeOwner(PlayerCommand cmd, BoltEntity entity, IThrownWeapon grenade) {
if(entity.IsOwner) {
using(var hits = BoltNetwork.OverlapSphereAll(cmd.targetPos, grenade.explosionRadius)) {
for(int i = 0; i < hits.count; i++) {
var hit = hits.GetHit(i);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if (targetEntity != entity &amp;&amp; targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= grenade.damage;
}
}
}
}
}

◆ OverlapSphereAll() [2/2]

static BoltPhysicsHits Photon.Bolt.BoltNetwork.OverlapSphereAll ( Vector3  origin,
float  radius,
int  frame 
)
inlinestatic

Perform a sphere overlap against Bolt hitboxes

Parameters
originThe origin of the sphere
radiusThe radius of the sphere
frameThe frame to rollback to for calculation
Returns
The hitboxes that overlapped with the sphere

Example: Calculating the blast radius of a grenade.

void GrenadeOwner(PlayerCommand cmd, BoltEntity entity, IThrownWeapon grenade) {
if(entity.IsOwner) {
using(var hits = BoltNetwork.OverlapSphereAll(cmd.targetPos, grenade.explosionRadius, cmd.ServerFrame)) {
for(int i = 0; i < hits.count; i++) {
var hit = hits.GetHit(i);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if (targetEntity != entity &amp;&amp; targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= grenade.damage;
}
}
}
}
}

◆ PositionAtFrame()

static Vector3 Photon.Bolt.BoltNetwork.PositionAtFrame ( BoltHitboxBody  hitboxBody,
int  frame 
)
inlinestatic

Perform a hitbox rewind to get transform position at a given frame.

Parameters
hitboxBodyThe BoltHitboxBody to rewind
frameThe frame (aka BoltNetwork.frame) to rewind to
Returns
The transform position of the hitbox on a given BoltNetwork.frame

Example: Using PositionAtFrame to perform a dist check between a caster and target entity, but some frames back in time.

Vector3 RewindDistCheck(BoltEntity caster, BoltEntity target, int framesToRewind) {
casterHitbox = caster.GetComponent<BoltHitboxBody>();
targetHitbox = caster.GetComponent<BoltHitboxBody>();
casterRewindPos = BoltNetwork.PositionAtFrame(casterHitbox, BoltNetwork.frame - framesToRewind);
targetRewindPos = BoltNetwork.PositionAtFrame(targetHitbox, BoltNetwork.frame - framesToRewind);
return Vector3.Distance(casterRewindPos, targetRewindPos);
}

◆ PreLoadPrefabDatabase()

static void Photon.Bolt.BoltNetwork.PreLoadPrefabDatabase ( )
inlinestatic

Async load Bolt Entity prefabs

Example: Preloading assets in the background before Bolt starts.

void loadInBackground() {
BoltNetwork.PreLoadPrefabDatabase();
Resources.LoadAsync<myTerrain>("Terrain");
}

◆ RaycastAll() [1/2]

static BoltPhysicsHits Photon.Bolt.BoltNetwork.RaycastAll ( Ray  ray)
inlinestatic

Perform a raycast against Bolt hitboxes

Parameters
rayThe ray to
Returns
The hitboxes that intersected the ray

Example: Using RaycastAll to detect a hit event and apply damage in a player weapon firing method.

void FireWeaponOwner(PlayerCommand cmd, BoltEntity entity) {
if(entity.IsOwner) {
using(var hits = BoltNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos)) {
var hit = hits.GetHit(0);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if(targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= activeWeapon.damage;
}
}
}
}

◆ RaycastAll() [2/2]

static BoltPhysicsHits Photon.Bolt.BoltNetwork.RaycastAll ( Ray  ray,
int  frame 
)
inlinestatic

Perform a raycast against Bolt hitboxes

Parameters
rayThe ray to
frameThe frame to roll back to when performing this raycast
Returns
The hitboxes that intersected the ray

Example: Using RaycastAll to detect a hit event on a specific previous frame and then apply damage in a player weapon firing method.

void FireWeaponOwner(PlayerCommand cmd, BoltEntity entity) {
if(entity.IsOwner) {
using(var hits = BoltNetwork.RaycastAll(new Ray(entity.transform.position, cmd.Input.targetPos),
cmd.ServerFrame)) {
var hit = hits.GetHit(0);
var targetEntity = hit.body.GetComponent<BoltEntity>();
if(targetEntity.StateIs<ILivingEntity>()) {
targetEntity.GetState<ILivingEntity>().HP -= activeWeapon.damage;
}
}
}
}

◆ Refuse() [1/2]

static void Photon.Bolt.BoltNetwork.Refuse ( UdpEndPoint  endpoint)
inlinestatic

Signal bolt to refuse an incoming connection request

Parameters
endpointThe UDP address of incoming client connection

Example: Refusing an incoming connection.

public override void ConnectRequest(BoltConnection connection) {
BoltNetwork.Refuse(connection.remoteEndPoint);
}

◆ Refuse() [2/2]

static void Photon.Bolt.BoltNetwork.Refuse ( UdpEndPoint  endpoint,
IProtocolToken  token 
)
inlinestatic

Signal bolt to refuse an incoming connection request

Parameters
endpointThe UDP address of incoming client connection
tokenA data token from the server

Example: Refusing an incoming connection and sending back an error message.

public override void ConnectRequest(BoltConnection connection) {
ErrorMessage errorMessage = new ErrorMessage("Connection Refused", "Server Is Full");
BoltNetwork.Refuse(connection.remoteEndPoint, errorMessage);
}

◆ RegisterTokenClass< T >()

static void Photon.Bolt.BoltNetwork.RegisterTokenClass< T > ( )
inlinestatic

Registers a type as a potential protocol token

Template Parameters
TThe type to register

Example Registering two token types on startup.

public override void BoltStartDone() {
BoltNetwork.RegisterTokenClass<UserToken>();
BoltNetwork.RegisterTokenClass<ServerMessage>();
}
Type Constraints
T :class 
T :IProtocolToken 
T :new() 

◆ RemoveGlobalEventCallback< T >()

static void Photon.Bolt.BoltNetwork.RemoveGlobalEventCallback< T > ( Action< T >  callback)
inlinestatic

Manually remove a global event callback

Type Constraints
T :Bolt.Event 

◆ RemoveGlobalEventListener()

static void Photon.Bolt.BoltNetwork.RemoveGlobalEventListener ( MonoBehaviour  mb)
inlinestatic

Manually remove a global event listener

Parameters
mbThe monobehaviour to be removed

◆ SetCanReceiveEntities()

static void Photon.Bolt.BoltNetwork.SetCanReceiveEntities ( bool  canReceiveEntities)
inlinestatic

Whether the local simulation can receive entities instantiated from other connections

Parameters
canReceiveEntitiesWTrue/False

Example: Configuring the server to allow receiving entities and open a LAN game.

void ConfigureServer() {
BoltNetwork.SetCanReceiveEntities(true);
BoltNetwork.EnableLanBroadcast();
}

◆ SetEventFilter()

static void Photon.Bolt.BoltNetwork.SetEventFilter ( IEventFilter  filter)
inlinestatic

Sets bolt to use a filter to accept or reject certain events based on custom filtering

Parameters
filterYour custom implementation of the IEventFilter interface

Example: A custom event filter implementation which does nothing.

public class NullEventFilter : IEventFilter {
public bool EventReceived(Event ev) {
return true;
}
}

Example: Setting the NullEventFilter on startup.

public override void BoltStartDone() {
SetEventFilter(new NullEventFilter());
}

◆ SetNetworkSimulation()

static void Photon.Bolt.BoltNetwork.SetNetworkSimulation ( float  loss,
int  pingMin,
int  pingMax 
)
inlinestatic

Sets the simulated network loss/ping settings for this peer.

Parameters
lossSimulated loss, 0.0-1.0
pingMinSimulated minimum ping
pingMaxSimulated max ping

◆ SetPrefabPool()

static void Photon.Bolt.BoltNetwork.SetPrefabPool ( IPrefabPool  pool)
inlinestatic

Sets a custom implementation for pooling prefabs

Parameters
poolThe custom pooling implementation

Example: Setting bolt to use a custom prefab pooling implementation.

public override void BoltStartDone() {
SetPrefabPool(new YourPrefabPool());
}

◆ Shutdown()

static void Photon.Bolt.BoltNetwork.Shutdown ( )
inlinestatic

Shutdown this instance.

◆ ShutdownImmediate()

static void Photon.Bolt.BoltNetwork.ShutdownImmediate ( )
inlinestatic

Shutdowns Bolt Immediately.

◆ UpdateCurrentScene()

static void Photon.Bolt.BoltNetwork.UpdateCurrentScene ( )
inlinestatic

Updates the internal loaded scene information. This is useful if Bolt is not used to manage Scenes and this is done externally by the developer. If the active Scene was changed, this must be invoked in order to signal that the internal data must be updated.

◆ UpdateSceneObjectsLookup()

static void Photon.Bolt.BoltNetwork.UpdateSceneObjectsLookup ( )
inlinestatic

Updates the scene objects for fast lookup.

◆ UpdateSessionList()

static void Photon.Bolt.BoltNetwork.UpdateSessionList ( Map< Guid, UdpSession sessions)
inlinestatic

Updates the session list from an external source

Parameters
sessionsNew sessions list.

Property Documentation

◆ Clients

IEnumerable<BoltConnection> Photon.Bolt.BoltNetwork.Clients
staticget

All clients connected to this host

Example: Disconnecting all current clients.

void DisconnectAllClients() {
foreach(var client in BoltNetwork.clients) {
client.Disconnect();
}
}

◆ Connections

IEnumerable<BoltConnection> Photon.Bolt.BoltNetwork.Connections
staticget

All the connections connected to this host

Example: Terminating all connections.

void DisconnectAll() {
foreach(var connection in BoltNetwork.connections) {
connection.Disconnect();
}
}

◆ CurrentAsyncOperation

AsyncOperation Photon.Bolt.BoltNetwork.CurrentAsyncOperation
staticget

Gets the current async operation.

The current async operation.

◆ CurrentVersion

string Photon.Bolt.BoltNetwork.CurrentVersion
staticget

Gets the current Bolt version as string.

◆ Entities

IEnumerable<BoltEntity> Photon.Bolt.BoltNetwork.Entities
staticget

Returns an IEnumerable list of all Bolt Entities currently loaded into the scene

Example: A post-game method to destroy all minions/npcs in the server simulation.

void PostGameCleanup() {
foreach(var entity in BoltNetwork.Entities) {
if(entity.IsOwner &amp;&amp; entity.StateIs<MinionState>) {
BoltNetwork.Destroy(entity);
}
}
}

◆ Frame

int Photon.Bolt.BoltNetwork.Frame
staticget

The current local simulation frame number

Example: Using the BoltNetwork frame in a loop to recalculate the player path once every 20 frames.

void FixedUpdate() {
if(BoltNetwork.frame % 20) == 0) {
playerMotor.Repath(targetPos);
}
}

◆ FrameAlpha

float Photon.Bolt.BoltNetwork.FrameAlpha
staticget

Normalized value of how much time have passed since the last FixedUpdate

◆ FrameBeginTime

float Photon.Bolt.BoltNetwork.FrameBeginTime
staticget

The time the last fixed update begain, same as Time.fixedTime

◆ FrameDeltaTime

float Photon.Bolt.BoltNetwork.FrameDeltaTime
staticget

The fixed frame delta, same as Time.fixedDeltaTime

Example: How to use frameDeltaTime to translate a player's per-second health regeneration rate into a per-frame value.

protected override void SimulateOwner() {
float hpRegen = BoltNetwork.frameDeltaTime * state.HealthRegen;
state.HP = Mathf.Clamp(state.HP + hpRegen, 0, 100);
}

◆ FramesPerSecond

int Photon.Bolt.BoltNetwork.FramesPerSecond
staticget

How many FixedUpdate frames per second bolt is configured to run

Example: Calculating the number of frames between footsteps from a time interval.

int FootstepFrameInterval(float stepTimeInterval) {
return Mathf.Round(stepTimeInterval / BoltNetwork.framesPerSecond);
}

◆ GlobalObject

GameObject Photon.Bolt.BoltNetwork.GlobalObject
staticget

The global object that all global behaviours will be attached to

Example: The globalObject can be used as a root for attaching new scripts such as GlobalEventListener callbacks.

protected override void SceneLoadLocalDone(string map) {
if(map.Equals("GameScene")) {
BoltNetwork.globalObject.AddComponent<ClientGameCallbacks>();
}
}

◆ IsClient

bool Photon.Bolt.BoltNetwork.IsClient
staticget

Returns true if this host is a client

Example: Implementing a client-side score sheet display to show the scores at the end of a game.

void GameOver(string winTeam) {
if(BoltNetwork.isClient) {
DisplayScoreSheet("Game Over", winTeam + " Team Wins!";
}
}

◆ IsConnected

bool Photon.Bolt.BoltNetwork.IsConnected
staticget

Returns true if this instance is a server or a client with at least one valid connection.

Example: Using the isConnected property to do an automatic reconnect loop.

void Update() {
if(!BoltNetwork.connected &amp;&amp; BoltNetwork.time - lastReconnectTime > 30f) {
BoltNetwork.Connect(serverAddr);
lastReconnectTime = BoltNetwork.time;
}
}

◆ IsDebugMode

bool Photon.Bolt.BoltNetwork.IsDebugMode
staticget

Returns true if Bolt was compiled in debug mode

Example: Showing an FPS and ping counter when in debug mode.

public override void BoltStartDone() {
if(BoltNetwork.isDebugMode) {
PingView.instance.Show();
FPSCounter.instance.Show();
}
}

◆ IsRunning

bool Photon.Bolt.BoltNetwork.IsRunning
staticget

Signal if Bolt is running.

Example: How to use the isRunning property to detect a downtime and restart the server.

void Update() {
if(!BoltNetwork.isRunning &amp;&amp; BoltNetwork.time > lastRestart + 30f) {
RestartServer();
lastRestart = BoltNetwork.time;
}
}

◆ IsServer

bool Photon.Bolt.BoltNetwork.IsServer
staticget

Returns true if this host is a server

Example: Using the isServer property to implement server specific logic such as spawning NPCs after a new map has been generated.

public override void SceneLoadLocalDone(string map) {
GenerateMap();
if(BoltNetwork.isServer)
{
SpawnNPCs();
}
}

◆ IsSinglePlayer

bool Photon.Bolt.BoltNetwork.IsSinglePlayer
staticget

Returns true if this host is running in single player mode.

true if is single player; otherwise, false.

◆ MaxConnections

int? Photon.Bolt.BoltNetwork.MaxConnections
staticget

The max number of client connections to the server

Example: Using the max connections value to enforce server connection limits on an incoming client connection.

public override void ConnectRequest(UdpEndPoint clientAddr)
{
if(BoltNetwork.connections.Count == BoltNetwork.maxConnections)
{
BoltNetwork.Refuse(clientAddr);
return;
}
}

◆ SceneObjects

IEnumerable<BoltEntity> Photon.Bolt.BoltNetwork.SceneObjects
staticget

A list of all BoltEntities in the server simulation

Example: Destroying all player entities using a foreach loop over BoltNetwork.SceneObjects and finding the players with StateIs().

void DestroyAllPlayers()
{
foreach(var entity in BoltNetwork.SceneObjects)
{
if(entity.StateIs<IPlayerState>())
{
BoltNetwork.Destroy(entity.gameObject);
}
}
}

◆ ScopeMode

ScopeMode Photon.Bolt.BoltNetwork.ScopeMode
staticget

The scoping mode active

◆ Server

BoltConnection Photon.Bolt.BoltNetwork.Server
staticget

The server connection

Example: Displaying the current server IP address and port to the client.

void ShowServerEndpoint() {
UdpEndPoint serverEndPoint = BoltNetwork.server.remoteEndPoint;
Message.Show("Current Server", string.Format("({0}:{1}", serverEndPoint.Address, serverEndPoint.Port);
}

◆ ServerFrame

int Photon.Bolt.BoltNetwork.ServerFrame
staticget

On the server this returns the local frame, on a client this returns the currently estimated frame of all server objects we have received

Example: Predicting the next possible fire frame on the client using the estimated serverFrame.

void ClientFireWeapon(PlayerCommand cmd) {
if(weapon.nextFireFrame <= BoltNEtwork.serverFrame) {
state.FireTrigger();
weapon.nextFireFrame = BoltNetwork.serverFrame + weapon.refireRate;
}
}

◆ ServerTime

float Photon.Bolt.BoltNetwork.ServerTime
staticget

The current server simulation time

Example: Using the serverTime property to display a message when the max game time has expired.

void Update() {
if((BoltNetwork.serverTime - gameStartTime >= MAX_GAME_TIME) {
Message.Show("Game Over", "Time Has Expired!");
}
}

◆ SessionList

Map<Guid, UdpSession> Photon.Bolt.BoltNetwork.SessionList
staticget

Gets the list of UdpSession received by the system.

The session list.

◆ Time

float Photon.Bolt.BoltNetwork.Time
staticget

The local time, same as Time.time

Example: Using the time property to periodically play footstep sounds on the client.

void Footsteps() {
if(BoltNetwork.time >= lastFootstep + footstepInterval) {
audio.PlayOneShot(footstepSound);
lastFootstep = BoltNetwork.time;
}
}

◆ UdpSocket

UdpSocket Photon.Bolt.BoltNetwork.UdpSocket
staticget

Gets the current UDP socket.

The UDP socket.

◆ Version

Version Photon.Bolt.BoltNetwork.Version
staticget

The current Photon Bolt assembly version number.

◆ VersionConfiguration

string??? Photon.Bolt.BoltNetwork.VersionConfiguration
staticget

Gets the Bolt Version description.

The Bolt Version description.

◆ VersionInfo

string??? Photon.Bolt.BoltNetwork.VersionInfo
staticget

Extra info of the Current Bolt version.

Photon.Bolt.BoltNetwork.Connect
static void Connect(UdpEndPoint endpoint, IProtocolToken token=null)
Connect to a server using their listening endpoint
Definition: BoltNetwork.Connection.cs:100
Photon.Bolt.BoltNetwork.SetEventFilter
static void SetEventFilter(IEventFilter filter)
Sets bolt to use a filter to accept or reject certain events based on custom filtering
Definition: BoltNetwork.Utils.cs:146
Photon.Bolt.BoltNetwork.SetPrefabPool
static void SetPrefabPool(IPrefabPool pool)
Sets a custom implementation for pooling prefabs
Definition: BoltNetwork.Entity.cs:427
UdpKit
Definition: Connection.cs:6