Ejemplo n.º 1
0
        public override Item getOne()
        {
            LampTileComponent component = new LampTileComponent(this.data, this.info.Copy());

            component.containerObject = this.containerObject;
            component.offsetKey       = this.offsetKey;
            return(component);
        }
Ejemplo n.º 2
0
        public override ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement)
        {
            LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <LampMultiTiledObject>(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());
                LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID <LampTileComponent>(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"]]);
            }
        }
Ejemplo n.º 3
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"]));
            string            GUID      = additionalSaveData["GUID"];
            LampTileComponent self      = Revitalize.ModCore.Serializer.DeserializeGUID <LampTileComponent>(additionalSaveData["GUID"]);

            if (ModCore.IsNullOrDefault <LampTileComponent>(self))
            {
                return(null);
            }
            try
            {
                if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
                {
                    LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <LampMultiTiledObject>(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);
        }
Ejemplo n.º 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);
                LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID <LampTileComponent>(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);
            }
        }