public class ObjectTracker extends java.lang.Object implements MessageCallback, MessageDispatch
Modifier and Type | Class and Description |
---|---|
protected class |
ObjectTracker.Entry |
static class |
ObjectTracker.NotifyAggroRadiusMessage |
protected class |
ObjectTracker.NotifyData |
static interface |
ObjectTracker.NotifyReactionRadiusCallback |
static class |
ObjectTracker.NotifyReactionRadiusMessage |
static interface |
ObjectTracker.RemoteObjectFilter
A filter callback used to determine if a remote object should be tracked.
|
static class |
ObjectTracker.TrackerFilter |
Modifier and Type | Field and Description |
---|---|
protected EntityWithWorldNodeFactory |
entityFactory |
protected float |
hystericalMargin |
protected OID |
instanceOid |
protected java.util.Set<OID> |
localObjects
Local objects are perceivers; remote objects are the objects that are perceived by perceivers
|
protected java.util.concurrent.locks.Lock |
lock |
static MessageType |
MSG_TYPE_NOTIFY_AGGRO_RADIUS |
static MessageType |
MSG_TYPE_NOTIFY_REACTION_RADIUS |
protected Namespace |
namespace |
protected ObjectTracker.NotifyReactionRadiusCallback |
notifyCallback |
protected ObjectTracker.TrackerFilter |
perceptionFilter |
protected long |
perceptionSubId |
protected java.util.Map<OID,ObjectTracker.NotifyData> |
reactionRadiusMap |
protected ObjectTracker.RemoteObjectFilter |
remoteObjectFilter |
protected java.util.Map<OID,ObjectTracker.Entry> |
trackMap |
NO_FLAGS, RESPONSE_EXPECTED
Constructor and Description |
---|
ObjectTracker(Namespace namespace,
OID oid,
EntityWithWorldNodeFactory entityFactory,
java.util.Collection<ObjectType> subjectTypes) |
ObjectTracker(Namespace namespace,
OID instanceOid,
EntityWithWorldNodeFactory entityFactory,
float hystericalMargin,
ObjectTracker.NotifyReactionRadiusCallback notifyCallback,
ObjectTracker.RemoteObjectFilter remoteObjectFilter) |
Modifier and Type | Method and Description |
---|---|
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.
|
protected Namespace namespace
protected OID instanceOid
protected EntityWithWorldNodeFactory entityFactory
protected float hystericalMargin
protected ObjectTracker.NotifyReactionRadiusCallback notifyCallback
protected ObjectTracker.RemoteObjectFilter remoteObjectFilter
protected java.util.Set<OID> localObjects
protected java.util.Map<OID,ObjectTracker.Entry> trackMap
protected java.util.Map<OID,ObjectTracker.NotifyData> reactionRadiusMap
protected ObjectTracker.TrackerFilter perceptionFilter
protected long perceptionSubId
protected java.util.concurrent.locks.Lock lock
public static final MessageType MSG_TYPE_NOTIFY_REACTION_RADIUS
public static final MessageType MSG_TYPE_NOTIFY_AGGRO_RADIUS
public ObjectTracker(Namespace namespace, OID oid, EntityWithWorldNodeFactory entityFactory, java.util.Collection<ObjectType> subjectTypes)
public ObjectTracker(Namespace namespace, OID instanceOid, EntityWithWorldNodeFactory entityFactory, float hystericalMargin, ObjectTracker.NotifyReactionRadiusCallback notifyCallback, ObjectTracker.RemoteObjectFilter remoteObjectFilter)
public OID getInstanceOid()
public void addLocalObject(OID oid, java.lang.Integer reactionRadius)
public boolean hasLocalObject(java.lang.Long oid)
public void addReactionRadius(OID oid, java.lang.Integer reactionRadius)
public void removeReactionRadius(OID oid)
public boolean removeLocalObject(OID oid)
protected boolean maybeAddRemoteObject(PerceptionMessage.ObjectNote objectNote)
protected boolean removeRemoteObject(OID objOid, OID oid, java.util.List<OID> trackersToRemove)
public void updateEntity(EntityWithWorldNode ewwn)
ewwn
- public void dispatchMessage(Message message, int flags, MessageCallback callback)
MessageDispatch
flags
through unaltered.dispatchMessage
in interface MessageDispatch
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').protected void handlePerception(PerceptionMessage perceptionMessage)
protected void maybeRemoveRemoteObject(OID subjectOid, PerceptionMessage.ObjectNote objectNote, OID targetOid)
public void handleMessage(Message msg, int flags)
MessageCallback
handleMessage
in interface MessageCallback
msg
- Message sent from other agent.flags
- Bitwise OR of MessageCallback.NO_FLAGS
, MessageCallback.RESPONSE_EXPECTED
.