Example #1
0
        /// <summary>
        /// Executes an interaction and optionally advances the resulting script until the game is interactive again.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="obj"></param>
        /// <param name="verb"></param>
        /// <param name="advanceToInteractive"></param>
        /// <returns></returns>
        public Script Interact(Entity sender, Entity obj, LockedVerb verb, bool advanceToInteractive = true)
        {
            AssertThatGetAllInteractionsDoesNotThrow();

            if (!Game.World.Interactive)
            {
                throw new InvalidOperationException(string.Format("World cannot be interacted with."));
            }

            if (!obj.Enabled || !obj.Visible)
            {
                throw new InvalidOperationException(string.Format("Entity {0} cannot be interacted with.", obj));
            }

            var Interactions          = obj.Get <Interaction>().GetInteractions();
            var InteractionsForObject = Interactions.GetFor(sender);
            var InteractionForVerb    = InteractionsForObject[verb];
            var Script = InteractionForVerb(new InteractionContext(sender, obj, null, verb));

            if (advanceToInteractive)
            {
                Advance(() => Script.Done || Script.WaitsforSelection() || null == Game.World);
                AdvanceToInteractive();
            }

            return(Script);
        }
Example #2
0
 /// <summary>
 /// Executes an interaction using the game's main actor.
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="verb"></param>
 /// <param name="advanceToInteractive"></param>
 /// <returns></returns>
 public Script Interact(Entity obj, LockedVerb verb, bool advanceToInteractive = true)
 {
     return(Interact(SessionSeven.Game.Ego, obj, verb, advanceToInteractive));
 }