Atavism Version 2018.1AGIS API

atavism.server.objects
Class ObjectTracker

java.lang.Object
  extended by atavism.server.objects.ObjectTracker
All Implemented Interfaces:
MessageCallback, MessageDispatch

public class ObjectTracker
extends java.lang.Object
implements MessageCallback, MessageDispatch


Nested Class Summary
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
           
 
Field Summary
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
           
 
Fields inherited from interface atavism.msgsys.MessageCallback
NO_FLAGS, RESPONSE_EXPECTED
 
Constructor Summary
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)
           
 
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
 

Field Detail

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
Constructor Detail

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)
Method Detail

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.


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