public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement)
        {
            Vector2     offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
            string      GUID      = additionalSaveData["GUID"];
            OreVeinTile self      = Revitalize.ModCore.Serializer.DeserializeGUID <OreVeinTile>(additionalSaveData["GUID"]);

            if (ModCore.IsNullOrDefault <OreVeinTile>(self))
            {
                return(null);
            }
            try
            {
                if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
                {
                    OreVeinObj obj = (OreVeinObj)Revitalize.ModCore.Serializer.DeserializeGUID <OreVeinObj>(additionalSaveData["ParentGUID"]);
                    self.containerObject = obj;
                    self.containerObject.removeComponent(offsetKey);
                    self.containerObject.addComponent(offsetKey, self);
                    Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
                }
                else
                {
                    self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
                    self.containerObject.removeComponent(offsetKey);
                    self.containerObject.addComponent(offsetKey, self);
                }
            }
            catch (Exception err)
            {
                ModCore.log(err);
            }

            return(self);
        }
        public override Item getOne()
        {
            OreVeinTile component = new OreVeinTile(this.data, this.info.Copy(), this.resourceInfo, this.extraDrops, this.healthValue);

            component.containerObject = this.containerObject;
            component.offsetKey       = this.offsetKey;
            return(component);
        }
Exemple #3
0
        public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement)
        {
            OreVeinObj obj = (OreVeinObj)Revitalize.ModCore.Serializer.DeserializeGUID <OreVeinObj>(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());
                OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID <OreVeinTile>(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"]]);
            }
        }
Exemple #4
0
        public override void recreate()
        {
            Dictionary <Vector2, Guid> guids = new Dictionary <Vector2, Guid>();

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

            foreach (KeyValuePair <Vector2, Guid> pair in guids)
            {
                this.childrenGuids.Remove(pair.Key);
                OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID <OreVeinTile>(pair.Value.ToString());
                component.InitNetFields();
                this.removeComponent(pair.Key);
                this.addComponent(pair.Key, component);
            }
            this.InitNetFields();

            if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
            {
                Revitalize.ModCore.ObjectGroups.Add(this.guid.ToString(), this);
            }
        }