Example #1
0
    public void addSighting(LabelHandle target, Vector3 position, Vector3?direction)
    {
        if (targetSightings.ContainsKey(target))
        {
            SensoryInfo info = targetSightings[target];

            if (info.getSightings() == 0)
            {
                // We have to increment the sighting count before we notify listeners
                info.addSighting();
                notifyListenersTargetFound(target);
            }
            else
            {
                // Keep this. See above comment
                info.addSighting();
            }
            info.updatePosition(position);
            info.updateDirection(direction);
        }
        else
        {
            targetSightings[target] = new SensoryInfo(position, direction, 1);
            notifyListenersTargetFound(target);
        }
    }
Example #2
0
    public void removeSighting(LabelHandle target, Vector3 position, Vector3?direction)
    {
        if (targetSightings.ContainsKey(target))
        {
            SensoryInfo info = targetSightings[target];

            info.removeSighting();
            if (info.getSightings() < 1)
            {
                notifyListenersTargetLost(target);
            }
            info.updatePosition(position);
        }
        else
        {
            //Realistically we should never get here. This case is stupid.
            targetSightings[target] = new SensoryInfo(position, direction, 0);
            notifyListenersTargetLost(target);
            Debug.LogWarning("Target '" + target.getName() + "' that was never found has been lost. Shenanigans?");
        }
    }