Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.ECBehaviorNetworkState.Instance Class Reference

Behavior instance. More...

Inheritance diagram for Dragengine.Scenery.ECBehaviorNetworkState.Instance:
Dragengine.Scenery.DefaultECBehaviorInstance Dragengine.Scenery.ECBehaviorInstance

Classes

class  LinkStateListener
 Link state if connection is added. More...
class  StateUpdateListener
 State update listener. More...

Public Member Functions

void addListener (Listener listener)
 Add listener.
int addMessage (MessageListener listener)
 Add message listener.
int addValue (NetworkStateValueType type, NetworkStateValueFormat format, ValueListener listener)
 Add value.
void dispose ()
 Dispose of composeable instance.
Connection getConnection ()
 Connection to server or null if not connected.
ConnectionTracker getConnectionTracker ()
 Connection tracker or null if not connected.
ECBehaviorNetworkState getECBehavior ()
 Behavior.
bool getIsServer ()
 Network state is the server state.
NetworkState getNetworkState ()
 Network state or null if not tracked.
NetworkStateTracker getNetworkStateTracker ()
 Network state tracker or null if not connected.
bool getReadOnly ()
 Network state is read only.
void init (StubElement stub)
 Initialize element from stub.
void linkState (Connection connection)
 Link state to connection if server.
void linkState (Connection connection, bool readOnly)
 Link state to connection if server.
void linkStateAllConnections ()
 Link state to all tracked connections if server.
void messageReceived (Connection connection, FileReader message)
 Process message received using ECBehaviorNetworkState.getMessageCode() .
Instance new (ECBehaviorNetworkState ecbehavior, BehaviorElement element)
 Create element.
void onStateValueChanged (int value)
 State value changed on the remote side.
void readFromLinkMessage (FileReader reader)
 Call readFromLinkMessage for all listeners.
void removeListener (Listener listener)
 Remove listener.
void sendMessage (int message, NetworkMessage content, int maxDelay)
 Send unreliable message.
void sendReliableMessage (int message, NetworkMessage content)
 Send reliable message.
void setMessageListener (int message, ValueListener listener)
 Set listener for message.
void setReadOnly (bool readOnly)
 Set if network state is read only.
void setValueListener (int value, ValueListener listener)
 Set listener for value.
void writeRequestLinkMessage (StubElement stub, Connection connection, FileWriter writer)
 Create network message to request linking state with server.
Public Member Functions inherited from Dragengine.Scenery.DefaultECBehaviorInstance
void addToGameWorld ()
 Add element to game world.
void attachToParent (Element parent)
 Attach element to object set by the mapper in the IGDE World Editor.
void enterFrame ()
 Frame update started.
void geometryChanged ()
 Position or orientation changed.
BehaviorElement getElement ()
 Behavior element to apply behavior to.
int getInstanceIndex ()
 Behavior instance index.
DefaultECBehaviorInstance new (BehaviorElement element)
 Create default composeable instance.
void postThink (float elapsed)
 Post thinking after physics processing is finished.
void readFromFile (PersistencyEnvironment env, FileReader reader)
 Read behavior instance from file.
void removeFromGameWorld ()
 Remove element from game world.
bool requiresEnterFrame ()
 Behavior instance requires enterFrame() to be called.
bool requiresThink ()
 Behavior instance requires think() to be called.
void stateChanged ()
 State changed (visble, touchable).
void think (float elapsed)
 Think about what to do for the next frame update.
void writeToFile (PersistencyEnvironment env, FileWriter writer)
 Write behavior instance to file.

Protected Member Functions

NetworkMessage createMessage (int message, NetworkMessage content)
 Create message to send.
Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehaviorInstance
void setRequiresEnterFrame (bool required)
 Set if behavior instance requires enterFrame() to be called.
void setRequiresThink (bool required)
 Set if behavior instance requires think() to be called.

Additional Inherited Members

Public Attributes inherited from Dragengine.Scenery.DefaultECBehaviorInstance
BehaviorElement pElement
int pInstanceIndex
bool pRequiresEnterFrame
bool pRequiresThink

Detailed Description

Behavior instance.

Member Function Documentation

◆ addListener()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.addListener ( Listener listener)

Add listener.

◆ addMessage()

int Dragengine.Scenery.ECBehaviorNetworkState.Instance.addMessage ( MessageListener listener)

Add message listener.

Warning
Make sure the element class on the local and remote side add messages in the exact same order.
Parameters
listenerListener called if message is received.
Returns
index of message to use to send message.

◆ addValue()

int Dragengine.Scenery.ECBehaviorNetworkState.Instance.addValue ( NetworkStateValueType type,
NetworkStateValueFormat format,
ValueListener listener )

Add value.

If no network state is present this function does nothing and returns -1 . It is thus safe to try adding a value if this behavior is detected. Network state support has then to be enabled only if addValue() returns anything else but -1.

Warning
Call this method only in response to Listener.addValues()
Make sure the element class on the local and remote side add values in the exact same order with the exact same type and format.
Parameters
typeType of value.
formatFormat of value. Use null for NetworkStateValueType.string and NetworkStateValueType.data
listenerListener called if value changes on remote side.
Returns
index of value in the network state or -1 if there is no network state.

References new().

Referenced by dispose(), getIsServer(), linkState(), and Dragengine.Scenery.ECBehaviorNetworkState.Instance.LinkStateListener.new().

◆ createMessage()

NetworkMessage Dragengine.Scenery.ECBehaviorNetworkState.Instance.createMessage ( int message,
NetworkMessage content )
protected

Create message to send.

◆ dispose()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.dispose ( )

◆ getConnection()

Connection Dragengine.Scenery.ECBehaviorNetworkState.Instance.getConnection ( )

Connection to server or null if not connected.

References getReadOnly().

◆ getConnectionTracker()

ConnectionTracker Dragengine.Scenery.ECBehaviorNetworkState.Instance.getConnectionTracker ( )

Connection tracker or null if not connected.

Referenced by sendReliableMessage().

◆ getECBehavior()

ECBehaviorNetworkState Dragengine.Scenery.ECBehaviorNetworkState.Instance.getECBehavior ( )

Behavior.

◆ getIsServer()

bool Dragengine.Scenery.ECBehaviorNetworkState.Instance.getIsServer ( )

Network state is the server state.

References addValue(), getNetworkState(), Dragengine.Scenery.ECBehaviorNetworkState.instance(), and new().

◆ getNetworkState()

◆ getNetworkStateTracker()

NetworkStateTracker Dragengine.Scenery.ECBehaviorNetworkState.Instance.getNetworkStateTracker ( )

Network state tracker or null if not connected.

References getNetworkState().

Referenced by removeListener().

◆ getReadOnly()

bool Dragengine.Scenery.ECBehaviorNetworkState.Instance.getReadOnly ( )

Network state is read only.

Usually reflects the read-only state of the resource network state but can be changed by scripts (typically server side) to turn the behavior read-only. This is typically the case for network states belonging to a client player which is changed by the client player not the server.

If true behaviors must not change state values while running. Otherwise strange effects can happen. If false behaviors can change state values while updating.

Referenced by getConnection(), readFromLinkMessage(), setReadOnly(), and Dragengine.Scenery.ECBehaviorNetworkState.Instance.StateUpdateListener.stateValueChanged().

◆ init()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.init ( StubElement stub)

Initialize element from stub.

Reimplemented from Dragengine.Scenery.DefaultECBehaviorInstance.

◆ linkState() [1/2]

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.linkState ( Connection connection)

Link state to connection if server.

Same as calling linkState(Connection,bool) with the result of calling Listener.writableLink() on all listeners.

References addValue(), Dragengine.Scenery.ECBehaviorNetworkState.instance(), and new().

Referenced by onStateValueChanged().

◆ linkState() [2/2]

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.linkState ( Connection connection,
bool readOnly )

Link state to connection if server.

Calls Listener.prepareLinkState() on listeners to allow modify link request message.

References getNetworkState().

◆ linkStateAllConnections()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.linkStateAllConnections ( )

Link state to all tracked connections if server.

Links state for all connections in ConnectionTracker. Calls linkState(Connection) for each tracked connection.

◆ messageReceived()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.messageReceived ( Connection connection,
FileReader message )

Process message received using ECBehaviorNetworkState.getMessageCode() .

◆ new()

Instance Dragengine.Scenery.ECBehaviorNetworkState.Instance.new ( ECBehaviorNetworkState ecbehavior,
BehaviorElement element )

◆ onStateValueChanged()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.onStateValueChanged ( int value)

State value changed on the remote side.

Called by StateUpdateListener only.

References Dragengine.Scenery.ECBehaviorNetworkState.instance(), linkState(), and new().

◆ readFromLinkMessage()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.readFromLinkMessage ( FileReader reader)

Call readFromLinkMessage for all listeners.

References getNetworkState(), and getReadOnly().

◆ removeListener()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.removeListener ( Listener listener)

Remove listener.

References getNetworkStateTracker().

◆ sendMessage()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.sendMessage ( int message,
NetworkMessage content,
int maxDelay )

Send unreliable message.

Send message with a maximum delay in milliseconds before giving up.

◆ sendReliableMessage()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.sendReliableMessage ( int message,
NetworkMessage content )

Send reliable message.

References getConnectionTracker().

◆ setMessageListener()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.setMessageListener ( int message,
ValueListener listener )

Set listener for message.

◆ setReadOnly()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.setReadOnly ( bool readOnly)

Set if network state is read only.

Usually reflects the read-only state of the resource network state but can be changed by scripts (typically server side) to turn the behavior read-only. This is typically the case for network states belonging to a client player which is changed by the client player not the server.

If true behaviors must not change state values while running. Otherwise strange effects can happen. If false behaviors can change state values while updating.

References getNetworkState(), and getReadOnly().

◆ setValueListener()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.setValueListener ( int value,
ValueListener listener )

Set listener for value.

References new().

◆ writeRequestLinkMessage()

void Dragengine.Scenery.ECBehaviorNetworkState.Instance.writeRequestLinkMessage ( StubElement stub,
Connection connection,
FileWriter writer )

Create network message to request linking state with server.

Create message by writing 8-bit code to message followed by stub content using StubElement.writeToFile().


The documentation for this class was generated from the following file: