Exemple #1
0
        /// <summary>
        /// Creates an instance of this (multitile) object in the target VM, out of world.
        /// </summary>
        /// <param name="vm"></param>
        public VMMultitileGroup CreateInstance(VM vm)
        {
            int i = 0;

            foreach (var ent in Entities)
            {
                VMEntity realEnt;
                var      objDefinition = FSO.Content.Content.Get().WorldObjects.Get(ent.GUID);

                var worldObject = vm.Context.MakeObjectComponent(objDefinition);
                var obj         = new VMGameObject(objDefinition, worldObject);
                obj.Load((VMGameObjectMarshal)ent);
                obj.Contained = new VMEntity[ent.Contained.Length]; //we aren't loading slot data, but we need to initialize this.
                obj.Position  = LotTilePos.OUT_OF_WORLD;
                if (VM.UseWorld)
                {
                    vm.Context.Blueprint.AddObject((ObjectComponent)obj.WorldUI);
                    vm.Context.Blueprint.ChangeObjectLocation((ObjectComponent)obj.WorldUI, obj.Position);
                }
                realEnt = obj;
                obj.FetchTreeByName(vm.Context);
                obj.Thread = new VMThread(vm.Context, obj, obj.Object.OBJ.StackSize);

                vm.AddEntity(obj);
                MultitileGroup.Objects[i++] = obj.ObjectID; //update saved group, in multitile group order (as saved)
                if (VM.UseWorld)
                {
                    obj.WorldUI.ObjectID = obj.ObjectID;
                }
                vm.Scheduler.ScheduleTickIn(obj, 1);
            }

            return(new VMMultitileGroup(MultitileGroup, vm.Context)); //should self register
        }
        /// <summary>
        /// Creates an instance of this (multitile) object in the target VM, out of world.
        /// </summary>
        /// <param name="vm"></param>
        public VMMultitileGroup CreateInstance(VM vm, bool ghost)
        {
            int i    = 0;
            var objs = new VMEntity[Entities.Length];

            foreach (var ent in Entities)
            {
                VMEntity realEnt;
                var      objDefinition = FSO.Content.Content.Get().WorldObjects.Get(ent.GUID, false);

                var worldObject = vm.Context.MakeObjectComponent(objDefinition);
                var obj         = new VMGameObject(objDefinition, worldObject);
                obj.Load((VMGameObjectMarshal)ent);
                obj.Contained = new VMEntity[ent.Contained.Length]; //we aren't loading slot data, but we need to initialize this.
                obj.Position  = LotTilePos.OUT_OF_WORLD;
                if (VM.UseWorld)
                {
                    vm.Context.Blueprint.AddObject((ObjectComponent)obj.WorldUI);
                    vm.Context.Blueprint.ChangeObjectLocation((ObjectComponent)obj.WorldUI, obj.Position);
                }
                realEnt = obj;
                obj.FetchTreeByName(vm.Context);
                if (!ghost)
                {
                    obj.Thread = new VMThread(vm.Context, obj, obj.Object.OBJ.StackSize);
                    vm.AddEntity(obj);
                }
                else
                {
                    objs[i] = obj;
                }
                obj.GhostImage = ghost;
                MultitileGroup.Objects[i++] = obj.ObjectID; //update saved group, in multitile group order (as saved)
                if (VM.UseWorld)
                {
                    obj.WorldUI.ObjectID = obj.ObjectID;
                }
                //if (!ghost) vm.InternalTick(obj, 1);
            }
            VMMultitileGroup multi;

            if (ghost)
            {
                multi = new VMMultitileGroup();
                multi.LoadGhost(MultitileGroup, vm.Context, objs);
            }
            else
            {
                multi = new VMMultitileGroup(MultitileGroup, vm.Context);
            }
            return(multi); //should self register
        }