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


C# VMStackFrame.GetCurrentOperand方法代码示例

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


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

示例1: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMGenericTSOCallOperand>();

            if (
                operand.Call == VMGenericTSOCallMode.GetIsPendingDeletion ||
                operand.Call == VMGenericTSOCallMode.IsTemp0AvatarIgnoringTemp1Avatar ||
                operand.Call == VMGenericTSOCallMode.IsGlobalBroken
                ) return VMPrimitiveExitCode.GOTO_FALSE;
            else if (operand.Call == VMGenericTSOCallMode.SwapMyAndStackObjectsSlots)
            {
                int total = Math.Min(context.StackObject.TotalSlots(), context.Caller.TotalSlots());
                for (int i = 0; i < total; i++)
                {
                    VMEntity temp1 = context.Caller.GetSlot(i);
                    VMEntity temp2 = context.StackObject.GetSlot(i);
                    context.Caller.ClearSlot(i);
                    context.StackObject.ClearSlot(i);
                    context.Caller.PlaceInSlot(temp2, i);
                    context.StackObject.PlaceInSlot(temp1, i);
                }
            }
            else if (operand.Call == VMGenericTSOCallMode.TestStackObject) return (context.StackObject != null) ? VMPrimitiveExitCode.GOTO_TRUE : VMPrimitiveExitCode.GOTO_FALSE;
            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:25,代码来源:VMGenericTSOCall.cs

示例2: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMPlaySoundOperand>();
            FWAV fwav = context.CodeOwner.Get<FWAV>(operand.EventID);
            if (fwav == null) fwav = context.VM.Context.Globals.Resource.Get<FWAV>(operand.EventID);

            if (fwav != null)
            {
                var thread = HITVM.Get().PlaySoundEvent(fwav.Name);
                if (thread != null)
                {
                    var owner = (operand.StackObjAsSource)?context.StackObject:context.Caller;

                    if (!thread.AlreadyOwns(owner.ObjectID)) thread.AddOwner(owner.ObjectID);

                    var entry = new VMSoundEntry()
                    {
                        Thread = thread,
                        Pan = !operand.NoPan,
                        Zoom = !operand.NoZoom,
                        Loop = operand.Loop,
                        Name = fwav.Name
                    };
                    owner.SoundThreads.Add(entry);
                    owner.TickSounds();
                }
            }

            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:30,代码来源:VMPlaySound.cs

示例3: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMLookTowardsOperand>();
            //TODO: primitive fails if object calls it
            VMAvatar sim = (VMAvatar)context.Caller;

            var result = new VMFindLocationResult();
            result.Position = new LotTilePos(sim.Position);

            switch (operand.Mode)
            {
                case VMLookTowardsMode.HeadTowardsObject:
                    return VMPrimitiveExitCode.GOTO_TRUE; //TODO: turning head towards things, with head seek timeout
                case VMLookTowardsMode.BodyTowardsCamera:
                    return VMPrimitiveExitCode.GOTO_TRUE; //does not work in TSO
                case VMLookTowardsMode.BodyTowardsStackObj:
                    result.RadianDirection = (float)GetDirectionTo(sim.Position, context.StackObject.Position);
                    result.Flags = RadianToFlags(result.RadianDirection);
                    break;
                case VMLookTowardsMode.BodyAwayFromStackObj:
                    result.RadianDirection = (float)GetDirectionTo(sim.Position, context.StackObject.Position);
                    result.RadianDirection = (float)((result.RadianDirection + Math.PI) % (Math.PI*2));
                    result.Flags = RadianToFlags(result.RadianDirection);
                    break;

            }

            var pathFinder = context.Thread.PushNewPathFinder(context, new List<VMFindLocationResult>() { result });
            if (pathFinder != null) return VMPrimitiveExitCode.CONTINUE;
            else return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:31,代码来源:VMLookTowards.cs

示例4: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMGotoRelativePositionOperand>();

            var obj = (VMGameObject)context.Callee;
            var avatar = (VMAvatar)context.Caller;

            /**
             * Examples for reference
             * Fridge - Have Snack - In front of, facing
             */
            if (operand.Location == VMGotoRelativeLocation.InFrontOf){
                /** Need to work out which side is in front? **/

                //TODO: My positions are wrong, what i call left front etc is wrong. Need to correct this eventually
                var location = obj.Position;
                switch(obj.Direction){
                    case tso.world.model.Direction.LeftFront:
                        location += new Vector3(0.0f, 1.0f, 0.0f);
                        break;
                    case tso.world.model.Direction.LeftBack:
                        location += new Vector3(-1.0f, 0.0f, 0.0f);
                        break;
                    case tso.world.model.Direction.RightFront:
                        location += new Vector3(1.0f, 0.0f, 0.0f);
                        break;
                    case tso.world.model.Direction.RightBack:
                        location += new Vector3(0.0f, -1.0f, 0.0f);
                        break;
                }
                avatar.Position = location + new Vector3(0.5f, 0.5f, 0.0f);
                return VMPrimitiveExitCode.GOTO_TRUE_NEXT_TICK;
            }
            throw new Exception("Unknown goto relative");
        }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:35,代码来源:VMGotoRelativePosition.cs

示例5: Execute

        //TODO: Behaviour for being notified out of idle and interaction canceling
        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMIdleForInputOperand>();

            if (operand.AllowPush == 1 && context.Thread.Queue.Count > 1)
            { //if there are any more interactions, we have been interrupted
                return VMPrimitiveExitCode.INTERRUPT;
            }

            if (context.Thread.Queue[0].Cancelled)
            {
                context.Caller.SetFlag(VMEntityFlags.NotifiedByIdleForInput, true);
                return VMPrimitiveExitCode.GOTO_TRUE;
            }

            if (context.Caller.Interrupt)
            {
                context.Caller.Interrupt = false;
                return VMPrimitiveExitCode.GOTO_TRUE;
            }

            var ticks = VMMemory.GetVariable(context, TSO.Simantics.engine.scopes.VMVariableScope.Parameters, operand.StackVarToDec);
            ticks--;

            if (ticks < 0)
            {
                return VMPrimitiveExitCode.GOTO_TRUE;
            }
            else
            {
                VMMemory.SetVariable(context, TSO.Simantics.engine.scopes.VMVariableScope.Parameters, operand.StackVarToDec, ticks);
                return VMPrimitiveExitCode.CONTINUE_NEXT_TICK;
            }
        }
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:35,代码来源:VMIdleForInput.cs

示例6: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMChangeSuitOrAccessoryOperand>();

            var avatar = (VMAvatar)context.Caller;

            if ((operand.Flags & VMChangeSuitOrAccessoryFlags.Update) == VMChangeSuitOrAccessoryFlags.Update)
            { //update outfit with outfit in stringset 304 with index in temp 0
                avatar.BodyOutfit = Convert.ToUInt64(context.Callee.Object.Resource.Get<STR>(304).GetString((context.Thread.TempRegisters[0])), 16);
            }
            else
            {
                var suit = VMMemory.GetSuit(context, operand.SuitScope, operand.SuitData);
                if(suit == null){
                    return VMPrimitiveExitCode.GOTO_TRUE;
                }

                if ((operand.Flags & VMChangeSuitOrAccessoryFlags.Remove) == VMChangeSuitOrAccessoryFlags.Remove)
                {
                    avatar.Avatar.RemoveAccessory(suit);
                }
                else
                {
                    avatar.Avatar.AddAccessory(suit);
                }
            }

            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:29,代码来源:VMChangeSuitOrAccessory.cs

示例7: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMRunTreeByNameOperand>();

            string name;

            if (operand.StringScope == 1)
            {//global
                name = context.Global.Resource.Get<STR>(operand.StringTable).GetString(operand.StringID-1);
            }
            else
            {//local
                name = context.CodeOwner.Get<STR>(operand.StringTable).GetString(operand.StringID-1);
            }

            if (context.Callee.TreeByName.ContainsKey(name))
            {
                var tree = context.Callee.TreeByName[name];
                //found it! now lets call the tree ;)
            }
            else
            {
                return VMPrimitiveExitCode.GOTO_FALSE;
            }

            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:sector-c,项目名称:Project-Dollhouse,代码行数:27,代码来源:VMRunTreeByName.cs

示例8: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMRefreshOperand>();
            VMEntity target = null;
            switch (operand.TargetObject)
            {
                case 0:
                    target = context.Caller;
                    break;
                case 1:
                    target = context.StackObject;
                    break;
            }

            switch (operand.RefreshType)
            {
                case 0: //graphic
                    if (target.GetType() == typeof(VMGameObject))
                    {
                        var TargObj = (VMGameObject)target;
                        TargObj.RefreshGraphic();
                    }
                    break;
            }

            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:27,代码来源:VMRefresh.cs

示例9: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMGotoRelativePositionOperand>();

            var obj = context.StackObject;
            var avatar = (VMAvatar)context.Caller;

            if (obj.Position == LotTilePos.OUT_OF_WORLD) return VMPrimitiveExitCode.GOTO_FALSE;

            var result = new VMFindLocationResult();
            LotTilePos relative;
            int intDir = (int)Math.Round(Math.Log((double)obj.Direction, 2));

            /**
             * Examples for reference
             * Fridge - Have Snack - In front of, facing
             */
            if (operand.Location == VMGotoRelativeLocation.OnTopOf)
            {
                relative = new LotTilePos(0, 0, obj.Position.Level);
                result.Position = new LotTilePos(obj.Position);
                //result.Flags = (SLOTFlags)obj.Direction;
            }
            else
            {
                int dir;
                if (operand.Location == VMGotoRelativeLocation.AnywhereNear) dir = (int)context.VM.Context.NextRandom(8);
                else dir = ((int)operand.Location + intDir) % 8;

                relative = Positions[dir];

                var location = obj.Position;
                location += relative;
                result.Position = location;
            }
            //throw new Exception("Unknown goto relative");

            if (operand.Direction == VMGotoRelativeDirection.Facing)
            {
                result.RadianDirection = (float)GetDirectionTo(relative, new LotTilePos(0, 0, relative.Level));
                result.Flags = RadianToFlags(result.RadianDirection);
            }
            else if (operand.Direction == VMGotoRelativeDirection.AnyDirection)
            {
                result.RadianDirection = 0;
                result.Flags = SLOTFlags.NORTH;
            }
            else
            {
                var dir = ((int)operand.Direction + intDir) % 8;
                result.RadianDirection = (float)dir*(float)(Math.PI/4.0);
                if (result.RadianDirection > Math.PI) result.RadianDirection -= (float)(Math.PI * 2.0);
                result.Flags = (SLOTFlags)(1<<(int)dir);
            }

            var pathFinder = context.Thread.PushNewPathFinder(context, new List<VMFindLocationResult>() { result });
            if (pathFinder != null) return VMPrimitiveExitCode.CONTINUE;
            else return VMPrimitiveExitCode.GOTO_FALSE;
        }
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:59,代码来源:VMGotoRelativePosition.cs

示例10: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMTransferFundsOperand>();
            /** Bit of a legacy thing going on here so there is a helper to translate old owner values into the new scope handler **/
            var ammount = VMMemory.GetVariable(context, operand.GetAmmountOwner(), operand.AmmountData);

            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:8,代码来源:VMTransferFunds.cs

示例11: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMFindBestObjectForFunctionOperand>();

            var entities = context.VM.Entities;

            int bestScore = int.MinValue;
            VMEntity bestObj = null;

            var entry = VMFindBestObjectForFunction.FunctionToEntryPoint[operand.Function];
            for (int i=0; i<entities.Count; i++) {
                var ent = entities[i];
                if (ent.ObjectData[(int)VMStackObjectVariable.LockoutCount] > 0) continue; //this object is not important!!!
                if (ent.EntryPoints[entry].ActionFunction != 0) {
                    bool Execute;
                    if (ent.EntryPoints[entry].ConditionFunction != 0) {

                        var Behavior = ent.GetBHAVWithOwner(ent.EntryPoints[entry].ConditionFunction, context.VM.Context);

                        var test = VMThread.EvaluateCheck(context.VM.Context, context.Caller, new VMQueuedAction(){
                            Callee = ent,
                            CodeOwner = Behavior.owner,
                            StackObject = ent,
                            Routine = context.VM.Assemble(Behavior.bhav),
                        });

                        Execute = (test == VMPrimitiveExitCode.RETURN_TRUE);

                    } else {
                        Execute = true;
                    }

                    if (Execute)
                    {
                        //calculate the score for this object.
                        int score = 0;
                        if (ScoreVar[operand.Function] != VMStackObjectVariable.Invalid) {
                            score = ent.GetValue(ScoreVar[operand.Function]);
                        }

                        LotTilePos posDiff = ent.Position - context.Caller.Position;
                        score -= (int)Math.Sqrt(posDiff.x*posDiff.x+posDiff.y*posDiff.y)/3;

                        if (score > bestScore)
                        {
                            bestScore = score;
                            bestObj = ent;
                        }
                    }
                }
            }

            if (bestObj != null)
            {
                context.StackObject = bestObj;
                return VMPrimitiveExitCode.GOTO_TRUE;
            } else return VMPrimitiveExitCode.GOTO_FALSE; //couldn't find an object! :'(
        }
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:58,代码来源:VMFindBestObjectForFunction.cs

示例12: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMGotoRoutingSlotOperand>();

            var slot = VMMemory.GetSlot(context, operand.Type, operand.Data);
            var obj = context.StackObject;
            var avatar = (VMAvatar)context.Caller;

            /**
             * How we should be going about this:
             *
             * Step 1: Evaluate possible positons for sim to route to
             * Step 2: Eliminate all positions intersected by an object that does not allow person intersection
             * Step 3: Evaluate routes to all positions, choose shortest route and eliminate all positions that we cannot route to (ignoring people).
             * Step 4: Route to position. Stop when the next tile has a person in it and ask them to move if possible.
             *
             **/

            //slot.Rsflags = TSO.Files.formats.iff.chunks.SLOTFlags.WEST;

            /**
             * Very little is kown about SLOTs so for now this is a place to dump comments
             *
             * Slots measure proximity in units of 16. 16 = 1 tile away from the object.
             * Global slots are in global.iff in a slot table with ID 100.
             * global.iff also has a string table #257 which provides labels for the SLOTs
             */

            //Routing slots must be type 3.
            if (slot.Type == 3){
                var tilePosition = new Vector2(obj.Position.X, obj.Position.Y);

                var possibleTargets = VMSlotParser.FindAvaliableLocations(obj, slot, context.VM.Context);
                if (possibleTargets.Count == 0){
                    return VMPrimitiveExitCode.GOTO_FALSE;
                }

                //TODO: Route finding and pick best route
                var target = possibleTargets[0];

                var pathFinder = context.Thread.PushNewPathFinder(context, possibleTargets);
                if (pathFinder != null) return VMPrimitiveExitCode.CONTINUE;
                else return VMPrimitiveExitCode.GOTO_FALSE;

                //var test = new VMPathFinder();
                //test.Caller = context.Caller;
                //test.Routine = context.Routine;
                //test.InitRoutes(possibleTargets);

                //avatar.SetPersonData(TSO.Simantics.model.VMPersonDataVariable.RouteEntryFlags, (short)target.Flags);
                //avatar.Direction = (Direction)target.Flags;
                //avatar.Position = new Vector3(target.Position.X + 0.5f, target.Position.Y + 0.5f, 0.0f);
            }

            return VMPrimitiveExitCode.GOTO_TRUE_NEXT_TICK;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:56,代码来源:VMGotoRoutingSlot.cs

示例13: Execute

 public override VMPrimitiveExitCode Execute(VMStackFrame context)
 {
     //TODO: Implement this.
     var operand = context.GetCurrentOperand<VMSetBalloonHeadlineOperand>();
     if (operand.Duration == 0)
     {
         /** Clear **/
     }
     return VMPrimitiveExitCode.GOTO_TRUE;
 }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:10,代码来源:VMSetBalloonHeadline.cs

示例14: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMSetToNextOperand>();
            var targetValue = VMMemory.GetVariable(context, operand.GetTargetOwner(), operand.GetTargetData());

            if (operand.SearchType == VMSetToNextSearchType.ObjectOfType){
                //TODO: Implement!
                return VMPrimitiveExitCode.GOTO_FALSE;
            }
            throw new Exception("Unknown search type");
        }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:11,代码来源:VMSetToNext.cs

示例15: Execute

        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var operand = context.GetCurrentOperand<VMRandomNumberOperand>();

            var rangeValue = (ushort)VMMemory.GetVariable(context, operand.RangeScope, operand.RangeData);

            var result = context.VM.Context.NextRandom(rangeValue);
            VMMemory.SetVariable(context, operand.DestinationScope, operand.DestinationData, (short)result);
            if (operand.RangeData == 8327) result = 0;
            return VMPrimitiveExitCode.GOTO_TRUE;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:11,代码来源:VMRandomNumber.cs


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