Пример #1
0
 public void SandboxRestore(VMSandboxRestoreState state)
 {
     Entities               = state.Entities;
     ObjectsById            = state.ObjectsById;
     ObjectId               = state.ObjectId;
     Context.SetToNextCache = state.SetToNext;
 }
Пример #2
0
 public void SandboxRestore(VMSandboxRestoreState state)
 {
     Entities              = state.Entities;
     ObjectsById           = state.ObjectsById;
     ObjectId              = state.ObjectId;
     Context.ObjectQueries = state.ObjectQueries;
     Context.RandomSeed    = state.RandomSeed;
 }
Пример #3
0
        public VMSandboxRestoreState Sandbox()
        {
            var state = new VMSandboxRestoreState {
                Entities = Entities, ObjectId = ObjectId, ObjectsById = ObjectsById
            };

            Entities    = new List <VMEntity>();
            ObjectsById = new Dictionary <short, VMEntity>();
            ObjectId    = 1;

            return(state);
        }
Пример #4
0
        public VMSandboxRestoreState Sandbox()
        {
            var state = new VMSandboxRestoreState {
                Entities    = Entities, ObjectId = ObjectId,
                ObjectsById = ObjectsById, SetToNext = Context.SetToNextCache
            };

            Context.SetToNextCache = new VMSetToNextCache(Context);
            Entities    = new List <VMEntity>();
            ObjectsById = new Dictionary <short, VMEntity>();
            ObjectId    = 1;

            return(state);
        }
Пример #5
0
        public VMSandboxRestoreState Sandbox()
        {
            var state = new VMSandboxRestoreState {
                Entities    = Entities, ObjectId = ObjectId,
                ObjectsById = ObjectsById, ObjectQueries = Context.ObjectQueries, RandomSeed = Context.RandomSeed
            };

            Context.ObjectQueries = new VMObjectQueries(Context);
            Entities    = new List <VMEntity>();
            ObjectsById = new Dictionary <short, VMEntity>();
            ObjectId    = 1;

            return(state);
        }
Пример #6
0
        public bool ExecuteEntryPoint(int entry,VMContext context,bool runImmediately,VMEntity stackOBJ,short[] args)
        {
            if (entry == 11)
            {
                //user placement, hack to do auto floor removal/placement for stairs
                if (Object.OBJ.LevelOffset > 0 && Position != LotTilePos.OUT_OF_WORLD)
                {
                    var floor      = context.Architecture.GetFloor(Position.TileX,Position.TileY,Position.Level);
                    var placeFlags = (VMPlacementFlags)ObjectData[(int)VMStackObjectVariable.PlacementFlags];
                    if ((placeFlags & VMPlacementFlags.InAir) > 0)
                    {
                        context.Architecture.SetFloor(Position.TileX,Position.TileY,Position.Level,new FloorTile(),true);
                    }
                    if ((placeFlags & VMPlacementFlags.OnFloor) > 0 && (floor.Pattern == 0))
                    {
                        context.Architecture.SetFloor(Position.TileX,Position.TileY,Position.Level,new FloorTile {
                            Pattern = 1
                        },true);
                    }
                }
            }

            bool result = false;

            if (EntryPoints[entry].ActionFunction > 255)
            {
                VMSandboxRestoreState SandboxState = null;
                if (GhostImage && runImmediately)
                {
                    SandboxState = context.VM.Sandbox();
                    for (int i = 0; i < MultitileGroup.Objects.Count; i++)
                    {
                        var obj = MultitileGroup.Objects[i];
                        context.VM.AddEntity(obj);
                    }
                }

                BHAV       bhav;
                GameObject CodeOwner;
                ushort     ActionID = EntryPoints[entry].ActionFunction;
                if (ActionID < 4096)
                { //global
                    bhav = context.Globals.Resource.Get <BHAV>(ActionID);
                }
                else if (ActionID < 8192)
                { //local
                    bhav = Object.Resource.Get <BHAV>(ActionID);
                }
                else
                { //semi-global
                    bhav = SemiGlobal.Get <BHAV>(ActionID);
                }

                CodeOwner = Object;

                if (bhav != null)
                {
                    var routine = context.VM.Assemble(bhav);
                    var action  = new VMQueuedAction
                    {
                        Callee    = this,
                        CodeOwner = CodeOwner,
                        /** Main function **/
                        StackObject = stackOBJ,
                        Routine     = routine,
                        Args        = args
                    };

                    if (runImmediately)
                    {
                        var checkResult = VMThread.EvaluateCheck(context,this,action);
                        result = (checkResult == VMPrimitiveExitCode.RETURN_TRUE);
                    }
                    else
                    {
                        this.Thread.EnqueueAction(action);
                    }
                }

                if (GhostImage && runImmediately)
                {
                    //restore state
                    context.VM.SandboxRestore(SandboxState);
                }
                return(result);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
 public void SandboxRestore(VMSandboxRestoreState state)
 {
     Entities = state.Entities;
     ObjectsById = state.ObjectsById;
     ObjectId = state.ObjectId;
     Context.SetToNextCache = state.SetToNext;
 }
Пример #8
0
        public VMSandboxRestoreState Sandbox()
        {
            var state = new VMSandboxRestoreState { Entities = Entities, ObjectId = ObjectId,
                ObjectsById = ObjectsById, SetToNext = Context.SetToNextCache };

            Context.SetToNextCache = new VMSetToNextCache(Context);
            Entities = new List<VMEntity>();
            ObjectsById = new Dictionary<short, VMEntity>();
            ObjectId = 1;

            return state;
        }
Пример #9
0
 public void SandboxRestore(VMSandboxRestoreState state)
 {
     Entities = state.Entities;
     ObjectsById = state.ObjectsById;
     ObjectId = state.ObjectId;
 }
Пример #10
0
        public VMSandboxRestoreState Sandbox()
        {
            var state = new VMSandboxRestoreState { Entities = Entities, ObjectId = ObjectId, ObjectsById = ObjectsById };

            Entities = new List<VMEntity>();
            ObjectsById = new Dictionary<short, VMEntity>();
            ObjectId = 1;

            return state;
        }
Пример #11
0
 public void SandboxRestore(VMSandboxRestoreState state)
 {
     Entities    = state.Entities;
     ObjectsById = state.ObjectsById;
     ObjectId    = state.ObjectId;
 }