Atavism Version 2018.1AGIS API

atavism.server.objects
Class MessageRegionTrigger

java.lang.Object
  extended by atavism.server.objects.MessageRegionTrigger
All Implemented Interfaces:
RegionTrigger

public class MessageRegionTrigger
extends java.lang.Object
implements RegionTrigger

Publish a message when object enters or leaves a custom region. Register with WorldManagerPlugin.registerRegionTrigger(String,RegionTrigger).

The trigger has two modes: subject and target. In subject mode, the trigger publishes a SubjectMessage sub-class which will be received by all perceivers of the subject (the player). In target mode, the trigger publishes a TargetMessage sub-class which will apply only to the object itself.

The trigger can add a fixed set of properties to each message. And the properties can be filtered by a set of property exclusions. The message will always have a "regionAction" property set to either "onEnter" or "onLeave" indicating which action triggered the message.

The remaining trigger behavior is controled by custom region properties:


Field Summary
static int SUBJECT_MODE
          Publish a 'subject' message (SubjectMessage sub-class).
static int TARGET_MODE
          Publish a 'targeted' message (TargetMessage sub-class).
 
Constructor Summary
MessageRegionTrigger()
           
MessageRegionTrigger(int mode)
           
MessageRegionTrigger(int mode, java.util.Map<java.lang.String,java.io.Serializable> messageProperties, java.util.Set<java.lang.String> propertyExclusions)
           
 
Method Summary
protected  void configureMessage(Message message, AOObject obj, Region region, java.lang.String action)
           
protected  void copyProperties(java.lang.String propertyNames, java.util.Map<java.lang.String,java.io.Serializable> source, java.util.Map<java.lang.String,java.io.Serializable> destination)
           
 void enter(AOObject obj, Region region)
          Send message when object enters a region.
 java.util.Map<java.lang.String,java.io.Serializable> getMessageProperties()
          Get the additional message properties.
 int getMode()
          Get the trigger mode.
 java.util.Set<java.lang.String> getPropertyExclusions()
          Get the property exclusions.
 void leave(AOObject obj, Region region)
          Send message when object leaves a region.
protected  Message makeMessage(AOObject obj, Region region)
           
 void setMessageProperties(java.util.Map<java.lang.String,java.io.Serializable> messageProperties)
          Set the additional message properties.
 void setMode(int mode)
          Set the trigger mode to TARGET_MODE or SUBJECT_MODE.
 void setPropertyExclusions(java.util.Set<java.lang.String> propertyExclusions)
          Set the property exclusions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TARGET_MODE

public static final int TARGET_MODE
Publish a 'targeted' message (TargetMessage sub-class).

See Also:
Constant Field Values

SUBJECT_MODE

public static final int SUBJECT_MODE
Publish a 'subject' message (SubjectMessage sub-class).

See Also:
Constant Field Values
Constructor Detail

MessageRegionTrigger

public MessageRegionTrigger()

MessageRegionTrigger

public MessageRegionTrigger(int mode)

MessageRegionTrigger

public MessageRegionTrigger(int mode,
                            java.util.Map<java.lang.String,java.io.Serializable> messageProperties,
                            java.util.Set<java.lang.String> propertyExclusions)
Method Detail

getMode

public int getMode()
Get the trigger mode.

Returns:
One of TARGET_MODE or SUBJECT_MODE

setMode

public void setMode(int mode)
Set the trigger mode to TARGET_MODE or SUBJECT_MODE.


getMessageProperties

public java.util.Map<java.lang.String,java.io.Serializable> getMessageProperties()
Get the additional message properties.


setMessageProperties

public void setMessageProperties(java.util.Map<java.lang.String,java.io.Serializable> messageProperties)
Set the additional message properties. These properties will be added to all messages sent by this trigger. The property exclusions do not apply to the additional properties.


getPropertyExclusions

public java.util.Set<java.lang.String> getPropertyExclusions()
Get the property exclusions.


setPropertyExclusions

public void setPropertyExclusions(java.util.Set<java.lang.String> propertyExclusions)
Set the property exclusions. The named properties will be excluded from messages. Useful in combination with messageRegionProperties=ALL or messageObjectProperties=ALL


enter

public void enter(AOObject obj,
                  Region region)
Send message when object enters a region. The message will have a "regionAction" property set to "onEnter".

Specified by:
enter in interface RegionTrigger

leave

public void leave(AOObject obj,
                  Region region)
Send message when object leaves a region. The message will have a "regionAction" property set to "onLeave".

Specified by:
leave in interface RegionTrigger

makeMessage

protected Message makeMessage(AOObject obj,
                              Region region)

configureMessage

protected void configureMessage(Message message,
                                AOObject obj,
                                Region region,
                                java.lang.String action)

copyProperties

protected void copyProperties(java.lang.String propertyNames,
                              java.util.Map<java.lang.String,java.io.Serializable> source,
                              java.util.Map<java.lang.String,java.io.Serializable> destination)


Copyright © 2018 Dragonsan Studios Sp. z o.o.