/// <summary> /// Constructor /// </summary> /// <param name="markerPrefab">prefab for markers</param> /// <param name="overlayContainer">parent for markers</param> /// <param name="coordToMapPosFunc">function to transform coords to map position</param> public MapGlobalUsersPositionMarkerController(UserMarkerObject markerPrefab, Transform overlayContainer, Func <float, float, Vector3> coordToMapPosFunc) { fetchScenesHandler = new FetchScenesHandler(UPDATE_INTERVAL_INITIAL, UPDATE_INTERVAL_FOREGROUND, UPDATE_INTERVAL_BACKGROUND); markersHandler = new MarkersHandler(markerPrefab, overlayContainer, MAX_MARKERS, coordToMapPosFunc); userPositionHandler = new UserPositionHandler(); markersContainer = overlayContainer; fetchScenesHandler.OnScenesFetched += OnScenesFetched; userPositionHandler.OnPlayerCoordsChanged += OnPlayerCoordsChanged; CommonScriptableObjects.rendererState.OnChange += OnRenderStateChanged; KernelConfig.i.EnsureConfigInitialized().Then(config => { commsRadius = (int)config.comms.commRadius + COMMS_RADIUS_THRESHOLD; OnPlayerCoordsChanged(userPositionHandler.playerCoords); }); OnRenderStateChanged(CommonScriptableObjects.rendererState.Get(), false); }
public void SceneFetcherShouldSetIntervalsCorrectly() { const float INITIAL_INTERVAL = 1; const float FOREGROUND_INTERVAL = 1.5f; const float BACKROUND_INTERVAL = 3.5f; FetchScenesHandler handler = new FetchScenesHandler(INITIAL_INTERVAL, FOREGROUND_INTERVAL, BACKROUND_INTERVAL); Assert.AreEqual(INITIAL_INTERVAL, handler.updateInterval); handler.SetUpdateMode(MapGlobalUsersPositionMarkerController.UpdateMode.FOREGROUND); Assert.AreEqual(INITIAL_INTERVAL, handler.updateInterval, "It should be using INITIAL_INTERVAL interval waiting for the initial fetch"); handler.isFirstFetch = false; handler.SetUpdateMode(MapGlobalUsersPositionMarkerController.UpdateMode.FOREGROUND); Assert.AreEqual(FOREGROUND_INTERVAL, handler.updateInterval); handler.SetUpdateMode(MapGlobalUsersPositionMarkerController.UpdateMode.BACKGROUND); Assert.AreEqual(BACKROUND_INTERVAL, handler.updateInterval); }