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"]));
            ChairTileComponent self      = Revitalize.ModCore.Serializer.DeserializeGUID <ChairTileComponent>(additionalSaveData["GUID"]);

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

            if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
            {
                //Get new container
                ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <ChairMultiTiledObject>(additionalSaveData["ParentGUID"]);
                self.containerObject = obj;
                obj.addComponent(offsetKey, self);
                //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
                Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], 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);
        }
        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"];
            ChairTileComponent self      = Revitalize.ModCore.Serializer.DeserializeGUID <ChairTileComponent>(additionalSaveData["GUID"]);

            if (ModCore.IsNullOrDefault <ChairTileComponent>(self))
            {
                return(null);
            }
            try
            {
                if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
                {
                    ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <ChairMultiTiledObject>(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 ICustomObject recreate(Dictionary <string, string> additionalSaveData, object replacement)
        {
            ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID <ChairMultiTiledObject>(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());
                ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID <ChairTileComponent>(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"]]);
            }
        }
Esempio n. 4
0
        private void loadContent()
        {
            MultiTiledComponent obj  = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.Red, true, null, null));
            MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red, false, null, null));
            MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null));


            obj.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj);

            MultiTiledObject bigObject = new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null));

            bigObject.addComponent(new Vector2(0, 0), obj);
            bigObject.addComponent(new Vector2(1, 0), obj2);
            bigObject.addComponent(new Vector2(2, 0), obj3);

            Recipe pie = new Recipe(new Dictionary <Item, int>()
            {
                [bigObject] = 1
            }, new KeyValuePair <Item, int>(new Furniture(3, Vector2.Zero), 1), new StatCost(100, 50, 0, 0));



            Framework.Objects.Furniture.ChairTileComponent chairTop = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Basic.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Framework.Graphics.TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, false, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary <string, List <Animation> >()
            {
                { "Default_" + (int)Framework.Enums.Direction.Down, new List <Animation>()
                  {
                      new Animation(new Rectangle(0, 0, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Down, new List <Animation>()
                  {
                      new Animation(new Rectangle(0, 0, 16, 16))
                  } },
                { "Default_" + (int)Framework.Enums.Direction.Right, new List <Animation>()
                  {
                      new Animation(new Rectangle(16, 0, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Right, new List <Animation>()
                  {
                      new Animation(new Rectangle(16, 0, 16, 16))
                  } },
                { "Default_" + (int)Framework.Enums.Direction.Up, new List <Animation>()
                  {
                      new Animation(new Rectangle(32, 0, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Up, new List <Animation>()
                  {
                      new Animation(new Rectangle(32, 32, 16, 32))
                  } },
                { "Default_" + (int)Framework.Enums.Direction.Left, new List <Animation>()
                  {
                      new Animation(new Rectangle(48, 0, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Left, new List <Animation>()
                  {
                      new Animation(new Rectangle(48, 0, 16, 16))
                  } }
            }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(false));
            Framework.Objects.Furniture.ChairTileComponent chairBottom = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Basic.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Framework.Graphics.TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, false, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16)), new Dictionary <string, List <Animation> >()
            {
                { "Default_" + (int)Framework.Enums.Direction.Down, new List <Animation>()
                  {
                      new Animation(new Rectangle(0, 16, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Down, new List <Animation>()
                  {
                      new Animation(new Rectangle(0, 16, 16, 16))
                  } },
                { "Default_" + (int)Framework.Enums.Direction.Right, new List <Animation>()
                  {
                      new Animation(new Rectangle(16, 16, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Right, new List <Animation>()
                  {
                      new Animation(new Rectangle(16, 16, 16, 16))
                  } },
                { "Default_" + (int)Framework.Enums.Direction.Up, new List <Animation>()
                  {
                      new Animation(new Rectangle(32, 16, 16, 16))
                  } },
                { "Sitting_" + (int)Framework.Enums.Direction.Up, new List <Animation>()
                  {
                      new Animation(new Rectangle(48, 32, 16, 32))
                  } },
                { "Default_" + (int)Framework.Enums.Direction.Left, new List <Animation>()
                  {
                      new Animation(new Rectangle(48, 16, 16, 16))
                  } },
                { "Sitting" + (int)Framework.Enums.Direction.Left, new List <Animation>()
                  {
                      new Animation(new Rectangle(48, 16, 16, 16))
                  } }
            }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(true));


            Framework.Objects.Furniture.ChairMultiTiledObject oakChair = new Framework.Objects.Furniture.ChairMultiTiledObject(new BasicItemInformation("Oak Chair", "A wood chair you can place anywhere.", "Chair", Color.White, -300, 0, true, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Revitalize.Framework.Objects.Furniture.ChairMultiTiledObject), null, new AnimationManager(), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager()));
            oakChair.addComponent(new Vector2(0, -1), chairTop);
            oakChair.addComponent(new Vector2(0, 0), chairBottom);

            customObjects.Add("Omegasis.BigTiledTest", bigObject);
            customObjects.Add("Omegasis.Revitalize.Furniture.Chairs.OakChair", oakChair);

            Framework.Objects.Furniture.RugTileComponent    rug1 = new Framework.Objects.Furniture.RugTileComponent(new BasicItemInformation("BasicRugTile", "A basic rug", "Rug", Color.Brown, -300, 0, false, 100, new Vector2(0, 0), true, true, "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", generatePlaceholderString(), TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.RugTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, null, null));
            Framework.Objects.Furniture.RugMultiTiledObject rug  = new Framework.Objects.Furniture.RugMultiTiledObject(new BasicItemInformation("BasicRugTile", "A basic rug", "Rug", Color.Brown, -300, 0, false, 100, new Vector2(0, 0), true, true, "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", generatePlaceholderString(), TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.RugMultiTiledObject), null, new AnimationManager(), Color.White, true, null, null));
            rug.addComponent(new Vector2(0, 0), rug1);

            customObjects.Add("Omegasis.Revitalize.Furniture.Rugs.RugTest", rug);
        }