Photon Bolt Engine API
1.3
|
virtual void | Attached () |
| Invoked when Bolt is aware of this entity and all internal state has been setup More...
|
|
virtual void | ControlGained () |
| Invoked when you gain control of this entity More...
|
|
virtual void | ControlLost () |
| Invoked when you lost control of this entity More...
|
|
virtual void | Detached () |
| Invoked when this entity is removed from Bolt's awareness More...
|
|
virtual void | ExecuteCommand (Bolt.Command command, bool resetState) |
| Invoked on both the owner and controller to execute a command More...
|
|
sealed override void | Initialized () |
| Invoked when the entity has been initialized, before Attached More...
|
|
virtual bool | LocalAndRemoteResultEqual (Bolt.Command command) |
| Utility callback used to signal to the user that this entity is about to be reset by a Command Result. Using this method, you are able to signal Bolt that the Result of the Command is equaled the current state of your entity, skipping all the recomputation needed when a Reset command arrives. More...
|
|
virtual void | MissingCommand (Bolt.Command previous) |
| Invoked on the owner when a remote connection is controlling this entity but we have not received any command for the current simulation frame. More...
|
|
virtual void | SimulateController () |
| Invoked each simulation step on the controller More...
|
|
virtual void | SimulateOwner () |
| Invoked each simulation step on the owner More...
|
|
◆ Attached()
virtual void Photon.Bolt.EntityBehaviour.Attached |
( |
| ) |
|
|
inlinevirtualinherited |
Invoked when Bolt is aware of this entity and all internal state has been setup
Example: Overriding the Attached()
method to add state change callbacks to the newly valid state.
state.AddCallback("name", NameChanged);
state.AddCallback("team", TeamChanged);
}
◆ ControlGained()
virtual void Photon.Bolt.EntityBehaviour.ControlGained |
( |
| ) |
|
|
inlinevirtualinherited |
Invoked when you gain control of this entity
Example: Using the ControlGained()
callback to set up a GameCamera
and MiniMap
to focus on this entity.
GameCamera.instance.AddFollowTarget(this.transform);
MiniMap.instance.ControlGained(this.entity);
}
◆ ControlLost()
virtual void Photon.Bolt.EntityBehaviour.ControlLost |
( |
| ) |
|
|
inlinevirtualinherited |
Invoked when you lost control of this entity
Example: Using the ControlLost()
callback to remove the focus of a GameCamera
and MiniMap
.
GameCamera.instance.RemoveFollowTarget();
MiniMap.instance.ControlLost(this.entity);
}
◆ Detached()
virtual void Photon.Bolt.EntityBehaviour.Detached |
( |
| ) |
|
|
inlinevirtualinherited |
Invoked when this entity is removed from Bolt's awareness
Example: Notifying the game minimap to remove the entity upon detaching from the simulation.
MiniMap.instance.RemoveKnownPlayer(this.entity);
{
◆ ExecuteCommand()
virtual void Photon.Bolt.EntityBehaviour.ExecuteCommand |
( |
Bolt.Command |
command, |
|
|
bool |
resetState |
|
) |
| |
|
inlinevirtualinherited |
Invoked on both the owner and controller to execute a command
- Parameters
-
command | The command to execute |
resetState | Indicates if we should reset the state of the local motor or not |
Example: Executing a simple WASD movement command. On the client this method can be called multiple times per fixed frame, beginning with a reset to the last confirmed state (resetState == true), and then again for each unverified input command in the queue (resetState == false);
Use the cmd.isFirstExecution property to do any type of one-shot behaviour such as playing sound or animations. This will prevent it from being called each time the input is replayed on the client.
Remember to create and compile a Command asset before using this method!
public override ExecuteCommand(Bolt.Command command,
bool resetState) {
WASDCommand cmd = (WASDCommand)command;
if(resetState) {
motor.SetState(cmd.Result.position);
}
else {
cmd.Result.position = motor.Move(cmd.Input.forward, cmd.Input.backward, cmd.Input.left, cmd.Input.right);
if (cmd.IsFirstExecution) {
AnimatePlayer(cmd);
}
}
}
◆ Initialized()
sealed override void Photon.Bolt.Internal.EntityEventListenerBase.Initialized |
( |
| ) |
|
|
inlinevirtual |
Invoked when the entity has been initialized, before Attached
Example: Notifying a MiniMap
class to draw this gameObject by overriding the Initialized()
method.
MiniMap.instance.AddKnownPlayer(this.gameObject);
}
Reimplemented from Photon.Bolt.EntityBehaviour.
◆ LocalAndRemoteResultEqual()
virtual bool Photon.Bolt.EntityBehaviour.LocalAndRemoteResultEqual |
( |
Bolt.Command |
command | ) |
|
|
inlinevirtualinherited |
Utility callback used to signal to the user that this entity is about to be reset by a Command Result. Using this method, you are able to signal Bolt that the Result of the Command is equaled the current state of your entity, skipping all the recomputation needed when a Reset command arrives.
- Parameters
-
command | The Command with ResetState flag as true for ExecuteCommand callback |
- Returns
- True if you want to not recompute everything when local and remote Result match. False otherwise (default always recompute)
◆ MissingCommand()
virtual void Photon.Bolt.EntityBehaviour.MissingCommand |
( |
Bolt.Command |
previous | ) |
|
|
inlinevirtualinherited |
Invoked on the owner when a remote connection is controlling this entity but we have not received any command for the current simulation frame.
- Parameters
-
previous | The last valid command received |
Example: Handling missing input commands by using the last received input command to continue moving in the same direction.
{
WASDCommand cmd = (WASDCommand)command;
cmd.Result.position motor.Move(cmd.Input.forward, cmd.Input.backward, cmd.Input.left, cmd.Input.right);
}
◆ SimulateController()
virtual void Photon.Bolt.EntityBehaviour.SimulateController |
( |
| ) |
|
|
inlinevirtualinherited |
Invoked each simulation step on the controller
Example: Creating a simple WASD-style movement input command and adding it to the queue of inputs. One input command should be added to the queue per execution and remember to create and compile a Command asset before using this method!
bool forward;
bool backward;
bool left;
bool right;
IPlayerCommandInput input = PlayerCommand.Create();
PollKeys();
input.forward = forward;
input.backward = backward;
input.left = left;
input.right = right;
}
◆ SimulateOwner()
virtual void Photon.Bolt.EntityBehaviour.SimulateOwner |
( |
| ) |
|
|
inlinevirtualinherited |
Invoked each simulation step on the owner
Example: Implementing an authoritative health regeneration update every 10th frame. Also fires the DeathTrigger()
on the state if health falls below zero.
if(state.alive && state.Health.Current <= 0) {
state.Health.alive = false;
state.DeathTrigger();
}
else if(state.alive && (BoltNetwork.frame % 10) == 0)
{
state.Health.Current = Mathf.Clamp (state.Health.Current + (state.Health.RegenPer10 * BoltNetwork.frameDeltaTime),
0, state.Health.Max);
}
}
◆ entity
The entity for this behaviour
Use the entity
property to access the internal BoltEntity
of the gameObject that this script is attached to.
Example: Passing the entity
of this gameObject to a MiniMap
, giving it the position, facing direction and the entity state (such as team, alive/dead, hostile, etc).
public class PlayerController : Bolt.EntityBehaviour {
GameCamera.instance.AddFollowTarget(this.transform);
MiniMap.instance.SetControlledPlayer(this.entity);
}
}
bool QueueInput(INetworkCommandData data, bool force=false)
Queue an input data on this entity for execution. This is called on a client which is controlling a p...
Definition: BoltEntity.cs:852
sealed override void Initialized()
Invoked when the entity has been initialized, before Attached
Definition: EntityEventListener.cs:6
virtual void MissingCommand(Bolt.Command previous)
Invoked on the owner when a remote connection is controlling this entity but we have not received any...
Definition: EntityBehaviour.cs:272
BoltEntity entity
The entity for this behaviour
Definition: EntityBehaviour.cs:93
virtual void Detached()
Invoked when this entity is removed from Bolt's awareness
Definition: EntityBehaviour.cs:171
virtual void ControlGained()
Invoked when you gain control of this entity
Definition: EntityBehaviour.cs:239
virtual void Attached()
Invoked when Bolt is aware of this entity and all internal state has been setup
Definition: EntityBehaviour.cs:157
virtual void SimulateOwner()
Invoked each simulation step on the owner
Definition: EntityBehaviour.cs:195
virtual void ControlLost()
Invoked when you lost control of this entity
Definition: EntityBehaviour.cs:254
virtual void SimulateController()
Invoked each simulation step on the controller
Definition: EntityBehaviour.cs:224
virtual void ExecuteCommand(Bolt.Command command, bool resetState)
Invoked on both the owner and controller to execute a command
Definition: EntityBehaviour.cs:304