Inheritance: VMSerializable
Exemple #1
0
        public VMMarshal Save()
        {
            var ents = new VMEntityMarshal[Entities.Count];
            var threads = new VMThreadMarshal[Entities.Count];
            var mult = new List<VMMultitileGroupMarshal>();

            int i = 0;
            foreach (var ent in Entities)
            {
                if (ent is VMAvatar)
                {
                    ents[i] = ((VMAvatar)ent).Save();
                }
                else
                {
                    ents[i] = ((VMGameObject)ent).Save();
                }
                threads[i++] = ent.Thread.Save();
                if (ent.MultitileGroup.BaseObject == ent)
                {
                    mult.Add(ent.MultitileGroup.Save());
                }
            }

            return new VMMarshal
            {
                Context = Context.Save(),
                Entities = ents,
                Threads = threads,
                MultitileGroups = mult.ToArray(),
                GlobalState = GlobalState,
                PlatformState = PlatformState,
                ObjectId = ObjectId
            };
        }
Exemple #2
0
        public virtual void LoadCrossRef(VMEntityMarshal input, VMContext context)
        {
            Contained = new VMEntity[input.Contained.Length];
            int i = 0;
            foreach (var item in input.Contained) Contained[i++] = context.VM.GetObjectById(item);

            Container = context.VM.GetObjectById(input.Container);
            if (UseWorld && Container != null)
            {
                WorldUI.Container = Container.WorldUI;
                WorldUI.ContainerSlot = ContainerSlot;
            }
        }
Exemple #3
0
        public void SaveEnt(VMEntityMarshal target)
        {
            var newList = new short[MyList.Count];
            int i = 0;
            foreach (var item in MyList) newList[i++] = item;

            var newContd = new short[Contained.Length];
            i = 0;
            foreach (var item in Contained) newContd[i++] = (item == null)?(short)0:item.ObjectID;

            var relArry = new VMEntityRelationshipMarshal[MeToObject.Count];
            i = 0;
            foreach (var item in MeToObject) relArry[i++] = new VMEntityRelationshipMarshal { Target = item.Key, Values = item.Value.ToArray() };

            target.ObjectID = ObjectID;
            target.PersistID = PersistID;
            target.ObjectData = ObjectData;
            target.MyList = newList;

            target.GUID = Object.OBJ.GUID;
            target.MasterGUID = (MasterDefinition == null)?0:MasterDefinition.GUID;

            target.MainParam = MainParam; //parameters passed to main on creation.
            target.MainStackOBJ = MainStackOBJ;

            target.Contained = newContd; //object ids
            target.Container = (Container == null)?(short)0:Container.ObjectID;
            target.ContainerSlot = ContainerSlot;

            target.Attributes = Attributes;
            target.MeToObject = relArry;

            target.DynamicSpriteFlags = DynamicSpriteFlags;
            target.Position = _Position;
        }
Exemple #4
0
        public virtual void Load(VMEntityMarshal input)
        {
            ObjectID = input.ObjectID;
            PersistID = input.PersistID;
            ObjectData = input.ObjectData;
            MyList = new LinkedList<short>(input.MyList);

            MainParam = input.MainParam; //parameters passed to main on creation.
            MainStackOBJ = input.MainStackOBJ;

            if (input.MasterGUID != 0)
            {
                var masterDef = FSO.Content.Content.Get().WorldObjects.Get(input.MasterGUID);
                MasterDefinition = masterDef.OBJ;
                UseTreeTableOf(masterDef);
            }
            else MasterDefinition = null;

            ContainerSlot = input.ContainerSlot;

            Attributes = input.Attributes;
            MeToObject = new Dictionary<ushort, List<short>>();
            foreach (var obj in input.MeToObject)  MeToObject[obj.Target] = new List<short>(obj.Values);

            DynamicSpriteFlags = input.DynamicSpriteFlags;
            Position = input.Position;
        }