Exemplo n.º 1
0
        /// <summary>
        /// Handles addition of new tracked object if user is using Unity triggers.
        /// </summary>
        private void handleTriggerAddition(GameObject trackedObject, WorldMonitors owner, string objectAffiliation, float threshold)
        {
            if (!trackedObject.GetComponent <TrackedObjectTriggers>())
            {
                trackedObject.AddComponent <TrackedObjectTriggers>();
            }

            TrackedObjectTriggers tot = trackedObject.GetComponent <TrackedObjectTriggers>();

            GameObjectIDReference.Add(trackedObject, AllocationSpace);
            gameObjectReference.Add(AllocationSpace, trackedObject);

            TrackedObjectData TOData = new TrackedObjectData
            {
                Object       = trackedObject,
                Threshold    = TriggersMimicOctree ? 0.75f * threshold : threshold,
                ObjectOwners = new List <WorldMonitors>()
            };

            if (owner)
            {
                TOData.ObjectOwners.Add(owner);
                tot.AcceptOwner(owner);
            }

            TrackedObjectDataRef.Add(AllocationSpace, TOData);
            TrackedObjectAffiliations.Add(AllocationSpace, objectAffiliation);

            TotalTrackedObjects++;
            AllocationSpace++;
            tot.Initialize();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles object removal when user is using Unity triggers
        /// </summary>
        private void handleTriggerRemoval(GameObject trackedObject, WorldMonitors whoToRemove = default(WorldMonitors), bool retainOtherTrackers = default(bool))
        {
            if (whoToRemove != default(WorldMonitors))
            {
                gameObject.GetComponent <TrackedObjectTriggers>().LoseOwner(whoToRemove);
                if (retainOtherTrackers)
                {
                    return;
                }
            }

            TrackedObjectTriggers tot = gameObject.GetComponent <TrackedObjectTriggers>();

            if (tot)
            {
                tot.wms = new List <WorldMonitors>(); // empty it.
            }
            TotalTrackedObjects--;
            return;
        }