Drag[en]gine Script Module DragonScript
1.23
|
Behavior element behavior adding network state support. More...
Classes | |
class | BlockListenerFactory |
Factory creating listeners using block. More... | |
class | DataValue |
Value listener for data type values. More... | |
class | DefaultListener |
Default implementation of behavior instance listener. More... | |
class | DefaultMessageListener |
Default implementation of message listener. More... | |
class | DefaultValueListener |
Default implementation of value listener. More... | |
class | DVectorValue |
Value listener for DVector type values. More... | |
class | FloatValue |
Value listener for float type values. More... | |
class | Instance |
Behavior instance. More... | |
class | IntegerValue |
Value listener for integer type values. More... | |
interface | Listener |
Listener for behavior instance events. More... | |
interface | ListenerFactory |
Factory creating listeners. More... | |
interface | MessageListener |
Message listener. More... | |
class | Point3Value |
Value listener for Point3 type values. More... | |
class | PointValue |
Value listener for Point type values. More... | |
class | QuaternionValue |
Value listener for Quaternion type values. More... | |
class | StringValue |
Value listener for string type values. More... | |
interface | ValueListener |
Value listener. More... | |
class | Vector2Value |
Value listener for Vector2 type values. More... | |
class | VectorValue |
Value listener for Vector type values. More... | |
Public Member Functions | |
void | addListenerFactory (Block blockFactory) |
Add listener factory using block. More... | |
void | addListenerFactory (ListenerFactory factory) |
Add listener factory. More... | |
ECBehaviorInstance | createInstance (BehaviorElement element) |
Create Behavior instance. More... | |
void | dispose () |
Dispose of behavior. More... | |
void | forEachListenerFactory (Block ablock) |
Visit listener factories with block with argument ListenerFactory. More... | |
ConnectionTracker | getConnectionTracker () |
Connection tracker. More... | |
byte | getMessageCode () |
Message code to use. More... | |
NetworkStateTracker | getNetworkStateTracker () |
Network state tracker. More... | |
byte | getRequestLinkCode () |
Request link code to use. More... | |
Instance | instance (BehaviorElement element) |
Get instance in element from owner element class. More... | |
ECBehaviorNetworkState | new (BehaviorElementClass eclass, byte requestLinkCode, byte messageCode) |
Create behavior element class. More... | |
ECBehaviorNetworkState | new (BehaviorElementClass eclass, byte requestLinkCode, byte messageCode, ConnectionTracker connectionTracker, NetworkStateTracker networkStateTracker) |
void | setConnectionTracker (ConnectionTracker connectionTracker) |
Set connection tracker. More... | |
void | setMessageCode (byte code) |
Set message code to use. More... | |
void | setNetworkStateTracker (NetworkStateTracker networkStateTracker) |
Set network state tracker. More... | |
void | setRequestLinkCode (byte code) |
Set request link code to use. More... | |
Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
void | assignInstanceIndex (int instanceIndex) |
Assign instance index. More... | |
String | getBehaviorID () |
Unique identifier of behavior. More... | |
String | getID () |
Identifier. More... | |
int | getInstanceIndex () |
Instance index. More... | |
void | loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance) |
Load instance data of another behavior. More... | |
bool | supportsBehaviorID (String identifier) |
Behavior supports loading instance data of another behavior. More... | |
Static Public Member Functions | |
static bool | createAndAddFromLinkRequest (Connection connection, NetworkState state, FileReader reader, GameWorld gameWorld) |
Create element from link request message and add it to game world. More... | |
static bool | createAndAddFromLinkRequest (Connection connection, NetworkState state, FileReader reader, GameWorld gameWorld, ElementClassList elementClassList) |
static ECBehaviorNetworkState.Instance | createFromLinkRequest (Connection connection, NetworkState state, FileReader reader) |
Create element from link request message. More... | |
static ECBehaviorNetworkState.Instance | createFromLinkRequest (Connection connection, NetworkState state, FileReader reader, ElementClassList elementClassList) |
static ECBehaviorNetworkState | getBehaviorIn (BehaviorElementClass eclass) |
Get behavior in element class or null if absent. More... | |
static Instance | getInstanceIn (BehaviorElement element) |
Get instance in element or null if absent. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
DefaultECBehavior | new (BehaviorElementClass eclass) |
Create default composeable behavior with empty identifier. More... | |
DefaultECBehavior | new (BehaviorElementClass eclass, String id) |
Create default composeable behavior. More... | |
void | setBehaviorID (String identifier) |
Set behavior identifier. More... | |
void | useClassNameAsBehaviorID () |
Set behavior identifier to "<class-name>:<identifier>". More... | |
void | useFullyQualifiedClassNameAsBehaviorID () |
Set behavior identifier to "<fully-qualified-class-name>:<identifier>". More... | |
Behavior element behavior adding network state support.
The behavior is only active during creation time the StubElement contains Connection instance. Behavior can not be attached to a connection later.
Network states allow elements to link their state to a network state on a remote host. This behavior can operate in two modes depending on how the element is created.
If the element is created on the local host the owner of this behavior is the master state. As such the master state is changed with the linked state on the remote side updated by the Network Module to match. The behavior creates a NetworkState resources and links it to the server network state during init().
If the element is requested to be created by the server the NetworkState is created by the Network Module and is handed over to the game using ConnectionListener.linkState(). In this case the behavior uses the provided network state resource and and acts as the slave. The server side changes the state and this behavior receives update notifications.
In both situations other behaviors add values to track. If this state is the server state they apply changes to the value if their state changes. If this state is the client state they will be notified if the remote side modifies the value. Such behaviors have to add a listener during constructor time implementing Listener.addValues() to add the values at init time in the correct time. Doing this anywhere else likely results in problems.
To enable network state support add ECBehaviorNetworkState then add behaviors designed to add and maintain network state values. A typical example of such a behaviors are ECBehaviorNStateGeometry or ECBehaviorNStateLocomotion.
No element class properties are added.
This behavior does not require the element class to be persistable (setPersistable).
This behavior can be present only once in the element class.
void Dragengine.Scenery.ECBehaviorNetworkState.addListenerFactory | ( | Block | blockFactory | ) |
void Dragengine.Scenery.ECBehaviorNetworkState.addListenerFactory | ( | ListenerFactory | factory | ) |
Add listener factory.
|
static |
Create element from link request message and add it to game world.
Call this after reading the request link code from the network message reader. This method does the following:
The caller is not responsible for the behavior element behind the returned NetworkState since the GameWorld owns it now. This is the most common function call to use.
A typical use looks like this:
|
static |
|
static |
Create element from link request message.
Call this after reading the request link code from the network message reader. This method does the following:
The caller is responsible for the behavior element owning the returned instance. Add it to a game world or store it in a place where it is properly disposed off later. Not doing so will causing memory leaks. Typical use case is to create a player actor for spawning later. For most other situations createAndAddFromLinkRequest() is better.
A typical use looks like this:
|
static |
ECBehaviorInstance Dragengine.Scenery.ECBehaviorNetworkState.createInstance | ( | BehaviorElement | element | ) |
Create Behavior instance.
Implements Dragengine.Scenery.ECBehavior.
void Dragengine.Scenery.ECBehaviorNetworkState.dispose | ( | ) |
Dispose of behavior.
Reimplemented from Dragengine.Scenery.DefaultECBehavior.
void Dragengine.Scenery.ECBehaviorNetworkState.forEachListenerFactory | ( | Block | ablock | ) |
Visit listener factories with block with argument ListenerFactory.
|
static |
Get behavior in element class or null if absent.
Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorComponent.
ConnectionTracker Dragengine.Scenery.ECBehaviorNetworkState.getConnectionTracker | ( | ) |
Connection tracker.
|
static |
Get instance in element or null if absent.
Use this method to check if a particular BehaviorElement contains a behavior instance of type ECBehaviorNetworkState.Instance . If more than one instance is present returns the first instance.
byte Dragengine.Scenery.ECBehaviorNetworkState.getMessageCode | ( | ) |
Message code to use.
NetworkStateTracker Dragengine.Scenery.ECBehaviorNetworkState.getNetworkStateTracker | ( | ) |
Network state tracker.
byte Dragengine.Scenery.ECBehaviorNetworkState.getRequestLinkCode | ( | ) |
Request link code to use.
Instance Dragengine.Scenery.ECBehaviorNetworkState.instance | ( | BehaviorElement | element | ) |
Get instance in element from owner element class.
ECBehaviorNetworkState Dragengine.Scenery.ECBehaviorNetworkState.new | ( | BehaviorElementClass | eclass, |
byte | requestLinkCode, | ||
byte | messageCode | ||
) |
Create behavior element class.
ECBehaviorNetworkState Dragengine.Scenery.ECBehaviorNetworkState.new | ( | BehaviorElementClass | eclass, |
byte | requestLinkCode, | ||
byte | messageCode, | ||
ConnectionTracker | connectionTracker, | ||
NetworkStateTracker | networkStateTracker | ||
) |
void Dragengine.Scenery.ECBehaviorNetworkState.setConnectionTracker | ( | ConnectionTracker | connectionTracker | ) |
Set connection tracker.
void Dragengine.Scenery.ECBehaviorNetworkState.setMessageCode | ( | byte | code | ) |
Set message code to use.
void Dragengine.Scenery.ECBehaviorNetworkState.setNetworkStateTracker | ( | NetworkStateTracker | networkStateTracker | ) |
Set network state tracker.
void Dragengine.Scenery.ECBehaviorNetworkState.setRequestLinkCode | ( | byte | code | ) |
Set request link code to use.