当前位置: 首页>>代码示例>>C#>>正文


C# Thing.FindAllChildrenBehaviors方法代码示例

本文整理汇总了C#中Thing.FindAllChildrenBehaviors方法的典型用法代码示例。如果您正苦于以下问题:C# Thing.FindAllChildrenBehaviors方法的具体用法?C# Thing.FindAllChildrenBehaviors怎么用?C# Thing.FindAllChildrenBehaviors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thing的用法示例。


在下文中一共展示了Thing.FindAllChildrenBehaviors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TraverseRoom

        /// <summary>This recursively traverses the rooms, stopping when TTL reaches 0, calling YellAtRoom at each stop.</summary>
        /// <remarks>
        /// @@@ TODO: This traversal logic should be centralized for reuse, taking an origin place, function, and options like whether
        ///     to go through closed exits. See 'Future Potential' at: https://wheelmud.codeplex.com/wikipage?title=Sensory%20Messages
        /// </remarks>
        /// <param name="place">The current place (generally a room) to work from.</param>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        /// <param name="sender">The entity that yelled.</param>
        /// <param name="timeToLive">How many rooms to traverse, -1 has no stop.</param>
        /// <param name="visitedPlaces">List of previous rooms that have been yelled at. (No one likes to be screamed at twice.)</param>
        private void TraverseRoom(Thing place, ActionInput actionInput, IController sender, int timeToLive, List<Thing> visitedPlaces)
        {
            if (timeToLive == 0 || visitedPlaces.Contains(place))
            {
                return;
            }

            // Track that we've now traversed to this place.
            visitedPlaces.Add(place);

            // Broadcast the yell request at the specified place.
            place.Eventing.OnCommunicationRequest(this.yellEvent, EventScope.SelfDown);
            if (!this.yellEvent.IsCancelled)
            {
                List<ExitBehavior> exits = place.FindAllChildrenBehaviors<ExitBehavior>();
                foreach (ExitBehavior exit in exits)
                {
                    var opensClosesBehavior = exit.Parent.Behaviors.FindFirst<OpensClosesBehavior>();
                    if (opensClosesBehavior == null || opensClosesBehavior.IsOpen == true)
                    {
                        Thing destination = exit.GetDestination(place);
                        this.TraverseRoom(destination, actionInput, sender, (timeToLive == -1) ? timeToLive : (timeToLive - 1), visitedPlaces);
                    }
                }

                // @@@ TODO: Consider traversing into portal destinations and the like?
                // @@@ TODO: AmbientSenseBehavior or DrownSenseBehavior or whatnot, so one can make an ambient
                //     noise which drowns out the tail end of a quieting yell under the ambient noise, etc.
            }
            else
            {
                // Create a new non-cancelled yell event; just because something suppressed part of the yell
                // doesn't necessarily mean all other branches of the yell should be suppressed too.  IE if
                // something to the west of our position prevents noise from going through there, the noise
                // that was also going northwards shouldn't suddenly stop.
                this.CreateYellEvent(sender.Thing);
            }
        }
开发者ID:Hobbitron,项目名称:WheelMUD,代码行数:48,代码来源:Yell.cs


注:本文中的Thing.FindAllChildrenBehaviors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。