Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Get User Values
            _userPreferences = new List <UserPreference>();

            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null)
            {
                string blockKeyPrefix = string.Format("grid-filter-{0}-", rockBlock.BlockId);

                foreach (var userPreference in rockBlock.GetUserPreferences(blockKeyPrefix))
                {
                    var blockKey = userPreference.Key.Replace(blockKeyPrefix, string.Empty);
                    var keyName  = blockKey.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    if (blockKey.Contains("|") && keyName.Length == 2)
                    {
                        // only load userPreferences that are stored in the {key}|{name} format
                        // and make sure there isn't more than one with the same key
                        if (!_userPreferences.Any(a => a.Key == keyName[0]))
                        {
                            _userPreferences.Add(new UserPreference(keyName[0], keyName[1], userPreference.Value));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Get User Values
            _userValues = new Dictionary <string, string>();

            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null)
            {
                string keyPrefix = string.Format("grid-filter-{0}-", rockBlock.CurrentBlock.Id);

                foreach (var userValue in rockBlock.GetUserValues(keyPrefix))
                {
                    _userValues.Add(userValue.Key.Replace(keyPrefix, string.Empty), userValue.Value);
                }
            }

            string scriptKey = "grid-filter-script";
            string script    = @"
Sys.Application.add_load(function () {

    $('div.grid-filter header').click(function () {
        $('i.toggle-filter', this).toggleClass('icon-chevron-down icon-chevron-up');
        $(this).siblings('div').slideToggle();
    });

});";

            if (!this.Page.ClientScript.IsClientScriptBlockRegistered(scriptKey))
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), scriptKey, script, true);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the selected location.
        /// Note this will redirect to the current page to include a LocationId query parameter if a LocationId parameter in the URL is missing or doesn't match.
        /// </summary>
        /// <param name="rockBlock">The rock block.</param>
        /// <param name="lpLocation">The lp location.</param>
        /// <param name="locationId">The identifier of the location.</param>
        /// <param name="campusId">The campus identifier.</param>
        public static void SetSelectedLocation(RockBlock rockBlock, LocationPicker lpLocation, int?locationId, int campusId)
        {
            if (locationId.HasValue && locationId > 0)
            {
                CheckinManagerHelper.SaveCampusLocationConfigurationToCookie(campusId, locationId);
                var pageParameterLocationId = rockBlock.PageParameter(PageParameterKey.LocationId).AsIntegerOrNull();
                if (!pageParameterLocationId.HasValue || pageParameterLocationId.Value != locationId)
                {
                    var additionalQueryParameters = new Dictionary <string, string>();
                    additionalQueryParameters.Add(PageParameterKey.LocationId, locationId.ToString());
                    rockBlock.NavigateToCurrentPageReference(additionalQueryParameters);
                    return;
                }

                using (var rockContext = new RockContext())
                {
                    if (locationId.HasValue)
                    {
                        lpLocation.SetNamedLocation(NamedLocationCache.Get(locationId.Value));
                    }
                }
            }
            else
            {
                lpLocation.Location = null;
                CheckinManagerHelper.SaveCampusLocationConfigurationToCookie(campusId, null);
            }
        }
Ejemplo n.º 4
0
        private void CreateBlocksBasedOnHeightMap()
        {
            for (int i = 0; i < heightMap.GetLength(0); i++)
            {
                for (int j = 0; j < heightMap.GetLength(1); j++)
                {
                    int blockPillarHeight = heightMap[i, j];

                    for (int k = 0; k < blockPillarHeight; k++)
                    {
                        BlockPosition blockPosition = new BlockPosition(i, k, j);

                        if (k < blockPillarHeight - 2)
                        {
                            result.PlaceBlockAt(RockBlock.GetInstance(), blockPosition);
                        }
                        else if (k < blockPillarHeight - 1)
                        {
                            result.PlaceBlockAt(EarthBlock.GetInstance(), blockPosition);
                        }
                        else
                        {
                            result.PlaceBlockAt(GrassyEarthBlock.GetInstance(), blockPosition);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RockBlockWrapper"/> class.
 /// </summary>
 /// <param name="rockBlock">The rock block.</param>
 /// <param name="blockCache">The BlockCache information that defines this block.</param>
 /// <param name="config">The dashboard configuration for this block.</param>
 public DashboardBlockWrapper(RockBlock rockBlock, BlockCache blockCache, DashboardBlockConfig config)
 {
     _rockBlock  = rockBlock;
     _blockCache = blockCache;
     ShowDelete  = true;
     Config      = config;
 }
        public void TestThatRenderingBlocksInOnePointOneChunkIsDoneProperly()
        {
            Island islandToRender = new Island(31);

            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(18, 2, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(19, 2, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(18, 2, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(19, 2, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(18, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(19, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(18, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(19, 1, 19));

            ChunkPresenter testCandidate = new ChunkPresenter();

            testCandidate.PresentChunk(islandToRender, 1, 1);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData, Is.Not.Null);
            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetWorldY(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetVertices().Length, Is.EqualTo(288));
            Assert.That(lastRenderedChunkData.GetIndices().Length, Is.EqualTo(144));
            Assert.That(lastRenderedChunkData.GetNormals().Length, Is.EqualTo(288));
            Assert.That(lastRenderedChunkData.GetUvCoordinates().Length, Is.EqualTo(192));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        public override bool Execute(RockContext rockContext, WorkflowAction action, object entity, out List <string> errorMessages)
        {
            errorMessages = new List <string>();

            HttpContext httpContext = HttpContext.Current;

            if (httpContext != null)
            {
                System.Web.UI.Page page = httpContext.Handler as System.Web.UI.Page;
                if (page != null)
                {
                    RockBlock workflowEntryBlock = page.ControlsOfTypeRecursive <RockBlock>().FirstOrDefault(x => x.BlockName == "Workflow Entry");
                    if (workflowEntryBlock != null)
                    {
                        workflowEntryBlock.PreRender += (sender, args) =>
                        {
                            NotificationBox notificationBox = workflowEntryBlock.ControlsOfTypeRecursive <NotificationBox>().FirstOrDefault();
                            if (notificationBox != null)
                            {
                                notificationBox.Visible = notificationBox.Visible && !GetAttributeValue(action, "HideStatusMessage").AsBoolean();
                                int index = notificationBox.Parent.Controls.IndexOf(notificationBox);
                                if (index > -1)
                                {
                                    notificationBox.Parent.Controls.AddAt(index + 1, new System.Web.UI.LiteralControl(GetAttributeValue(action, "HTML").ResolveMergeFields(GetMergeFields(action))));
                                }
                            }
                        };
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
        public IEnumerator BlockTypeIsRock()
        {
            RockBlock testCandidate = RockBlock.GetInstance();

            yield return(null);

            Assert.That(testCandidate, Is.Not.Null);
            Assert.That(testCandidate.GetBlockType(), Is.EqualTo(BlockTypes.ROCK));
        }
Ejemplo n.º 9
0
        public static RockBlock GetInstance()
        {
            if (null != instance)
            {
                return(instance);
            }

            instance = new RockBlock();
            return(instance);
        }
Ejemplo n.º 10
0
        public IEnumerator CannotPlaceBlockAboveMaximumHeight()
        {
            Island        testCandidate = new Island(64);
            Block         testBlock     = RockBlock.GetInstance();
            BlockPosition blockPosition = new BlockPosition(63, 256, 63);

            yield return(null);

            Assert.Throws <BlockPositionOutOfBoundsException>(() => testCandidate.PlaceBlockAt(testBlock, blockPosition));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the selected location.
        /// </summary>
        /// <param name="rockBlock">The rock block.</param>
        /// <param name="campus">The campus.</param>
        /// <param name="lpLocation">The lp location.</param>
        /// <returns></returns>
        public static int?GetSelectedLocation(RockBlock rockBlock, CampusCache campus, LocationPicker lpLocation)
        {
            // If the Campus selection has changed, we need to reload the LocationItemPicker with the Locations specific to that Campus.
            lpLocation.NamedPickerRootLocationId = campus.LocationId.GetValueOrDefault();

            // Check the LocationPicker for the Location ID.
            int locationId = lpLocation.NamedLocation?.Id ?? 0;

            if (locationId > 0)
            {
                return(locationId);
            }

            // If not defined on the LocationPicker, check first for a LocationId Page parameter.
            locationId = rockBlock.PageParameter(PageParameterKey.LocationId).AsInteger();

            if (locationId > 0)
            {
                // double check the locationId in the URL is valid for the Campus (just in case it was altered or is no longer valid for the campus)
                var locationCampusId = NamedLocationCache.Get(locationId).CampusId;
                if (locationCampusId != campus.Id)
                {
                    locationId = 0;
                }
            }

            if (locationId > 0)
            {
                CheckinManagerHelper.SaveCampusLocationConfigurationToCookie(campus.Id, locationId);
            }
            else
            {
                // If still not defined, check for cookie setting.
                locationId = CheckinManagerHelper.GetCheckinManagerConfigurationFromCookie().LocationIdFromSelectedCampusId.GetValueOrNull(campus.Id) ?? 0;

                if (locationId > 0)
                {
                    // double check the locationId in the cookie is valid for the Campus (just in case it was altered or is no longer valid for the campus)
                    var locationCampusId = NamedLocationCache.Get(locationId)?.CampusId;
                    if (locationCampusId != campus.Id)
                    {
                        locationId = 0;
                    }
                }

                if (locationId <= 0)
                {
                    return(null);
                }
            }

            return(locationId);
        }
        public IEnumerator LeftFaceIsShownWhenUncovered()
        {
            SolidBlockFaceHidingStrategy testCandidate = new SolidBlockFaceHidingStrategy();

            Block coveredBlock  = RockBlock.GetInstance();
            Block coveringBlock = AirBlock.GetInstance();

            bool result = testCandidate.FaceIsHidden(coveredBlock, coveringBlock, BlockFaceDirections.LEFT);

            yield return(null);

            Assert.IsFalse(result);
        }
Ejemplo n.º 13
0
        public IEnumerator AllBlockFacesAreCovering()
        {
            RockBlock testCandidate = RockBlock.GetInstance();

            yield return(null);

            Assert.IsTrue(testCandidate.GetFrontFaceIsCovering());
            Assert.IsTrue(testCandidate.GetRightFaceIsCovering());
            Assert.IsTrue(testCandidate.GetBackFaceIsCovering());
            Assert.IsTrue(testCandidate.GetLeftFaceIsCovering());
            Assert.IsTrue(testCandidate.GetBottomFaceIsCovering());
            Assert.IsTrue(testCandidate.GetTopFaceIsCovering());
        }
Ejemplo n.º 14
0
        public void GetBlockTest_Succesful()
        {
            Vector3Int size = new Vector3Int(10, 10, 10);

            GridMap.Instance.SetSize(size);
            Vector3Int pos      = new Vector3Int(0, 0, 0);
            Block      newBlock = new RockBlock();

            GridMap.Instance.SetBlock(pos, newBlock);
            Block block = GridMap.Instance.GetBlock(pos);

            Assert.AreEqual(block, newBlock);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Deletes the user preferences.
        /// </summary>
        public void DeleteUserPreferences()
        {
            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null && _userPreferences != null)
            {
                foreach (var userPreference in _userPreferences)
                {
                    rockBlock.DeleteUserPreference(userPreference.Key);
                }

                _userPreferences.Clear();
            }
        }
Ejemplo n.º 16
0
        private void SaveUserValues()
        {
            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null)
            {
                string keyPrefix = string.Format("grid-filter-{0}-", rockBlock.CurrentBlock.Id);

                foreach (var userValue in _userValues)
                {
                    rockBlock.SetUserValue(keyPrefix + userValue.Key, userValue.Value);
                }
            }
        }
Ejemplo n.º 17
0
        private void SaveUserPreferences()
        {
            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null)
            {
                string keyPrefix = string.Format("grid-filter-{0}-", rockBlock.BlockId);

                foreach (var userPreference in _userPreferences)
                {
                    rockBlock.SetUserPreference(string.Format("{0}{1}|{2}", keyPrefix, userPreference.Key, userPreference.Name), userPreference.Value);
                }
            }
        }
Ejemplo n.º 18
0
        public IEnumerator LeftBlockFaceIsVisibleWhenOnLeftIslandEdge()
        {
            Island        testCandidate = new Island(64);
            BlockPosition blockPosition = new BlockPosition(63, 0, 0);

            Block testBlock = RockBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.LEFT, blockPosition);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
        public void TestThatCoveredMiddleBlockIsNotRendered()
        {
            Island islandToRender = new Island(46);

            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 20));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 20));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 20));

            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 20));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 20));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 20));

            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 20));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 20));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 20));

            ChunkPresenter testCandidate = new ChunkPresenter();

            testCandidate.PresentChunk(islandToRender, 2, 1);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData, Is.Not.Null);
            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(2));
            Assert.That(lastRenderedChunkData.GetWorldY(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetVertices().Length, Is.EqualTo(648));
            Assert.That(lastRenderedChunkData.GetIndices().Length, Is.EqualTo(324));
            Assert.That(lastRenderedChunkData.GetNormals().Length, Is.EqualTo(648));
            Assert.That(lastRenderedChunkData.GetUvCoordinates().Length, Is.EqualTo(432));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Deletes all the grid user preferences for all grid filters on the block. If <see cref="UserPreferenceKeyPrefix"/> is set, it will only delete user preferences for the grid filter(s) on the block that has the UserPreferenceKeyPrefix.
        /// </summary>
        public void DeleteUserPreferences()
        {
            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null && _userPreferences != null)
            {
                string keyPrefix = string.Format("grid-filter-{0}-", rockBlock.BlockId) + this.UserPreferenceKeyPrefix;

                foreach (var userPreference in _userPreferences)
                {
                    rockBlock.DeleteUserPreference(string.Format("{0}{1}|{2}", keyPrefix, userPreference.Key, userPreference.Name));
                }

                _userPreferences.Clear();
            }
        }
        /// <summary>
        /// Verifies the block type instance properties to make sure they are compiled and have the attributes updated,
        /// with an option to cancel the loop.
        /// </summary>
        public static void VerifyBlockTypeInstanceProperties(int[] blockTypesIdToVerify, CancellationToken cancellationToken)
        {
            if (blockTypesIdToVerify.Length == 0)
            {
                return;
            }

            foreach (int blockTypeId in blockTypesIdToVerify)
            {
                if (cancellationToken.IsCancellationRequested == true)
                {
                    return;
                }

                try
                {
                    /* 2020-09-04 MDP
                     * Notice that we call BlockTypeCache.Get every time we need data from it.
                     * We do this because the BlockTypeCache get easily get stale due to other threads.
                     */

                    if (BlockTypeCache.Get(blockTypeId)?.IsInstancePropertiesVerified == false)
                    {
                        // make sure that only one thread is trying to compile block types and attributes so that we don't get collisions and unneeded compiler overhead
                        lock ( VerifyBlockTypeInstancePropertiesLockObj )
                        {
                            if (BlockTypeCache.Get(blockTypeId)?.IsInstancePropertiesVerified == false)
                            {
                                using (var rockContext = new RockContext())
                                {
                                    var  blockTypeCache    = BlockTypeCache.Get(blockTypeId);
                                    Type blockCompiledType = blockTypeCache.GetCompiledType();

                                    bool attributesUpdated = RockBlock.CreateAttributes(rockContext, blockCompiledType, blockTypeId);
                                    BlockTypeCache.Get(blockTypeId)?.MarkInstancePropertiesVerified(true);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    // ignore if the block couldn't be compiled, it'll get logged and shown when the page tries to load the block into the page
                    Debug.WriteLine(ex);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Gets the checkin area filter that the (Checkin Manager) block uses.
        /// Determined by 'Area' PageParameter, 'ShowAllAreas' block setting, Cookie or 'CheckInAreaGuid' block setting
        /// </summary>
        /// <param name="rockBlock">The rock block.</param>
        /// <returns></returns>
        public static GroupTypeCache GetCheckinAreaFilter(RockBlock rockBlock)
        {
            // If a Check-in Area query string parameter is defined, it takes precedence.
            Guid?checkinManagerPageParameterCheckinAreaGuid = rockBlock.PageParameter(PageParameterKey.Area).AsGuidOrNull();

            if (checkinManagerPageParameterCheckinAreaGuid.HasValue)
            {
                var checkinManagerPageParameterCheckinArea = GroupTypeCache.Get(checkinManagerPageParameterCheckinAreaGuid.Value);

                if (checkinManagerPageParameterCheckinArea != null)
                {
                    return(checkinManagerPageParameterCheckinArea);
                }
            }

            // If ShowAllAreas is enabled, we won't filter by Check-in Area (unless there was a page parameter).
            if (rockBlock.GetAttributeValue(BlockAttributeKey.ShowAllAreas).AsBoolean())
            {
                return(null);
            }

            // If ShowAllAreas is false, get the area filter from the cookie.
            var checkinManagerCookieCheckinAreaGuid = CheckinManagerHelper.GetCheckinManagerConfigurationFromCookie().CheckinAreaGuid;

            if (checkinManagerCookieCheckinAreaGuid != null)
            {
                var checkinManagerCookieCheckinArea = GroupTypeCache.Get(checkinManagerCookieCheckinAreaGuid.Value);
                if (checkinManagerCookieCheckinArea != null)
                {
                    return(checkinManagerCookieCheckinArea);
                }
            }

            // Next, check the Block AttributeValue.
            var checkinManagerBlockAttributeCheckinAreaGuid = rockBlock.GetAttributeValue(BlockAttributeKey.CheckInAreaGuid).AsGuidOrNull();

            if (checkinManagerBlockAttributeCheckinAreaGuid.HasValue)
            {
                var checkinManagerBlockAttributeCheckinArea = GroupTypeCache.Get(checkinManagerBlockAttributeCheckinAreaGuid.Value);
                if (checkinManagerBlockAttributeCheckinArea != null)
                {
                    return(checkinManagerBlockAttributeCheckinArea);
                }
            }

            return(null);
        }
        public void TestThatIslandIsPresentedInChunks()
        {
            Island toRender = new Island(64);

            toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(15, 0, 15));
            toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(16, 0, 15));
            toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(15, 0, 16));
            toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(16, 0, 16));

            StandardIslandPresenter testCandidate = new StandardIslandPresenter();

            testCandidate.PresentIsland(toRender);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(1));
        }
Ejemplo n.º 24
0
        public IEnumerator TopFaceOfBlockIsVisibleWhenNotFullyCovering()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(0, 4, 0);
            BlockPosition blockPositionTwo = new BlockPosition(0, 5, 0);

            Block testBlock = AirBlock.GetInstance();
            Block neighbor  = RockBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionOne);
            testCandidate.PlaceBlockAt(neighbor, blockPositionTwo);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, blockPositionOne);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
Ejemplo n.º 25
0
        public IEnumerator BackFaceOfBlockIsHiddenWhenCovered()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(0, 0, 24);
            BlockPosition blockPositionTwo = new BlockPosition(0, 0, 23);

            Block testBlock = RockBlock.GetInstance();
            Block neighbor  = RockBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionOne);
            testCandidate.PlaceBlockAt(neighbor, blockPositionTwo);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.BACK, blockPositionOne);

            yield return(null);

            Assert.That(result, Is.EqualTo(true));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Updates the selection from page parameters.
        /// </summary>
        /// <param name="selection">The selection.</param>
        /// <param name="rockBlock">The rock block.</param>
        /// <returns></returns>
        public string UpdateSelectionFromPageParameters(string selection, RockBlock rockBlock)
        {
            string[] selectionValues = selection?.Split('|') ?? new string[] { "" };
            if (selectionValues.Length >= 1)
            {
                // check for either a CampusId or CampusIds parameter
                var campusIds = rockBlock.PageParameter("CampusId")?.SplitDelimitedValues().AsIntegerList();
                campusIds = campusIds ?? rockBlock.PageParameter("CampusIds")?.SplitDelimitedValues().AsIntegerList() ?? new List <int>();

                if (campusIds.Any())
                {
                    var selectedCampusGuids = campusIds.Select(a => CampusCache.Get(a)).Where(a => a != null).Select(a => a.Guid).ToList();

                    selectionValues[0] = selectedCampusGuids.AsDelimited(",");
                    return(selectionValues.ToList().AsDelimited("|"));
                }
            }

            return(selection);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // Get User Values
            _userPreferences = new Dictionary <string, string>();

            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null)
            {
                string keyPrefix = string.Format("grid-filter-{0}-", rockBlock.BlockId);

                foreach (var userPreference in rockBlock.GetUserPreferences(keyPrefix))
                {
                    _userPreferences.Add(userPreference.Key.Replace(keyPrefix, string.Empty), userPreference.Value);
                }
            }

            const string scriptKey = "grid-filter-script";
            const string script    = @"
Sys.Application.add_load(function () {

    $('div.grid-filter header').click(function () {
        $('i.toggle-filter', this).toggleClass('fa-chevron-down fa-chevron-up');
        var $hf = $('input', this).first();
        if($hf.val() != 'true') {
            $hf.val('true');
        } else {
            $hf.val('false');
        }
        $(this).siblings('div').slideToggle();
    });

});";

            if (!this.Page.ClientScript.IsStartupScriptRegistered(scriptKey))
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), scriptKey, script, true);
            }
        }
Ejemplo n.º 28
0
    /// <summary>
    /// タグの変更
    /// </summary>
    private void ChangeTag()
    {
        Transform parent = transform.parent;

        if (MyUtility.NullCheck(parent))
        {
            return;
        }

        RockBlock rockBlock = parent.GetComponent <RockBlock>();

        if (MyUtility.NullCheck(rockBlock))
        {
            return;
        }



        if (Mathf.Abs(rockBlock.moveVector.y) > 0)
        {
            transform.tag = "DangerObject";
            return;
        }

        if (rockBlock.state.Equals(RockBlockState.MOVE))
        {
            transform.tag = "DangerObject";
            return;
        }

        if (
            (GameObject.FindGameObjectWithTag("Player").transform.position - transform.position).magnitude <= 0.2f
            )
        {
            transform.tag = "DangerObject";
            return;
        }

        transform.tag = "Untagged";
    }
Ejemplo n.º 29
0
        /// <summary>
        /// Saves the user preferences.
        /// </summary>
        private void SaveUserPreferences()
        {
            RockBlock rockBlock = this.RockBlock();

            if (rockBlock != null)
            {
                string keyPrefix = string.Format("grid-filter-{0}-", rockBlock.BlockId);

                foreach (var userPreference in _userPreferences)
                {
                    string keyPrefixUserPreferenceKey = string.Format("{0}{1}|", keyPrefix, userPreference.Key);
                    string key = string.Format("{0}{1}", keyPrefixUserPreferenceKey, userPreference.Name);

                    // No duplicate user preference key values before the '|' are allowed.
                    // This search for any keys that match before the '|' but mismatch after '|' and delete it before writing the user preference.
                    int?personEntityTypeId = EntityTypeCache.Get(Person.USER_VALUE_ENTITY).Id;

                    using (var rockContext = new Rock.Data.RockContext())
                    {
                        var attributeService = new Model.AttributeService(rockContext);
                        var attributes       = attributeService
                                               .Queryable()
                                               .Where(a => a.EntityTypeId == personEntityTypeId)
                                               .Where(a => a.Key.StartsWith(keyPrefixUserPreferenceKey))
                                               .Where(a => a.Key != key);

                        if (attributes.Count() != 0)
                        {
                            foreach (var attribute in attributes)
                            {
                                rockBlock.DeleteUserPreference(attribute.Key);
                            }
                        }
                        rockContext.SaveChanges();
                    }

                    rockBlock.SetUserPreference(key, userPreference.Value);
                }
            }
        }
Ejemplo n.º 30
0
    /// <summary>
    /// 左右に衝突したか?( true : 衝突した | false : 衝突してない )
    /// </summary>
    public bool IsCollidedLeftOrRight()
    {
        Transform parent = transform.parent;

        if (MyUtility.NullCheck(parent))
        {
            return(false);
        }

        RockBlock rockBlock = parent.GetComponent <RockBlock>();

        if (MyUtility.NullCheck(rockBlock))
        {
            return(false);
        }



        int iLayerMask = (1 << LayerMask.NameToLayer("BackGround")) | (1 << LayerMask.NameToLayer("Cloud"));

        iLayerMask = ~iLayerMask;
        RaycastHit2D[] hits =
        {
            Physics2D.Raycast(transform.position, Vector3.right, 10.0f, iLayerMask),
            Physics2D.Raycast(transform.position, Vector3.left,  10.0f, iLayerMask),
        };

        RaycastHit2D hit = (rockBlock.rotateDirection.Equals(MyDirection.Right)) ? hits[0] : hits[1];

        if (hit.collider && !hit.transform.name.Contains("RockBlockPart"))
        {
            float fDistance = Vector3.Distance(hit.point, transform.position);
            return(GetSize().x / 2 + 0.2f >= fDistance);
        }



        return(false);
    }