예제 #1
0
        public void Load(VMQueuedActionMarshal input, VMContext context)
        {
            CodeOwner = FSO.Content.Content.Get().WorldObjects.Get(input.CodeOwnerGUID);

            BHAV bhav = null;

            if (input.RoutineID >= 8192)
            {
                bhav = CodeOwner.Resource.SemiGlobal.Get <BHAV>(input.RoutineID);
            }
            else if (input.RoutineID >= 4096)
            {
                bhav = CodeOwner.Resource.Get <BHAV>(input.RoutineID);
            }
            else
            {
                bhav = context.Globals.Resource.Get <BHAV>(input.RoutineID);
            }
            Routine = context.VM.Assemble(bhav);

            Callee            = context.VM.GetObjectById(input.Callee);
            StackObject       = context.VM.GetObjectById(input.StackObject);
            IconOwner         = context.VM.GetObjectById(input.IconOwner);
            Name              = input.Name;
            Args              = input.Args;
            InteractionNumber = input.InteractionNumber;
            Cancelled         = input.Cancelled;
            Priority          = input.Priority;
            Mode              = input.Mode;
            Flags             = input.Flags;
            UID      = input.UID;
            Callback = (input.Callback == null)?null:new VMActionCallback(input.Callback, context);
        }
예제 #2
0
        public void Load(VMQueuedActionMarshal input, VMContext context)
        {
            CodeOwner = FSO.Content.Content.Get().WorldObjects.Get(input.CodeOwnerGUID);

            if (input.RoutineID >= 8192)
            {
                ActionRoutine = (VMRoutine)CodeOwner.Resource.SemiGlobal.GetRoutine(input.RoutineID);
            }
            else if (input.RoutineID >= 4096)
            {
                ActionRoutine = (VMRoutine)CodeOwner.Resource.GetRoutine(input.RoutineID);
            }
            else
            {
                ActionRoutine = (VMRoutine)context.Globals.Resource.GetRoutine(input.RoutineID);
            }

            if (input.CheckRoutineID != 0)
            {
                if (input.CheckRoutineID >= 8192)
                {
                    CheckRoutine = (VMRoutine)CodeOwner.Resource.SemiGlobal.GetRoutine(input.CheckRoutineID);
                }
                else if (input.CheckRoutineID >= 4096)
                {
                    CheckRoutine = (VMRoutine)CodeOwner.Resource.GetRoutine(input.CheckRoutineID);
                }
                else
                {
                    CheckRoutine = (VMRoutine)context.Globals.Resource.GetRoutine(input.CheckRoutineID);
                }
            }

            Callee            = context.VM.GetObjectById(input.Callee);
            StackObject       = context.VM.GetObjectById(input.StackObject);
            IconOwner         = context.VM.GetObjectById(input.IconOwner);
            Name              = input.Name;
            Args              = input.Args;
            InteractionNumber = input.InteractionNumber;
            Cancelled         = input.Cancelled;
            Priority          = input.Priority;
            Mode              = input.Mode;
            Flags             = input.Flags;
            Flags2            = input.Flags2;
            UID      = input.UID;
            Callback = (input.Callback == null)?null:new VMActionCallback(input.Callback, context);

            InteractionResult  = input.InteractionResult;
            ResultCheckCounter = input.ResultCheckCounter;
        }
        public void Deserialize(BinaryReader reader)
        {
            RoutineID      = reader.ReadUInt16();
            CheckRoutineID = reader.ReadUInt16();
            Callee         = reader.ReadInt16();
            StackObject    = reader.ReadInt16();
            IconOwner      = reader.ReadInt16();

            CodeOwnerGUID = reader.ReadUInt32();
            if (reader.ReadBoolean())
            {
                Name = reader.ReadString();
            }

            var argsLen = reader.ReadInt32();

            if (argsLen > -1)
            {
                Args = new short[argsLen];
                for (int i = 0; i < argsLen; i++)
                {
                    Args[i] = reader.ReadInt16();
                }
            }

            InteractionNumber = reader.ReadInt32();
            NotifyIdle        = reader.ReadBoolean();

            Priority = reader.ReadInt16();
            Mode     = (VMQueueMode)reader.ReadByte();
            Flags    = (TTABFlags)reader.ReadUInt32();
            Flags2   = (TSOFlags)reader.ReadUInt32();

            UID = reader.ReadUInt16();

            if (reader.ReadBoolean())
            {
                Callback = new VMActionCallbackMarshal();
                Callback.Deserialize(reader);
            }

            if (Version > 11)
            {
                InteractionResult  = reader.ReadSByte();
                ResultCheckCounter = reader.ReadUInt16();
            }
        }
예제 #4
0
        public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
        {
            var      operand = (VMPushInteractionOperand)args;
            VMEntity interactionSource;

            if ((operand.Flags & (1 << 1)) > 0)
            {
                interactionSource = context.VM.GetObjectById((short)context.Locals[operand.ObjectLocation]);
            }
            else
            {
                interactionSource = context.VM.GetObjectById((short)context.Args[operand.ObjectLocation]);
            }

            short       priority = 0;
            VMQueueMode mode     = VMQueueMode.Normal;

            switch (operand.Priority)
            {
            case VMPushPriority.Inherited:
                short oldPrio = 1;
                if (context.ActionTree)
                {
                    oldPrio = context.Thread.Queue[0].Priority;
                }
                priority = Math.Max((short)1, oldPrio); break;

            case VMPushPriority.Maximum:
                priority = (short)VMQueuePriority.Maximum; break;

            case VMPushPriority.Autonomous:
                priority = (short)VMQueuePriority.Autonomous; break;

            case VMPushPriority.UserDriven:
                priority = (short)VMQueuePriority.UserDriven; break;

            case VMPushPriority.ParentIdle:
                priority = (short)VMQueuePriority.ParentIdle; mode = VMQueueMode.ParentIdle; break;

            case VMPushPriority.ParentExit:
                priority = (short)VMQueuePriority.ParentExit; mode = VMQueueMode.ParentExit; break;

            case VMPushPriority.Idle:
                priority = (short)VMQueuePriority.Idle; mode = VMQueueMode.Idle; break;
            }

            var action = interactionSource.GetAction(operand.Interaction, context.StackObject, context.VM.Context, false);

            if (action == null)
            {
                return(VMPrimitiveExitCode.GOTO_FALSE);
            }
            if (operand.UseCustomIcon)
            {
                action.IconOwner = context.VM.GetObjectById((short)context.Locals[operand.IconLocation]);
            }
            action.Mode     = mode;
            action.Priority = priority;
            action.Flags   |= TTABFlags.MustRun;
            if (operand.PushTailContinuation)
            {
                action.Flags |= TTABFlags.FSOPushTail;
            }
            if (operand.PushHeadContinuation)
            {
                action.Flags |= TTABFlags.Leapfrog;
            }

            context.StackObject.Thread.EnqueueAction(action);

            return(VMPrimitiveExitCode.GOTO_TRUE);
        }
예제 #5
0
        public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
        {
            var      operand = (VMPushInteractionOperand)args;
            VMEntity interactionSource;

            if (operand.ObjectInLocal)
            {
                interactionSource = context.VM.GetObjectById((short)context.Locals[operand.ObjectLocation]);
            }
            else
            {
                interactionSource = context.VM.GetObjectById((short)context.Args[operand.ObjectLocation]);
            }

            short       priority = 0;
            VMQueueMode mode     = VMQueueMode.Normal;

            switch (operand.Priority)
            {
            case VMPushPriority.Inherited:
                short oldPrio = 1;
                if (context.ActionTree)
                {
                    oldPrio = context.Thread.ActiveAction.Priority;
                }
                priority = Math.Max((short)1, oldPrio); break;

            case VMPushPriority.Maximum:
                priority = (short)VMQueuePriority.Maximum; break;

            case VMPushPriority.Autonomous:
                priority = (short)VMQueuePriority.Autonomous; break;

            case VMPushPriority.UserDriven:
                priority = (short)VMQueuePriority.UserDriven; break;

            case VMPushPriority.ParentIdle:
                priority = (short)VMQueuePriority.ParentIdle; mode = VMQueueMode.ParentIdle; break;

            case VMPushPriority.ParentExit:
                priority = (short)VMQueuePriority.ParentExit; mode = VMQueueMode.ParentExit; break;

            case VMPushPriority.Idle:
                priority = (short)VMQueuePriority.Idle; mode = VMQueueMode.Idle; break;
            }

            var action = interactionSource.GetAction(operand.Interaction, context.StackObject, context.VM.Context, false);

            if (action == null)
            {
                return(VMPrimitiveExitCode.GOTO_FALSE);
            }
            if (operand.UseCustomIcon)
            {
                action.IconOwner = context.VM.GetObjectById((short)context.Locals[operand.IconLocation]);
            }
            action.Mode     = mode;
            action.Priority = priority;
            if (!context.VM.TS1)
            {
                action.Flags |= TTABFlags.MustRun;
            }
            else
            {
                action.Flags |= TTABFlags.FSOSkipPermissions;
            }
            if (operand.PushTailContinuation)
            {
                action.Flags |= TTABFlags.FSOPushTail;
            }
            if (operand.PushHeadContinuation)
            {
                action.Flags |= TTABFlags.FSOPushHead;
            }

            context.StackObject.Thread.EnqueueAction(action);
            if (context.StackObject is VMAvatar && context.Caller is VMAvatar && context.StackObject != context.Caller)
            {
                //if this is an interaction between two sims, and this interaction is being pushed onto someone else,
                //show the interaction result chooser for that sim immediately, rather than force them to wait.
                //(erroneously shows up for "talk to" and "whisper to". there may be a better way to do this.
                action.InteractionResult = 0;
            }

            return(VMPrimitiveExitCode.GOTO_TRUE);
        }
예제 #6
0
        public void Deserialize(BinaryReader reader)
        {
            RoutineID = reader.ReadUInt16();
            CheckRoutineID = reader.ReadUInt16();
            Callee = reader.ReadInt16();
            StackObject = reader.ReadInt16();
            IconOwner = reader.ReadInt16();

            CodeOwnerGUID = reader.ReadUInt32();
            if (reader.ReadBoolean()) Name = reader.ReadString();

            var argsLen = reader.ReadInt32();
            if (argsLen > -1)
            {
                Args = new short[argsLen];
                for (int i = 0; i < argsLen; i++) Args[i] = reader.ReadInt16();
            }

            InteractionNumber = reader.ReadInt32();
            Cancelled = reader.ReadBoolean();

            Priority = reader.ReadInt16();
            Mode = (VMQueueMode)reader.ReadByte();
            Flags = (TTABFlags)reader.ReadUInt32();
            Flags2 = (TSOFlags)reader.ReadUInt32();

            UID = reader.ReadUInt16();

            if (reader.ReadBoolean())
            {
                Callback = new VMActionCallbackMarshal();
                Callback.Deserialize(reader);
            }
        }
예제 #7
0
        public void Load(VMQueuedActionMarshal input, VMContext context)
        {
            CodeOwner = FSO.Content.Content.Get().WorldObjects.Get(input.CodeOwnerGUID);

            BHAV bhav = null;
            if (input.RoutineID >= 8192) bhav = CodeOwner.Resource.SemiGlobal.Get<BHAV>(input.RoutineID);
            else if (input.RoutineID >= 4096) bhav = CodeOwner.Resource.Get<BHAV>(input.RoutineID);
            else bhav = context.Globals.Resource.Get<BHAV>(input.RoutineID);
            ActionRoutine = context.VM.Assemble(bhav);

            if (input.CheckRoutineID != 0)
            {
                if (input.CheckRoutineID >= 8192) bhav = CodeOwner.Resource.SemiGlobal.Get<BHAV>(input.CheckRoutineID);
                else if (input.CheckRoutineID >= 4096) bhav = CodeOwner.Resource.Get<BHAV>(input.CheckRoutineID);
                else bhav = context.Globals.Resource.Get<BHAV>(input.CheckRoutineID);
                CheckRoutine = context.VM.Assemble(bhav);
            }

            Callee = context.VM.GetObjectById(input.Callee);
            StackObject = context.VM.GetObjectById(input.StackObject);
            IconOwner = context.VM.GetObjectById(input.IconOwner);
            Name = input.Name;
            Args = input.Args;
            InteractionNumber = input.InteractionNumber;
            Cancelled = input.Cancelled;
            Priority = input.Priority;
            Mode = input.Mode;
            Flags = input.Flags;
            Flags2 = input.Flags2;
            UID = input.UID;
            Callback = (input.Callback == null)?null:new VMActionCallback(input.Callback, context);
        }
예제 #8
0
        public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
        {
            var      operand = (VMPushInteractionOperand)args;
            VMEntity interactionSource;

            if ((operand.Flags & (1 << 1)) > 0)
            {
                interactionSource = context.VM.GetObjectById((short)context.Locals[operand.ObjectLocation]);
            }
            else
            {
                interactionSource = context.VM.GetObjectById((short)context.Args[operand.ObjectLocation]);
            }

            short       priority = 0;
            VMQueueMode mode     = VMQueueMode.Normal;

            switch (operand.Priority)
            {
            case VMPushPriority.Inherited:
                priority = Math.Max((short)1, context.Thread.Queue[0].Priority); break;

            case VMPushPriority.Maximum:
                priority = (short)VMQueuePriority.Maximum; break;

            case VMPushPriority.Autonomous:
                priority = (short)VMQueuePriority.Autonomous; break;

            case VMPushPriority.UserDriven:
                priority = (short)VMQueuePriority.UserDriven; break;

            case VMPushPriority.ParentIdle:
                priority = (short)VMQueuePriority.ParentIdle; mode = VMQueueMode.ParentIdle; break;

            case VMPushPriority.ParentExit:
                priority = (short)VMQueuePriority.ParentExit; mode = VMQueueMode.ParentExit; break;

            case VMPushPriority.Idle:
                priority = (short)VMQueuePriority.Idle; mode = VMQueueMode.Idle; break;
            }

            BHAV       bhav;
            GameObject CodeOwner = null;
            var        Action    = interactionSource.TreeTable.InteractionByIndex[operand.Interaction];
            ushort     ActionID  = Action.ActionFunction;

            CodeOwner = interactionSource.Object;
            if (ActionID < 4096)
            { //global
                bhav = null;
                //unimp as it has to access the context to get this.
            }
            else if (ActionID < 8192)
            { //local
                bhav = interactionSource.Object.Resource.Get <BHAV>(ActionID);
            }
            else
            { //semi-global
                bhav = interactionSource.SemiGlobal.Get <BHAV>(ActionID);
            }

            VMEntity IconOwner = null;

            if (operand.UseCustomIcon)
            {
                IconOwner = context.VM.GetObjectById((short)context.Locals[operand.IconLocation]);
            }

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

            context.StackObject.Thread.EnqueueAction(
                new FSO.SimAntics.Engine.VMQueuedAction
            {
                Callee            = interactionSource,
                CodeOwner         = CodeOwner,
                Routine           = routine,
                Name              = interactionSource.TreeTableStrings.GetString((int)Action.TTAIndex),
                StackObject       = interactionSource,
                InteractionNumber = operand.Interaction,
                IconOwner         = IconOwner,
                Priority          = priority,
                Mode              = mode,
                Flags             = (TTABFlags)Action.Flags | (operand.PushHeadContinuation?TTABFlags.Leapfrog:0)
            }
                );

            return(VMPrimitiveExitCode.GOTO_TRUE);
        }