atavism.server.objects
Class ObjectTracker
java.lang.Object
atavism.server.objects.ObjectTracker
- All Implemented Interfaces:
- MessageCallback, MessageDispatch
public class ObjectTracker
- extends java.lang.Object
- implements MessageCallback, MessageDispatch
Method Summary |
void |
addAggroRadius(OID oid,
OID target,
java.lang.Integer reactionRadius)
|
void |
addLocalObject(OID oid,
java.lang.Integer reactionRadius)
|
void |
addReactionRadius(OID oid,
java.lang.Integer reactionRadius)
|
void |
dispatchMessage(Message message,
int flags,
MessageCallback callback)
Dispatch message to queue or thread pool. |
OID |
getInstanceOid()
|
java.util.List<OID> |
getOidsInRadius(OID oid)
|
void |
handleMessage(Message msg,
int flags)
Handle message. |
protected void |
handlePerception(PerceptionMessage perceptionMessage)
|
boolean |
hasLocalObject(java.lang.Long oid)
|
protected boolean |
maybeAddRemoteObject(PerceptionMessage.ObjectNote objectNote)
|
protected void |
maybeRemoveRemoteObject(OID subjectOid,
PerceptionMessage.ObjectNote objectNote,
OID targetOid)
|
void |
removeAggroRadius(OID oid,
OID target)
|
boolean |
removeLocalObject(OID oid)
|
void |
removeReactionRadius(OID oid)
|
protected boolean |
removeRemoteObject(OID objOid,
OID oid,
java.util.List<OID> trackersToRemove)
|
void |
updateEntity(EntityWithWorldNode ewwn)
Checks the distance between the tracker and the entity in question to
determine whether they are entering or leaving the reaction or aggro
radius. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
namespace
protected Namespace namespace
instanceOid
protected OID instanceOid
entityFactory
protected EntityWithWorldNodeFactory entityFactory
hystericalMargin
protected float hystericalMargin
notifyCallback
protected ObjectTracker.NotifyReactionRadiusCallback notifyCallback
remoteObjectFilter
protected ObjectTracker.RemoteObjectFilter remoteObjectFilter
localObjects
protected java.util.Set<OID> localObjects
- Local objects are perceivers; remote objects are the objects that are
perceived by perceivers
trackMap
protected java.util.Map<OID,ObjectTracker.Entry> trackMap
reactionRadiusMap
protected java.util.Map<OID,ObjectTracker.NotifyData> reactionRadiusMap
perceptionFilter
protected ObjectTracker.TrackerFilter perceptionFilter
perceptionSubId
protected long perceptionSubId
lock
protected java.util.concurrent.locks.Lock lock
MSG_TYPE_NOTIFY_REACTION_RADIUS
public static final MessageType MSG_TYPE_NOTIFY_REACTION_RADIUS
MSG_TYPE_NOTIFY_AGGRO_RADIUS
public static final MessageType MSG_TYPE_NOTIFY_AGGRO_RADIUS
ObjectTracker
public ObjectTracker(Namespace namespace,
OID oid,
EntityWithWorldNodeFactory entityFactory,
java.util.Collection<ObjectType> subjectTypes)
ObjectTracker
public ObjectTracker(Namespace namespace,
OID instanceOid,
EntityWithWorldNodeFactory entityFactory,
float hystericalMargin,
ObjectTracker.NotifyReactionRadiusCallback notifyCallback,
ObjectTracker.RemoteObjectFilter remoteObjectFilter)
getInstanceOid
public OID getInstanceOid()
addLocalObject
public void addLocalObject(OID oid,
java.lang.Integer reactionRadius)
hasLocalObject
public boolean hasLocalObject(java.lang.Long oid)
addReactionRadius
public void addReactionRadius(OID oid,
java.lang.Integer reactionRadius)
addAggroRadius
public void addAggroRadius(OID oid,
OID target,
java.lang.Integer reactionRadius)
removeReactionRadius
public void removeReactionRadius(OID oid)
removeAggroRadius
public void removeAggroRadius(OID oid,
OID target)
removeLocalObject
public boolean removeLocalObject(OID oid)
maybeAddRemoteObject
protected boolean maybeAddRemoteObject(PerceptionMessage.ObjectNote objectNote)
getOidsInRadius
public java.util.List<OID> getOidsInRadius(OID oid)
removeRemoteObject
protected boolean removeRemoteObject(OID objOid,
OID oid,
java.util.List<OID> trackersToRemove)
updateEntity
public void updateEntity(EntityWithWorldNode ewwn)
- Checks the distance between the tracker and the entity in question to
determine whether they are entering or leaving the reaction or aggro
radius. Iterates through each reactionRadiusMap entry to determine if the
moving creature has is listed.
- Parameters:
ewwn
-
dispatchMessage
public void dispatchMessage(Message message,
int flags,
MessageCallback callback)
- Description copied from interface:
MessageDispatch
- Dispatch message to queue or thread pool. Implementations should
pass the
flags
through unaltered.
- Specified by:
dispatchMessage
in interface MessageDispatch
- Parameters:
message
- Message sent from other agent.flags
- Bitwise OR of MessageCallback.NO_FLAGS
,
MessageCallback.RESPONSE_EXPECTED
callback
- Callback to handle the message (currently,
always the same as 'this').
handlePerception
protected void handlePerception(PerceptionMessage perceptionMessage)
maybeRemoveRemoteObject
protected void maybeRemoveRemoteObject(OID subjectOid,
PerceptionMessage.ObjectNote objectNote,
OID targetOid)
handleMessage
public void handleMessage(Message msg,
int flags)
- Description copied from interface:
MessageCallback
- Handle message.
- Specified by:
handleMessage
in interface MessageCallback
- Parameters:
msg
- Message sent from other agent.flags
- Bitwise OR of MessageCallback.NO_FLAGS
, MessageCallback.RESPONSE_EXPECTED
.