Exemple #1
0
        private void EngramValue(SimulationEvent e)
        {
            SimulationObjectProxy obProx;
            string engramName     = ((StringValue)e["EngramName"]).value;
            string engramValue    = ((StringValue)e["EngramValue"]).value;
            string engramDataType = ((StringValue)e["EngramDataType"]).value;
            string objectID       = string.Empty;

            objectID = ((StringValue)e["SpecificUnit"]).value;
            if (objectID != string.Empty)
            {
                obProx = objectProxies[objectID];
                if (!StateDB.physicalObjects.ContainsKey(objectID))
                {
                    return;
                }
                EmitterValue          em  = (EmitterValue)obProx["Emitters"].GetDataValue();
                CustomAttributesValue cus = (CustomAttributesValue)obProx["CustomAttributes"].GetDataValue();
                if (em.attIsEngram.ContainsKey(engramName))
                {
                    cus.attributes[engramName] = DataValueFactory.BuildString(engramValue);
                    obProx["CustomAttributes"].SetDataValue(cus);
                }
                //Add the qualified engram name to the collection.
                //Does not need to be the same qualified name as the scencon uses.
                StateDB.UpdateEngrams(String.Format("{0}|{1}", objectID, engramName), engramValue, engramDataType);

                return;
            }
            else
            {
                StateDB.UpdateEngrams(engramName, engramValue, engramDataType);

                foreach (string id in objectProxies.Keys)
                {
                    obProx = objectProxies[id];
                    if (!StateDB.physicalObjects.ContainsKey(id))
                    {
                        continue;
                    }
                    EmitterValue          em  = (EmitterValue)obProx["Emitters"].GetDataValue();
                    CustomAttributesValue cus = (CustomAttributesValue)obProx["CustomAttributes"].GetDataValue();
                    if (em.attIsEngram.ContainsKey(engramName))
                    {
                        cus.attributes[engramName] = DataValueFactory.BuildString(engramValue);
                        obProx["CustomAttributes"].SetDataValue(cus);
                    }
                }
                return;
            }
        }
Exemple #2
0
        /// <summary>
        /// This method retrieves all sensable attributes from the target proxy into the referenced attribute collection value.
        /// </summary>
        /// <param name="ACV">Current collection to add attributes into.</param>
        /// <param name="targetProxy">SimulationProxy to retrieve attributes from.</param>
        private void SenseAllAttributes(ref AttributeCollectionValue singleObjectACV, SimulationObjectProxy targetProxy)
        {
            //for the target object, go through each observable attribute, and add to the view with full confidence.
            string targetObjectID = ((StringValue)targetProxy["ID"].GetDataValue()).value;
            string objectType     = targetProxy.GetObjectType();
            DetectedAttributeValue dav;
            List <string>          keys = targetProxy.GetKeys();

            foreach (string att in simModel.objectModel.objects[objectType].attributes.Keys)
            {
                if (simModel.objectModel.objects[objectType].attributes[att].otherObservable)
                {
                    if (keys.Contains(att))
                    {
                        dav = new DetectedAttributeValue();

                        if (att == "CustomAttributes")
                        {
                            DataValue t = targetProxy[att].GetDataValue();
                            if (t.dataType == "CustomAttributesType")
                            {
                                Dictionary <string, DataValue> copiedDict = CopyFromCustomAttributes(((CustomAttributesValue)t).attributes);
                                t = new CustomAttributesValue();
                                ((CustomAttributesValue)t).attributes = copiedDict;
                            }

                            dav        = new DetectedAttributeValue();
                            dav.stdDev = 100;
                            dav.value  = DataValueFactory.BuildFromDataValue(t);
                            //AddAttributeToACV(ref singleAttributeCollection, simModelAtt.Key, detectedAttribute);
                        }
                        else
                        {
                            dav.value  = DataValueFactory.BuildFromDataValue(targetProxy[att].GetDataValue());
                            dav.stdDev = 100;
                        }
                        if (((AttributeCollectionValue)singleObjectACV).attributes.ContainsKey(att))
                        {
                            ((AttributeCollectionValue)singleObjectACV)[att] = dav;
                        }
                        else
                        {
                            ((AttributeCollectionValue)singleObjectACV).attributes.Add(att, dav);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Similar to CalculateRangeRings, this is done with ABSOLUTE data, not detected values.
        /// This method is called in a ViewProAttributeUpdate call, which only contains attributes
        /// which have CHANGED, and will determine if either the sensors, vulnerabilties, or capabilities (including docked weapons) has
        /// changed.  If so, then new attributes will be added to the attribute collection value.
        /// </summary>
        /// <param name="acv"></param>
        /// <param name="fullObjectView"></param>
        /// <returns></returns>
        private void AddRangeRings(ref AttributeCollectionValue acv, ref SimulationObjectProxy fullObjectView)
        {
            if (acv.attributes.ContainsKey("Sensors"))
            {
                //detected contains a sensor array type
                CustomAttributesValue sensorCollection = DataValueFactory.BuildCustomAttributes(new Dictionary <string, DataValue>()) as CustomAttributesValue;
                RangeRingDisplayValue sensorRing;
                SensorArrayValue      detectedSensors = acv["Sensors"] as SensorArrayValue;

                foreach (SensorValue sv in detectedSensors.sensors)
                {
                    sensorRing = DataValueFactory.BuildRangeRingDisplayValue(sv.sensorName, "Sensors", false, new Dictionary <int, int>()) as RangeRingDisplayValue;
                    sensorRing.rangeIntensities.Add(Convert.ToInt32(sv.maxRange), -1);

                    sensorCollection.attributes.Add(sv.sensorName, sensorRing);
                }

                if (sensorCollection.attributes.Count > 0)
                {
                    acv.attributes.Add("SensorRangeRings", sensorCollection);
                }
                else
                {
                    Console.WriteLine("No SensorRangeRings added to ACV");
                }
            }
            if (acv.attributes.ContainsKey("Vulnerability"))
            {
                //gets detected values, containing a vulnerability type
                CustomAttributesValue    vulnerabilityCollection = DataValueFactory.BuildCustomAttributes(new Dictionary <string, DataValue>()) as CustomAttributesValue;
                RangeRingDisplayValue    vulnerabilityRing;
                VulnerabilityValue       detectedVulnerability = acv["Vulnerability"] as VulnerabilityValue;
                Dictionary <string, int> longestRange          = new Dictionary <string, int>();//[Capability],[Range]

                foreach (VulnerabilityValue.Transition tr in detectedVulnerability.transitions)
                {
                    foreach (VulnerabilityValue.TransitionCondition tc in tr.conditions)
                    {
                        if (!longestRange.ContainsKey(tc.capability))
                        {
                            longestRange.Add(tc.capability, -1);
                        }
                        if (longestRange[tc.capability] < Convert.ToInt32(tc.range))
                        {
                            longestRange[tc.capability] = Convert.ToInt32(tc.range);
                        }
                    }
                }

                foreach (KeyValuePair <string, int> kvp in longestRange)
                {
                    vulnerabilityRing = DataValueFactory.BuildRangeRingDisplayValue(kvp.Key, "Vulnerability", false, new Dictionary <int, int>()) as RangeRingDisplayValue;
                    vulnerabilityRing.rangeIntensities.Add(kvp.Value, -1);

                    vulnerabilityCollection.attributes.Add(kvp.Key, vulnerabilityRing);
                }


                if (vulnerabilityCollection.attributes.Count > 0)
                {
                    acv.attributes.Add("VulnerabilityRangeRings", vulnerabilityCollection);
                }
                else
                {
                    Console.WriteLine("No VulnerabilityRangeRings added to ACV");
                }
            }
            if (acv.attributes.ContainsKey("Capability") || acv.attributes.ContainsKey("DockedWeapons"))
            {
                CustomAttributesValue capabilityCollection = DataValueFactory.BuildCustomAttributes(new Dictionary <string, DataValue>()) as CustomAttributesValue;
                RangeRingDisplayValue capabilityRing;

                Dictionary <string, int> longestWeaponRange = new Dictionary <string, int>();//[Capability],[Range]


                //docked weapons gets string list of IDs
                if (acv.attributes.ContainsKey("DockedWeapons"))
                {
                    StringListValue dockedWeapons = acv["DockedWeapons"] as StringListValue;
                    foreach (String weaponID in dockedWeapons.strings)
                    {
                        //get weapon id
                        //get proxy info for weapon
                        SimulationObjectProxy weapon = objectProxies[weaponID];
                        string species = ((StringValue)weapon["ClassName"].GetDataValue()).value;
                        if (longestWeaponRange.ContainsKey(species))
                        {
                            continue;
                            //For now, assume that all weapons of the same species type have the same ranges.
                            //this will cut back on unneccessary loops, and for the most part is 100% true.
                        }

//get max speed, maxfuel or current fuel, get fuel consumption rate, get SHORTEST capability range
                        double maxSpeed             = ((DoubleValue)weapon["MaximumSpeed"].GetDataValue()).value;
                        double maxFuel              = ((DoubleValue)weapon["FuelCapacity"].GetDataValue()).value;
                        double fuelConsumptionRate  = ((DoubleValue)weapon["FuelConsumptionRate"].GetDataValue()).value;
                        double shortCapabilityRange = -1;

                        CapabilityValue             weaponCV  = (CapabilityValue)weapon["Capability"].GetDataValue();
                        Dictionary <string, double> capRanges = new Dictionary <string, double>();

                        foreach (CapabilityValue.Effect ef in weaponCV.effects)
                        {
                            if (!capRanges.ContainsKey(ef.name))
                            {
                                capRanges.Add(ef.name, ef.range);
                            }
                            else
                            {
                                if (capRanges[ef.name] > ef.range)
                                {//You want the smaller range here because that's how weapons work.  Auto-attacks use the SHORTEST range to trigger.
                                    capRanges[ef.name] = ef.range;
                                }
                            }
                        }
                        //but here, you want the LONGEST of the ranges that could trigger an auto-attack.
                        foreach (KeyValuePair <string, double> kvp in capRanges)
                        {
                            if (kvp.Value > shortCapabilityRange)
                            {
                                shortCapabilityRange = kvp.Value;
                            }
                        }

                        double thisRange = maxSpeed * maxFuel * fuelConsumptionRate + shortCapabilityRange;
                        longestWeaponRange.Add(species, Convert.ToInt32(thisRange));
                    }
                    //
                }

                Dictionary <string, Dictionary <double, double> > capabilityRanges = new Dictionary <string, Dictionary <double, double> >();
                if (acv.attributes.ContainsKey("Capability"))
                {
                    CapabilityValue detectedCapability = acv["Capability"] as CapabilityValue;


                    foreach (CapabilityValue.Effect ef in detectedCapability.effects)
                    {
                        if (!capabilityRanges.ContainsKey(ef.name))
                        {
                            capabilityRanges.Add(ef.name, new Dictionary <double, double>());
                        }

                        capabilityRanges[ef.name].Add(ef.range, ef.intensity);
                    }
                }

                //add all capabilities to ring collection
                foreach (string capName in capabilityRanges.Keys)
                {
                    if (!capabilityCollection.attributes.ContainsKey(capName))
                    {
                        capabilityRing = DataValueFactory.BuildRangeRingDisplayValue(capName, "Capability", false, new Dictionary <int, int>()) as RangeRingDisplayValue;
                        Dictionary <int, int> convertedRanges = new Dictionary <int, int>();
                        foreach (KeyValuePair <double, double> kvp in capabilityRanges[capName])
                        {
                            convertedRanges.Add(Convert.ToInt32(kvp.Key), Convert.ToInt32(kvp.Value));
                        }
                        capabilityRing.AddAndSortRanges(convertedRanges); //this sorts as well

                        capabilityCollection.attributes.Add(capName, capabilityRing);
                    }
                    else
                    {
                        Console.WriteLine("Failed to add duplicate capability to collection, {0}", capName);
                    }
                }

                foreach (string weaponSpeciesName in longestWeaponRange.Keys)
                {
                    if (!capabilityCollection.attributes.ContainsKey(weaponSpeciesName))
                    {
                        capabilityRing = DataValueFactory.BuildRangeRingDisplayValue(weaponSpeciesName, "Capability", true, new Dictionary <int, int>()) as RangeRingDisplayValue;
                        capabilityRing.rangeIntensities.Add(longestWeaponRange[weaponSpeciesName], -1); //TODO: Maybe add intensity above?
                        capabilityCollection.attributes.Add(weaponSpeciesName, capabilityRing);
                    }
                    else
                    {
                        Console.WriteLine("Failed to add duplicate capability(Weapon species) to collection, {0}", weaponSpeciesName);
                    }
                }

                if (capabilityCollection.attributes.Count > 0)
                {
                    acv.attributes.Add("CapabilityRangeRings", capabilityCollection);
                }
                else
                {
                    Console.WriteLine("No CapabilityRangeRings added to ACV");
                }
            }
        }
Exemple #4
0
        private void StateChange(SimulationEvent e)
        {
            string id = ((StringValue)e["ObjectID"]).value;
            SimulationObjectProxy prox = null; // objectProxies[id];

            prox = GetObjectProxy(id);
            if (prox == null)
            {
                return;
            }

            string newState = ((StringValue)e["NewState"]).value;

            DataValue dv = prox["StateTable"].GetDataValue();

            if (((StateTableValue)dv).states.ContainsKey(newState))
            {
                DataValue dv2 = ((StateTableValue)dv).states[newState];
                //AD: Added state to attributes
                DataValue temp = new StringValue();
                ((StringValue)temp).value = newState;
                ((AttributeCollectionValue)dv2).attributes["State"] = temp;
                //AD
                foreach (string attname in ((AttributeCollectionValue)dv2).attributes.Keys)
                {
                    if (prox.GetKeys().Contains(attname) && prox[attname].IsOwner())
                    {
                        prox[attname].SetDataValue(((AttributeCollectionValue)dv2).attributes[attname]);
                        if (attname == "Sensors")
                        {
                            double           maxSensor = -1.0;
                            SensorArrayValue sav       = ((AttributeCollectionValue)dv2).attributes[attname] as SensorArrayValue;
                            foreach (SensorValue sv in sav.sensors)
                            {
                                maxSensor = Math.Max(maxSensor, sv.maxRange);
                            }
                            if (maxSensor >= 0)
                            {
                                ObjectDistances.UpdateObjectSensorRange(id, maxSensor);
                            }
                        }
                    }
                }
            }
            CustomAttributesValue cav = prox["CustomAttributes"].GetDataValue() as CustomAttributesValue;

            Dictionary <string, DataValue> x = new Dictionary <string, DataValue>();

            if (cav != null)
            {
                x = cav.attributes;
            }

            EmitterValue em = (EmitterValue)prox["Emitters"].GetDataValue();

            foreach (string attName in em.attIsEngram.Keys)
            {
                if (em.attIsEngram[attName])
                {
                    if (StateDB.engrams.ContainsKey(attName))
                    {
                        x[attName] = DataValueFactory.BuildString(StateDB.engrams[attName].engramValue);
                    }
                }
            }

            prox["CustomAttributes"].SetDataValue(DataValueFactory.BuildCustomAttributes(x));
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="allObjectViews"></param>
        private void SenseAllObjects(ref Dictionary <string, Dictionary <string, AttributeCollectionValue> > allObjectsViews)
        {
            SimulationObjectProxy sensingProxy        = null;
            SimulationObjectProxy targetProxy         = null;
            Vec3D                    sensingLocation  = null;
            Vec3D                    targetsLocation  = null;
            LocationValue            senLocation      = null;
            LocationValue            tarLocation      = null;
            double                   distance         = 0.0;
            SensorArrayValue         sav              = null;
            DataValue                targetsAttribute = null;
            string                   ownerID          = null;
            string                   objectType       = null;
            DetectedAttributeValue   detectedAttribute;
            AttributeCollectionValue singleAttributeCollection = null;
            bool isSensed = false;

            // The dictionary is constantly created in this method //
            Dictionary <string, AttributeCollectionValue> singleObjectView;

            //AD to improve this later:
            // for each object in the visible ObjectDistances collection
            //    for each object after the current index
            //       check for the index object's view of the nested object
            //       check for the nested object's view of the index object
            //Possible hangup is the "All" emitter.



            int x = 0;

            //Each object senses each other object
            //foreach (string sensorObjectID in listOfObjectIDs)
            foreach (KeyValuePair <string, List <string> > networks in networkRosters)
            {
                if (!activeSensorNetworks[networks.Key])
                {
                    continue;
                }
                foreach (string sensorObjectID in networkObjects[networks.Key])
                {
                    sensingProxy = objectProxies[sensorObjectID];
                    objectType   = sensingProxy.GetObjectType();
                    senLocation  = sensingProxy["Location"].GetDataValue() as LocationValue;
                    if (senLocation.exists)
                    {
                        ownerID          = ((StringValue)sensingProxy["OwnerID"].GetDataValue()).value;
                        singleObjectView = new Dictionary <string, AttributeCollectionValue>();
                        x++;
                        //foreach (string targetObjectID in listOfObjectIDs)
                        foreach (List <string> objects in networkObjects.Values)
                        {
                            if (objects.Contains(sensorObjectID))
                            {
                                if (((EmitterValue)sensingProxy["Emitters"].GetDataValue()).emitters.ContainsKey("Invisible"))
                                //OR if it's the "master" object for a region?? -lisa
                                {
                                    continue;
                                }
                                string target = sensorObjectID;

                                singleAttributeCollection = new AttributeCollectionValue();
                                foreach (KeyValuePair <string, AttributeInfo> simModelAtt in simModel.objectModel.objects[objectType].attributes)
                                {
                                    if (!simModelAtt.Value.ownerObservable == true)
                                    {
                                        continue;
                                    }
                                    //if (!sensingProxy.GetKeys().Contains(simModelAtt.Key))
                                    //    continue;
                                    DataValue t = sensingProxy[simModelAtt.Key].GetDataValue();
                                    if (t.dataType == "CustomAttributesType")
                                    {
                                        Dictionary <string, DataValue> copiedDict = CopyFromCustomAttributes(((CustomAttributesValue)t).attributes);
                                        t = new CustomAttributesValue();
                                        ((CustomAttributesValue)t).attributes = copiedDict;
                                    }
                                    detectedAttribute        = new DetectedAttributeValue();
                                    detectedAttribute.stdDev = 100;
                                    detectedAttribute.value  = DataValueFactory.BuildFromDataValue(t);
                                    AddAttributeToACV(ref singleAttributeCollection, simModelAtt.Key, detectedAttribute);
                                }//end foreach sensable attribute

                                if (!allObjectsViews.ContainsKey(sensorObjectID))
                                {
                                    allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                }
                                if (!objectViews.ContainsKey(sensorObjectID))
                                {
                                    objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                }
                                //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                //to users.
                                AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(target, singleAttributeCollection);

                                //if (changedAttributes != null && selectedRangeRingLevel != RangeRingLevels.DISABLED)
                                //{
                                //    CalculateRangeRings(ref changedAttributes, ref sensingProxy);
                                //}

                                if (changedAttributes != null)
                                {
                                    allObjectsViews[sensorObjectID].Add(target, changedAttributes);
                                }
                                else//this is so there is at least the empty entry for the detected object so
                                //you still know it is detected.
                                {
                                    if (!allObjectsViews[sensorObjectID].ContainsKey(target))
                                    {
                                        allObjectsViews[sensorObjectID].Add(target, new AttributeCollectionValue());
                                    }
                                }
                            }
                            else
                            {
                                foreach (string targetObjectID in objects)
                                {//sensing and target objects are not the same
                                    targetProxy = objectProxies[targetObjectID];
                                    tarLocation = targetProxy["Location"].GetDataValue() as LocationValue;
                                    if (tarLocation.exists)
                                    {
                                        EmitterValue emitters = targetProxy["Emitters"].GetDataValue() as EmitterValue;
                                        if (emitters.emitters.ContainsKey("All"))
                                        {
                                            //if an object has an all emitter, retrieve all attributes without sensing algorithm
                                            AttributeCollectionValue atts = new AttributeCollectionValue();
                                            if (singleObjectView.ContainsKey(targetObjectID))
                                            {
                                                atts = singleObjectView[targetObjectID];
                                            }
                                            SenseAllAttributes(ref atts, targetProxy);
                                            singleObjectView[targetObjectID] = atts;
                                            isSensed = true;

                                            if (!allObjectsViews.ContainsKey(sensorObjectID))
                                            {
                                                allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                            }
                                            if (!objectViews.ContainsKey(sensorObjectID))
                                            {
                                                objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                            }
                                            //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                            //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                            //to users.
                                            AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(targetObjectID, atts);

                                            //if (changedAttributes != null && selectedRangeRingLevel == RangeRingLevels.FULL)
                                            //{//the only way to sense a "target" here is for FULL ring display
                                            //    CalculateRangeRings(ref changedAttributes, ref targetProxy);
                                            //}

                                            if (changedAttributes != null)
                                            {
                                                allObjectsViews[sensorObjectID].Add(targetObjectID, changedAttributes);
                                            }
                                            else//this is so there is at least the empty entry for the detected object so
                                            //you still know it is detected.
                                            {
                                                if (!allObjectsViews[sensorObjectID].ContainsKey(targetObjectID))
                                                {
                                                    allObjectsViews[sensorObjectID].Add(targetObjectID, new AttributeCollectionValue());
                                                }
                                            }
                                        }
                                        else if (emitters.emitters.ContainsKey("Invisible"))
                                        //or if object is "master" for moving region -lisa
                                        {
                                            continue;
                                        }
                                        else
                                        {//object does not have an all emitter, continue to check each emitter value
                                            AttributeCollectionValue atts = new AttributeCollectionValue();
                                            if (Omniscience)
                                            {
                                                if (singleObjectView.ContainsKey(targetObjectID))
                                                {
                                                    atts = singleObjectView[targetObjectID];
                                                }
                                                SenseAllAttributes(ref atts, targetProxy);
                                                singleObjectView[targetObjectID] = atts;
                                                isSensed = true;
                                                if (!allObjectsViews.ContainsKey(sensorObjectID))
                                                {
                                                    allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                                }
                                                if (!objectViews.ContainsKey(sensorObjectID))
                                                {
                                                    objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                                }
                                                //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                                //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                                //to users.
                                                AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(targetObjectID, atts);

                                                //if (changedAttributes != null && selectedRangeRingLevel == RangeRingLevels.FULL)
                                                //{//the only way to sense a "target" here is for FULL ring display
                                                //    CalculateRangeRings(ref changedAttributes, ref targetProxy);
                                                //}

                                                if (changedAttributes != null)
                                                {
                                                    allObjectsViews[sensorObjectID].Add(targetObjectID, changedAttributes);
                                                }
                                                else//this is so there is at least the empty entry for the detected object so
                                                //you still know it is detected.
                                                {
                                                    if (!allObjectsViews[sensorObjectID].ContainsKey(targetObjectID))
                                                    {
                                                        allObjectsViews[sensorObjectID].Add(targetObjectID, new AttributeCollectionValue());
                                                    }
                                                }
                                                continue;
                                            }

                                            sensingLocation = new Vec3D(senLocation);
                                            targetsLocation = new Vec3D(tarLocation);
                                            isSensed        = false;
                                            distance        = sensingLocation.ScalerDistanceTo(targetsLocation);
                                            sav             = sensingProxy["Sensors"].GetDataValue() as SensorArrayValue;

                                            foreach (SensorValue sv in sav.sensors)
                                            {
                                                if (distance < sv.maxRange)
                                                {
                                                    //Find obstructions
                                                    List <SimulationObjectProxy> obstructions = FindObstructions(sensingLocation, targetsLocation);

                                                    foreach (KeyValuePair <string, List <ConeValue> > kvp in sv.ranges)
                                                    { //Key is the attribute being sensed, value is a list of cones
                                                        if (kvp.Key == "All")
                                                        {
                                                            atts = new AttributeCollectionValue();
                                                            if (singleObjectView.ContainsKey(targetObjectID))
                                                            {
                                                                atts = singleObjectView[targetObjectID];
                                                            }
                                                            SenseAllAttributes(ref atts, targetProxy);
                                                            singleObjectView[targetObjectID] = atts;
                                                            isSensed = true;
                                                        }
                                                        else //not an All sensor, so run detection algorithm
                                                        {//Added in main-line
                                                            if (!emitters.emitters.ContainsKey(kvp.Key))
                                                            {
                                                                continue;
                                                            }
                                                            //Custom attributes fix:
                                                            DataValue currentDataValue;
                                                            try
                                                            {
                                                                currentDataValue = targetProxy[kvp.Key].GetDataValue();
                                                            }
                                                            catch
                                                            {
                                                                currentDataValue = targetProxy["CustomAttributes"].GetDataValue();
                                                                currentDataValue = ((CustomAttributesValue)currentDataValue)[kvp.Key];
                                                                //will throw an error here if object doesn't contain custom atts, or
                                                                //if it doesnt contain the specified custom att.
                                                            }

                                                            bool isObstructed = false;
                                                            foreach (SimulationObjectProxy reg in obstructions)
                                                            {
                                                                foreach (string attributeBlocked in ((StringListValue)reg["BlocksSensorTypes"].GetDataValue()).strings)
                                                                {
                                                                    if (kvp.Key == attributeBlocked)
                                                                    {
                                                                        isObstructed = true;
                                                                    }
                                                                }
                                                            }
                                                            if (isObstructed)
                                                            {
                                                                detectedAttribute            = new DetectedAttributeValue();
                                                                detectedAttribute.value      = DataValueFactory.BuildValue(currentDataValue.dataType);
                                                                detectedAttribute.confidence = 0;
                                                                //continue;
                                                            }
                                                            else
                                                            {
                                                                targetsAttribute = DataValueFactory.BuildFromDataValue(currentDataValue);
                                                                //ev is emitters
                                                                Dictionary <string, double> emitterCollection = emitters.emitters[kvp.Key];

                                                                detectedAttribute = new DetectedAttributeValue();
                                                                detectedAttribute = ObjectMath.Detection(senLocation, tarLocation, targetsAttribute, kvp.Value, emitterCollection, obstructions, ref randomGenerator);
                                                            }
                                                            if (detectedAttribute != null)
                                                            {
                                                                singleAttributeCollection = new AttributeCollectionValue();
                                                                if (singleObjectView.ContainsKey(targetObjectID))
                                                                {
                                                                    singleAttributeCollection = singleObjectView[targetObjectID];
                                                                }
                                                                AddAttributeToACV(ref singleAttributeCollection, kvp.Key, detectedAttribute);
                                                                isSensed = true;
                                                            }
                                                        }
                                                    }//end foreach attribute in sensor

                                                    //if the object has any attributes sensed, fill in some other info for the object's view.
                                                    if (isSensed)
                                                    {
                                                        detectedAttribute        = new DetectedAttributeValue();
                                                        detectedAttribute.stdDev = 100;
                                                        detectedAttribute.value  = targetProxy["ID"].GetDataValue();
                                                        if (singleAttributeCollection == null)
                                                        {
                                                            singleAttributeCollection = new AttributeCollectionValue();
                                                        }
                                                        if (!singleObjectView.ContainsKey(targetObjectID))
                                                        {
                                                            singleObjectView.Add(targetObjectID, singleAttributeCollection);
                                                        }
                                                        singleAttributeCollection = singleObjectView[targetObjectID];
                                                        AddAttributeToACV(ref singleAttributeCollection, "ID", detectedAttribute);

                                                        detectedAttribute        = new DetectedAttributeValue();
                                                        detectedAttribute.stdDev = 100;
                                                        detectedAttribute.value  = targetProxy["OwnerID"].GetDataValue();
                                                        AddAttributeToACV(ref singleAttributeCollection, "OwnerID", detectedAttribute);
                                                    } //end if isSensed.
                                                }
                                            }         //end foreach sensor in sensor array

                                            if (singleObjectView.ContainsKey(targetObjectID))
                                            {
                                                AttributeCollectionValue attr = singleObjectView[targetObjectID];
                                                if (!allObjectsViews.ContainsKey(sensorObjectID))
                                                {
                                                    allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                                }
                                                if (!objectViews.ContainsKey(sensorObjectID))
                                                {
                                                    objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                                }

                                                if (attr.attributes.ContainsKey("CustomAttributes"))
                                                {
                                                    DataValue t    = ((DetectedAttributeValue)attr["CustomAttributes"]).value;
                                                    double    conf = ((DetectedAttributeValue)attr["CustomAttributes"]).confidence;
                                                    Dictionary <string, DataValue> copiedDict = CopyFromCustomAttributes(((CustomAttributesValue)t).attributes);
                                                    t = new CustomAttributesValue();
                                                    ((CustomAttributesValue)t).attributes = copiedDict;
                                                    attr.attributes.Remove("CustomAttributes");
                                                    attr.attributes.Add("CustomAttributes", DataValueFactory.BuildDetectedValue(t, Convert.ToInt32(conf)));
                                                }
                                                //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                                //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                                //to users.
                                                AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(targetObjectID, attr);

                                                //if (changedAttributes != null && selectedRangeRingLevel == RangeRingLevels.FULL)
                                                //{//the only way to sense a "target" here is for FULL ring display
                                                //    CalculateRangeRings(ref changedAttributes, ref targetProxy);
                                                //}

                                                if (changedAttributes != null)
                                                {
                                                    allObjectsViews[sensorObjectID].Add(targetObjectID, changedAttributes);
                                                }
                                                else//this is so there is at least the empty entry for the detected object so
                                                //you still know it is detected.
                                                {
                                                    if (!allObjectsViews[sensorObjectID].ContainsKey(targetObjectID))
                                                    {
                                                        allObjectsViews[sensorObjectID].Add(targetObjectID, new AttributeCollectionValue());
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (objectViews.ContainsKey(sensorObjectID))
                                                {
                                                    if (objectViews[sensorObjectID].ContainsObject(targetObjectID))
                                                    {
                                                        objectViews[sensorObjectID].RemoveObject(targetObjectID);
                                                        //if you once knew of this object, and now don't, remove it from object's view.
                                                    }
                                                }
                                            }
                                        } //end emitter detection
                                    }     //end if target is visible
                                }
                            }
                        } //end foreach target object
                    }     //end if sensor is visible
                }         //end of foreach sensing object
            }             //end of Foreach sensor network
            if (x > 0)
            {
                //Console.Out.WriteLine("ViewPro: {0} objects were sensing at time {1}.", x, currentTick / 1000);
            }
        }