Ejemplo n.º 1
0
        public void PushUserInteraction(int interaction,VMEntity caller,VMContext context,short[] args)
        {
            if (!TreeTable.InteractionByIndex.ContainsKey((uint)interaction))
            {
                return;
            }
            var    Action   = TreeTable.InteractionByIndex[(uint)interaction];
            ushort ActionID = Action.ActionFunction;

            var function = GetBHAVWithOwner(ActionID,context);

            if (function == null)
            {
                return;
            }

            VMEntity carriedObj = caller.GetSlot(0);

            var routine = context.VM.Assemble(function.bhav);

            caller.Thread.EnqueueAction(
                new FSO.SimAntics.Engine.VMQueuedAction
            {
                Callee            = this,
                CodeOwner         = function.owner,
                Routine           = routine,
                Name              = TreeTableStrings.GetString((int)Action.TTAIndex),
                StackObject       = this,
                Args              = args,
                InteractionNumber = interaction,
                Priority          = (short)VMQueuePriority.UserDriven,
                Flags             = (TTABFlags)Action.Flags
            }
                );
        }
Ejemplo n.º 2
0
        private VMEntity DeepestObjInSlot(VMEntity pt, int depth)
        {
            //todo: make sure nobody can create cyclic slots, and limit slot depth
            if (depth > 50)
            {
                throw new Exception("slot depth too high!");
            }
            var slots = pt.TotalSlots();

            for (int i = 0; i < slots; i++)
            {
                var ent = pt.GetSlot(i);
                if (ent != null)
                {
                    return(DeepestObjInSlot(ent, depth++));
                }
            }
            return(pt);
        }
Ejemplo n.º 3
0
        public void PushUserInteraction(int interaction, VMEntity caller, VMContext context)
        {
            if (!TreeTable.InteractionByIndex.ContainsKey((uint)interaction)) return;
            var Action = TreeTable.InteractionByIndex[(uint)interaction];
            ushort ActionID = Action.ActionFunction;

            var function = GetBHAVWithOwner(ActionID, context);

            VMEntity carriedObj = caller.GetSlot(0);

            var routine = context.VM.Assemble(function.bhav);
            caller.Thread.EnqueueAction(
                new FSO.SimAntics.Engine.VMQueuedAction
                {
                    Callee = this,
                    CodeOwner = function.owner,
                    Routine = routine,
                    Name = TreeTableStrings.GetString((int)Action.TTAIndex),
                    StackObject = this,
                    Args = ((Action.MaskFlags & InteractionMaskFlags.AvailableWhenCarrying) > 0)
                        ? new short[] { (carriedObj == null)?(short)0:carriedObj.ObjectID, 0, 0, 0 }:null,
                    InteractionNumber = interaction,
                    Priority = VMQueuePriority.UserDriven
                }
            );
        }