示例#1
0
        public bool IsUnlocked(ResourceActivationContext ctxt, LocationAttractionItemProperties props)
        {
            switch (props.RangeAvailability)
            {
            case AttractionRangeAvailability.Always:
                return(true);

            case AttractionRangeAvailability.InRangeAndAfter:
                return(ctxt.CheckEvent("in_range"));

            case AttractionRangeAvailability.OnlyInRange:
                return(ctxt.CheckState("in_range"));
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Starts monitoring an attraction item by setting up a location fence and following
        /// the activation/range rules. Will call back "activate" and "deactivate" based
        /// on these rules.
        /// </summary>
        /// <param name="ctxt"></param>
        /// <param name="actxt"></param>
        /// <param name="item"></param>
        /// <param name="activateItems"></param>
        /// <param name="deactivateItems"></param>
        private void MonitorAttractionItem(
            ResourceActivationContext ctxt,
            ActivatedAttractionContext actxt,
            LocationAttractionItemProperties item,
            IAttractionItemHandler handler)
        {
            bool activated  = false;
            var  wasInRange = ctxt.CheckEvent("in_range");

            Func <bool> checkAutoplay = () =>
            {
                var didPlay = ctxt.CheckEvent("open");

                return(item.AutoplayBehavior == AttractionRangeAutoplayBehavior.Always ||
                       item.AutoplayBehavior == AttractionRangeAutoplayBehavior.Once && !didPlay);
            };

            var autoplay = checkAutoplay();

            if (item.RangeAvailability == AttractionRangeAvailability.Always)
            {
                // Always activate
                activated = true;
                handler.Activate(actxt.Attraction, autoplay);
            }
            else
            {
                if (wasInRange && item.RangeAvailability == AttractionRangeAvailability.InRangeAndAfter)
                {
                    handler.Activate(actxt.Attraction, autoplay);
                }
            }

            var range = item.Range ?? actxt.Range;

            if (range != null && actxt.Attraction.Locations != null)
            {
                m_fencePool.WatchLocations(ctxt.InstanceId, actxt.Attraction.Locations, range,
                                           (locations) =>
                {
                    ctxt.FireEvent("in_range");
                    ctxt.SetState("in_range");

                    // In Range
                    if (!activated || item.RangeAvailability == AttractionRangeAvailability.OnlyInRange)
                    {
                        activated = true;
                        handler.Activate(actxt.Attraction, checkAutoplay());
                    }
                },
                                           () =>
                {
                    ctxt.ClearState("in_range");

                    // Out of range
                    if (item.RangeAvailability == AttractionRangeAvailability.OnlyInRange)
                    {
                        handler.Deactivate(actxt.Attraction);
                    }
                });
            }
            else
            {
                // Items haven't been activated, but there's no range or locations.
                // In this case treat the items as "in range" and activate them.
                if (!activated)
                {
                    ctxt.FireEvent("in_range");
                    ctxt.SetState("in_range");

                    activated = true;
                    handler.Activate(actxt.Attraction, autoplay);
                }
            }
        }
示例#3
0
 public bool IsToDo(ResourceActivationContext ctxt, LocationAttractionItemProperties props)
 {
     return(!ctxt.CheckEvent("complete"));
 }