void IModule.LoadModule()
        {
            // setup our static functionality injection for IUsesGeoLocation implementors
            IUsesGeoLocationMethods.TryGetGeoLocationAction             = TryGetGeoLocation;
            IUsesGeoLocationMethods.TryStartServiceFunction             = TryStartService;
            IUsesGeoLocationMethods.SubscribeGeoLocationChangedAction   = SubscribeGeoLocationChanged;
            IUsesGeoLocationMethods.UnsubscribeGeoLocationChangedAction = UnsubscribeGeoLocationChanged;

            if (m_CurrentLocation.latitude == default && m_CurrentLocation.longitude == default)
            {
                m_CurrentLocation = new Vector2(k_DefaultLatitude, k_DefaultLongitude);
            }

            // since this is the only environment trait provider so far,  we add this environment semantic tag
            // to the reserved data ID here.  In the future it may / should live in a more central place.
            m_Database.GetTraitProvider(out MARSTraitDataProvider <bool> tagTraitProvider);
            tagTraitProvider?.AddOrUpdateTrait((int)ReservedDataIDs.ImmediateEnvironment, TraitNames.Environment, true);
#if UNITY_EDITOR
            if (m_AutoStartLocationService)
            {
                AddOrUpdateLocationTrait();
            }
#else
            if (m_AutoStartLocationService)
            {
                TryStartService();
            }
            else
            {
                Debug.Log("MARS GeoLocation is not configured to request location service permission for this project."
                          + " See 'GeoLocationModule' asset.");
            }
#endif
        }
Exemple #2
0
 public void QueryDataDirty_DataNotMarkedAsUsedAndDataChanged_ReturnsFalse()
 {
     m_Db.GetTraitProvider(out MARSTraitDataProvider <float> floatTraits);
     for (var i = 0; i < k_ConditionsPerType; ++i)
     {
         floatTraits.AddOrUpdateTrait(k_DataID, TraitNameForIndex <float>(i), default(float));
     }
     Assert.True(m_Db.QueryDataDirty(m_QueryMatchId));
 }
        internal static void PopulateDatabase(MARSDatabase database, int perTypeTraitCount = 1)
        {
            database.GetTraitProvider(out MARSTraitDataProvider <float> floatTraits);
            database.GetTraitProvider(out MARSTraitDataProvider <Vector2> vector2Traits);

            PopulateTraitProvider(floatTraits, FloatTraits, "", perTypeTraitCount);
            PopulateTraitProvider(vector2Traits, EqualMemberVector2Traits, "", perTypeTraitCount);
            // fake plane sizes
            PopulateTraitProvider(vector2Traits, UnequalMemberVector2Traits, "bounds2d");
        }
        public void SetupBeforeEach()
        {
            m_GameObject     = new GameObject("blank");
            m_ConditionsRoot = m_GameObject.AddComponent <TestMRObject>();
            m_Db.GetTraitProvider(out m_FloatTraits);

            // clear and repopulate the database with a standard set of test data before every test
            m_Db.Clear();
            DatabaseTestData.PopulateDatabase(m_Db, 3);

            SlowTaskModule.instance.ClearTasks();
        }
        public void BasicFilterTest()
        {
            m_Database.GetTraitProvider(out MARSTraitDataProvider <bool> tagTraits);
            // if we get a null provider, code generation hasn't run yet
            if (tagTraits == null)
            {
                return;
            }

            m_Database.GetTraitProvider(out MARSTraitDataProvider <Vector2> vector2Traits);
            m_Database.GetTraitProvider(out MARSTraitDataProvider <float> floatTraits);
            m_Database.GetTraitProvider(out MARSTraitDataProvider <int> intTraits);
            const string presentTrait = "present";

            // add a trait by this name to every type we support, so we can be sure it works for all of them
            for (var i = 0; i < 5; i++)
            {
                intTraits.AddOrUpdateTrait(i, presentTrait, Random.Range(0, 10));
                floatTraits.AddOrUpdateTrait(i, presentTrait, Random.Range(0f, 10f));
                tagTraits.AddOrUpdateTrait(i, presentTrait, true);
                vector2Traits.AddOrUpdateTrait(i, presentTrait, new Vector2());
            }

            var indices = new List <int> {
                0, 1, 2, 3
            };
            var setToFilter = new HashSet <int> {
                3, 4, 5, 6, 7
            };
            var preFilterCount = setToFilter.Count;
            var matchSets      = new []
            {
                // we re-use this same filter set for every instance, because the only difference is type
                setToFilter, setToFilter, setToFilter, setToFilter
            };
            var requirements = new []
            {
                RequirementsForType <int>(presentTrait), RequirementsForType <float>(presentTrait),
                RequirementsForType <bool>(presentTrait), RequirementsForType <Vector2>(presentTrait)
            };

            TraitRequirementFilterTransform.ProcessStage(indices, m_Database.TypeToFilterAction, requirements, ref matchSets);

            // we expect ids > 4 to be filtered from each set, because only IDs 0-4 have the trait.
            var expectedCountAfterFilter = preFilterCount - 3;

            foreach (var set in matchSets)
            {
                Assert.AreEqual(expectedCountAfterFilter, set.Count);
                Assert.True(set.Contains(3));
                Assert.True(set.Contains(4));
            }
        }
        public void SetupBeforeEach()
        {
            m_Db = new MARSDatabase();
            var dbModule = (IModule)m_Db;

            dbModule.LoadModule();

            m_GroupPipeline = new GroupQueryPipeline(m_Db);
            m_GroupPipeline.SetupData();

            m_MatchingData = new SetMatchData
            {
                dataAssignments = new Dictionary <IMRObject, int>(),
                exclusivities   = new Dictionary <IMRObject, Exclusivity>()
            };

            m_Db.GetTraitProvider(out m_FloatTraitProvider);
            m_Db.GetTraitProvider(out m_TagTraitProvider);
            m_Db.GetTraitProvider(out m_Vector2TraitProvider);

            k_Ratings.Clear();
            k_ToDestroy.Clear();
        }
Exemple #7
0
        public void SetupBeforeEach()
        {
            m_Db = new MARSDatabase();
            var dbModule = (IModule)m_Db;

            dbModule.LoadModule();

            m_Db.GetTraitProvider(out m_FloatTraitProvider);
            m_Db.GetTraitProvider(out m_TagTraitProvider);
            m_Db.GetTraitProvider(out m_IntTraitProvider);
            m_Db.GetTraitProvider(out m_Vector2TraitProvider);
            m_Db.GetTraitProvider(out m_PoseTraitProvider);

            var dbOffsetSubscriber = (IUsesCameraOffset)m_Db;

            m_CameraGameObject          = new GameObject();
            dbOffsetSubscriber.provider = m_CameraGameObject.AddComponent <CameraOffsetProvider>();

            m_DataID      = -1;
            m_QueryResult = new QueryResult(m_QueryMatchId);
            m_AllMatchingIDs.Clear();
            m_Ratings.Clear();
        }
 public void AddGetRemoveSemanticTagTraitValue()
 {
     m_Db.GetTraitProvider(out MARSTraitDataProvider <bool> tagTraits);
     AddGetRemove_TraitValue(k_ExampleTraitId, TraitNames.Floor, true);
 }