예제 #1
0
        public override void Load(VMStackFrameMarshal input, VMContext context)
        {
            base.Load(input, context);
            var inR = (VMRoutingFrameMarshal)input;

            Rooms = new Stack<VMRoomPortal>();
            for (int i=inR.Rooms.Length-1; i>=0; i--) Rooms.Push(inR.Rooms[i]);
            CurrentPortal = inR.CurrentPortal;

            ParentRoute = GetParentFrame(); //should be able to, since all arrays are generated left to right, including the stacks.

            WalkTo = (inR.WalkTo == null)?null:new LinkedList<Point>(inR.WalkTo);
            WalkDirection = inR.WalkDirection;
            TargetDirection = inR.TargetDirection;
            IgnoreRooms = inR.IgnoreRooms;

            State = inR.State;
            PortalTurns = inR.PortalTurns;
            WaitTime = inR.WaitTime;
            Timeout = inR.Timeout;
            Retries = inR.Retries;

            AttemptedChair = inR.AttemptedChair;
            TurnTweak = inR.TurnTweak;
            TurnFrames = inR.TurnFrames;

            MoveTotalFrames = inR.MoveTotalFrames;
            MoveFrames = inR.MoveFrames;
            Velocity = inR.Velocity;

            CallFailureTrees = inR.CallFailureTrees;

            IgnoredRooms = new HashSet<VMRoomPortal>(inR.IgnoredRooms);
            AvatarsToConsider = new HashSet<VMAvatar>();

            foreach (var avatar in inR.AvatarsToConsider)
                AvatarsToConsider.Add((VMAvatar)context.VM.GetObjectById(avatar));

            PreviousPosition = inR.PreviousPosition;
            CurrentWaypoint = inR.CurrentWaypoint;

            RoomRouteInvalid = inR.RoomRouteInvalid;
            Slot = inR.Slot; //NULLable
            Target = context.VM.GetObjectById(inR.Target); //object id
            if (inR.Choices != null)
            {
                Choices = new List<VMFindLocationResult>();
                foreach (var c in inR.Choices) Choices.Add(new VMFindLocationResult(c, context));
            }
            else Choices = null;
            CurRoute = (inR.CurRoute == null)?null:new VMFindLocationResult(inR.CurRoute, context); //NULLable
        }
예제 #2
0
파일: VMThread.cs 프로젝트: Daribon/FreeSO
        public VMRoutingFrame PushNewRoutingFrame(VMStackFrame frame, bool failureTrees)
        {
            var childFrame = new VMRoutingFrame
            {
                Routine = frame.Routine,
                Caller = frame.Caller,
                Callee = frame.Callee,
                CodeOwner = frame.CodeOwner,
                StackObject = frame.StackObject,
                Thread = this,
                CallFailureTrees = failureTrees
            };

            Stack.Add(childFrame);
            return childFrame;
        }
예제 #3
0
        private void Init()
        {
            ParentRoute = GetParentFrame();
            if (ParentRoute != null)
            {
                AvatarsToConsider = new HashSet<VMAvatar>(ParentRoute.AvatarsToConsider);
            }
            else
            {
                foreach (var obj in VM.Entities)
                {
                    if (obj is VMAvatar)
                    {
                        var colAvatar = (VMAvatar)obj;
                        var colTopFrame = colAvatar.Thread.Stack.LastOrDefault();

                        if (colTopFrame != null && colTopFrame is VMRoutingFrame)
                        {
                            var colRoute = (VMRoutingFrame)colTopFrame;
                            if (colRoute.WaitTime > 0) AvatarsToConsider.Add(colAvatar);
                        }
                    }
                }
            }
        }