コード例 #1
0
        public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement)
        {
            //instead of using this.offsetkey.x use get additional save data function and store offset key there

            Vector2             offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
            MultiTiledComponent self      = Revitalize.ModCore.Serializer.DeserializeGUID <MultiTiledComponent>(additionalSaveData["GUID"]);

            if (self == null)
            {
                return(null);
            }

            if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
            {
                //Get new container
                MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <MultiTiledObject>(additionalSaveData["ParentGUID"]);
                self.containerObject = obj;
                obj.addComponent(offsetKey, self);
                //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
                Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj);
            }
            else
            {
                self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
                Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
                //Revitalize.ModCore.log("READD AN OBJECT!!!!");
            }

            return((ICustomObject)self);
        }
コード例 #2
0
        public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement)
        {
            MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <MultiTiledObject>(additionalSaveData["GUID"]);

            if (obj == null)
            {
                return(null);
            }

            Dictionary <Vector2, Guid> guids = new Dictionary <Vector2, Guid>();

            foreach (KeyValuePair <Vector2, Guid> pair in obj.childrenGuids)
            {
                guids.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Vector2, Guid> pair  in guids)
            {
                obj.childrenGuids.Remove(pair.Key);
                //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
                MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID <MultiTiledComponent>(pair.Value.ToString());
                component.InitNetFields();

                obj.addComponent(pair.Key, component);
            }
            obj.InitNetFields();

            if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
            {
                Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj);
                return(obj);
            }
            else
            {
                return(Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]]);
            }
        }