Atavism Version 2018.1AGIS API

atavism.server.objects
Class ProximityTracker

java.lang.Object
  extended by atavism.server.objects.ProximityTracker
All Implemented Interfaces:
MessageDispatch

public class ProximityTracker
extends java.lang.Object
implements MessageDispatch

This class is similar to the ObjectTracker, but is used in cases where there is no local/remote distinction between objects. Instead, the class maintains it's own set of InterpolatedWorldNodes, and an update thread to keep them current, and a mapping from perceiver objects to perceived objects. When one of those objects moves, the mapping is updated, and if they have moved in or out of range, the class either sends a NotifyReactionRadius message, or


Nested Class Summary
protected  class ProximityTracker.PerceiverData
           
 
Field Summary
protected  float hystericalMargin
           
protected  OID instanceOid
           
protected  java.util.concurrent.locks.Lock lock
           
protected  Namespace namespace
           
protected  ObjectTracker.NotifyReactionRadiusCallback notifyCallback
           
protected  java.util.Map<OID,ProximityTracker.PerceiverData> perceiverDataMap
          This maps a perceiver oid into an object containing the list of perceived objects, and the list of objects in range.
protected  ObjectTracker.RemoteObjectFilter remoteObjectFilter
           
protected  boolean running
           
protected  atavism.server.objects.ProximityTracker.Updater updater
           
protected  java.lang.Thread updaterThread
           
 
Constructor Summary
ProximityTracker(Namespace namespace, OID instanceOid)
           
ProximityTracker(Namespace namespace, OID instanceOid, float hystericalMargin, ObjectTracker.NotifyReactionRadiusCallback notifyCallback, ObjectTracker.RemoteObjectFilter remoteObjectFilter)
           
 
Method Summary
 void addTrackedPerceiver(OID perceiverOid, InterpolatedWorldNode wnode, 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 perceiverOid)
           
 void handlePerception(PerceptionMessage perceptionMessage)
           
 void handleUpdateWorldNode(long oid, WorldManagerClient.UpdateWorldNodeMessage wnodeMsg)
           
 boolean hasTrackedPerceiver(OID oid)
           
protected  boolean maybeAddPerceivedObject(PerceptionMessage.ObjectNote objectNote)
           
protected  void maybeRemovePerceivedObject(OID oid, PerceptionMessage.ObjectNote objectNote, OID targetOid)
           
protected  void performNotification(OID perceiverOid, OID perceivedOid, boolean inRadius, boolean wasInRadius)
           
protected  void removePerceivedObject(OID targetOid, OID oid)
           
 void removeTrackedPerceiver(OID perceiverOid)
           
 void setRunning(boolean running)
           
protected  void testProximity(ProximityTracker.PerceiverData perceiverData, ProximityTracker.PerceiverData perceivedData, boolean interpolatePerceiver, boolean interpolatePerceived)
          Test if the perceived object has come in or out of range of the perceiver object; if so, we change the inRangeOids set for the perceiver, and notify the perceiver.
protected  void updateEntity(ProximityTracker.PerceiverData perceiverData)
           
 
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

hystericalMargin

protected float hystericalMargin

notifyCallback

protected ObjectTracker.NotifyReactionRadiusCallback notifyCallback

remoteObjectFilter

protected ObjectTracker.RemoteObjectFilter remoteObjectFilter

updater

protected atavism.server.objects.ProximityTracker.Updater updater

updaterThread

protected java.lang.Thread updaterThread

running

protected boolean running

perceiverDataMap

protected java.util.Map<OID,ProximityTracker.PerceiverData> perceiverDataMap
This maps a perceiver oid into an object containing the list of perceived objects, and the list of objects in range.


lock

protected java.util.concurrent.locks.Lock lock
Constructor Detail

ProximityTracker

public ProximityTracker(Namespace namespace,
                        OID instanceOid)

ProximityTracker

public ProximityTracker(Namespace namespace,
                        OID instanceOid,
                        float hystericalMargin,
                        ObjectTracker.NotifyReactionRadiusCallback notifyCallback,
                        ObjectTracker.RemoteObjectFilter remoteObjectFilter)
Method Detail

getInstanceOid

public OID getInstanceOid()

addTrackedPerceiver

public void addTrackedPerceiver(OID perceiverOid,
                                InterpolatedWorldNode wnode,
                                java.lang.Integer reactionRadius)

hasTrackedPerceiver

public boolean hasTrackedPerceiver(OID oid)

removeTrackedPerceiver

public void removeTrackedPerceiver(OID perceiverOid)

getOidsInRadius

public java.util.List<OID> getOidsInRadius(OID perceiverOid)

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').

maybeAddPerceivedObject

protected boolean maybeAddPerceivedObject(PerceptionMessage.ObjectNote objectNote)

testProximity

protected void testProximity(ProximityTracker.PerceiverData perceiverData,
                             ProximityTracker.PerceiverData perceivedData,
                             boolean interpolatePerceiver,
                             boolean interpolatePerceived)
Test if the perceived object has come in or out of range of the perceiver object; if so, we change the inRangeOids set for the perceiver, and notify the perceiver.


performNotification

protected void performNotification(OID perceiverOid,
                                   OID perceivedOid,
                                   boolean inRadius,
                                   boolean wasInRadius)

updateEntity

protected void updateEntity(ProximityTracker.PerceiverData perceiverData)

handlePerception

public void handlePerception(PerceptionMessage perceptionMessage)

handleUpdateWorldNode

public void handleUpdateWorldNode(long oid,
                                  WorldManagerClient.UpdateWorldNodeMessage wnodeMsg)

maybeRemovePerceivedObject

protected void maybeRemovePerceivedObject(OID oid,
                                          PerceptionMessage.ObjectNote objectNote,
                                          OID targetOid)

removePerceivedObject

protected void removePerceivedObject(OID targetOid,
                                     OID oid)

setRunning

public void setRunning(boolean running)


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