From 50a7720bce23dda7d23d8f0e0eb31c9fb8d225e1 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Sun, 20 Jan 2019 23:34:11 -0800 Subject: [PATCH 1/2] Updated mods to SMAPI 3.X. Also revitalize: Placement bounds and depth properly work. --- GeneralMods/AdvancedSaveBackup/manifest.json | 2 +- GeneralMods/AutoSpeed/manifest.json | 2 +- GeneralMods/BillboardAnywhere/manifest.json | 2 +- GeneralMods/BuildEndurance/manifest.json | 2 +- GeneralMods/BuildHealth/manifest.json | 2 +- GeneralMods/BuyBackCollectables/manifest.json | 2 +- GeneralMods/DailyQuestAnywhere/manifest.json | 2 +- GeneralMods/Fall28SnowDay/manifest.json | 2 +- GeneralMods/HappyBirthday/Changelog.txt | 24 ++++++--- GeneralMods/HappyBirthday/manifest.json | 2 +- GeneralMods/MoreRain/manifest.json | 2 +- GeneralMods/MuseumRearranger/manifest.json | 2 +- GeneralMods/NightOwl/manifest.json | 2 +- GeneralMods/NoMorePets/manifest.json | 2 +- .../Framework/Objects/CustomObject.cs | 53 +++++++++++++++++-- .../Framework/Objects/Furniture/Bench.cs | 2 +- .../Furniture/ChairMultiTiledObject.cs | 1 + .../InformationFiles/ObjectGUIDInfo.cs | 23 ++++++++ .../Framework/Objects/MultiTiledComponent.cs | 25 +++++---- .../Framework/Objects/MultiTiledObject.cs | 28 ++++++++-- GeneralMods/Revitalize/ModCore.cs | 11 +++- GeneralMods/Revitalize/Revitalize.csproj | 1 + GeneralMods/SaveAnywhere/manifest.json | 2 +- .../SimpleSoundManager/Framework/WavSound.cs | 2 +- GeneralMods/SimpleSoundManager/manifest.json | 2 +- .../StardewSymphonyRemastered/manifest.json | 2 +- GeneralMods/StardustCore/manifest.json | 2 +- GeneralMods/TimeFreeze/manifest.json | 2 +- 28 files changed, 159 insertions(+), 47 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs diff --git a/GeneralMods/AdvancedSaveBackup/manifest.json b/GeneralMods/AdvancedSaveBackup/manifest.json index bb113ace..559192a8 100644 --- a/GeneralMods/AdvancedSaveBackup/manifest.json +++ b/GeneralMods/AdvancedSaveBackup/manifest.json @@ -1,7 +1,7 @@ { "Name": "Advanced Save Backup", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Backs up your save files when loading SMAPI and every in game night when saving.", "UniqueID": "Omegasis.AdvancedSaveBackup", "EntryDll": "AdvancedSaveBackup.dll", diff --git a/GeneralMods/AutoSpeed/manifest.json b/GeneralMods/AutoSpeed/manifest.json index acc444d5..b5c3f9e3 100644 --- a/GeneralMods/AutoSpeed/manifest.json +++ b/GeneralMods/AutoSpeed/manifest.json @@ -1,7 +1,7 @@ { "Name": "Auto Speed", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.8.0", "Description": "Got to go fast!", "UniqueID": "Omegasis.AutoSpeed", "EntryDll": "AutoSpeed.dll", diff --git a/GeneralMods/BillboardAnywhere/manifest.json b/GeneralMods/BillboardAnywhere/manifest.json index 5685e1ec..8a6fea42 100644 --- a/GeneralMods/BillboardAnywhere/manifest.json +++ b/GeneralMods/BillboardAnywhere/manifest.json @@ -1,7 +1,7 @@ { "Name": "Billboard Anywhere", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.8.0", "Description": "Lets you view the billboard from anywhere.", "UniqueID": "Omegasis.BillboardAnywhere", "EntryDll": "BillboardAnywhere.dll", diff --git a/GeneralMods/BuildEndurance/manifest.json b/GeneralMods/BuildEndurance/manifest.json index 965d6449..31cb9880 100644 --- a/GeneralMods/BuildEndurance/manifest.json +++ b/GeneralMods/BuildEndurance/manifest.json @@ -1,7 +1,7 @@ { "Name": "Build Endurance", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.8.0", "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildEndurance", "EntryDll": "BuildEndurance.dll", diff --git a/GeneralMods/BuildHealth/manifest.json b/GeneralMods/BuildHealth/manifest.json index f68687dd..60ea6839 100644 --- a/GeneralMods/BuildHealth/manifest.json +++ b/GeneralMods/BuildHealth/manifest.json @@ -1,7 +1,7 @@ { "Name": "Build Health", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.8.0", "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildHealth", "EntryDll": "BuildHealth.dll", diff --git a/GeneralMods/BuyBackCollectables/manifest.json b/GeneralMods/BuyBackCollectables/manifest.json index c4349ae3..862d6a7a 100644 --- a/GeneralMods/BuyBackCollectables/manifest.json +++ b/GeneralMods/BuyBackCollectables/manifest.json @@ -1,7 +1,7 @@ { "Name": "Buy Back Collectables", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Lets you buy back any obtained collectable.", "UniqueID": "Omegasis.BuyBackCollectables", "EntryDll": "BuyBackCollectables.dll", diff --git a/GeneralMods/DailyQuestAnywhere/manifest.json b/GeneralMods/DailyQuestAnywhere/manifest.json index f573351b..fae36232 100644 --- a/GeneralMods/DailyQuestAnywhere/manifest.json +++ b/GeneralMods/DailyQuestAnywhere/manifest.json @@ -1,7 +1,7 @@ { "Name": "Daily Quest Anywhere", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Open the daily quest board from anywhere in the game.", "UniqueID": "Omegasis.DailyQuestAnywhere", "EntryDll": "DailyQuestAnywhere.dll", diff --git a/GeneralMods/Fall28SnowDay/manifest.json b/GeneralMods/Fall28SnowDay/manifest.json index 35210825..0d4bd6b8 100644 --- a/GeneralMods/Fall28SnowDay/manifest.json +++ b/GeneralMods/Fall28SnowDay/manifest.json @@ -1,7 +1,7 @@ { "Name": "Fall 28 Snow Day", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.", "UniqueID": "Omegasis.Fall28SnowDay", "EntryDll": "Fall28SnowDay.dll", diff --git a/GeneralMods/HappyBirthday/Changelog.txt b/GeneralMods/HappyBirthday/Changelog.txt index e4b23240..bf350261 100644 --- a/GeneralMods/HappyBirthday/Changelog.txt +++ b/GeneralMods/HappyBirthday/Changelog.txt @@ -1,4 +1,12 @@ -Happy Birthday Change Log +Happy Birthday Change Log + +~~~~~~~~~~~~~~~~ +Manifest 1.9.0 Changelog +~~~~~~~~~~~~~~~~ +General Changes + -Added support for Chinese birthday translations thanks to Nexus user erinyang. + -Added support for loading translation strings for Birthday Mail and HUD Messages. + ~~~~~~~~~~~~~~~~ Manifest 1.8.0 Changelog @@ -9,12 +17,12 @@ Manifest 1.8.0 Changelog -A language can be set for birthday messages in the Config.json file. -Added support for birthday messages to be in .json files for easier editing. -Added support for birthday messages to be in multiple supported languages - -English - -Spanish - -German - -Chinese - -Japanese - -Brazilian Portuguese + -English + -Spanish + -German + -Chinese + -Japanese + -Brazilian Portuguese -Added in spouse specific birthday dialogue messages which can be created by the players. -Added in multiple languages for spouse birthday messages. -Added in birthday gifts to be in .json files. @@ -24,4 +32,4 @@ Manifest 1.8.0 Changelog -Added in player portraits to be shown on the callendar. Multiplayer changes: -Added in multiplayer farmhand portraits to be shown on the callendar. - -Added in a hud message that displays when another player has a birthday. \ No newline at end of file + -Added in a hud message that displays when another player has a birthday. diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index c2a5fe2f..8f5d9444 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -1,7 +1,7 @@ { "Name": "Happy Birthday", "Author": "Alpha_Omegasis", - "Version": "1.8.3", + "Version": "1.9.0", "Description": "Adds the farmer's birthday to the game.", "UniqueID": "Omegasis.HappyBirthday", "EntryDll": "HappyBirthday.dll", diff --git a/GeneralMods/MoreRain/manifest.json b/GeneralMods/MoreRain/manifest.json index 8bc0f494..55769136 100644 --- a/GeneralMods/MoreRain/manifest.json +++ b/GeneralMods/MoreRain/manifest.json @@ -1,7 +1,7 @@ { "Name": "More Rain", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.8.0", "Description": "Change how much it rains in the game.", "UniqueID": "Omegasis.MoreRain", "EntryDll": "MoreRain.dll", diff --git a/GeneralMods/MuseumRearranger/manifest.json b/GeneralMods/MuseumRearranger/manifest.json index 7ed4041d..71f628da 100644 --- a/GeneralMods/MuseumRearranger/manifest.json +++ b/GeneralMods/MuseumRearranger/manifest.json @@ -1,7 +1,7 @@ { "Name": "Museum Rearranger", "Author": "Alpha_Omegasis", - "Version": "1.7.0", + "Version": "1.8.0", "Description": "Lets you rearrange the museum without needing to donate something.", "UniqueID": "Omegasis.MuseumRearranger", "EntryDll": "MuseumRearranger.dll", diff --git a/GeneralMods/NightOwl/manifest.json b/GeneralMods/NightOwl/manifest.json index b7a37179..acff5fad 100644 --- a/GeneralMods/NightOwl/manifest.json +++ b/GeneralMods/NightOwl/manifest.json @@ -1,7 +1,7 @@ { "Name": "Night Owl", "Author": "Alpha_Omegasis", - "Version": "1.8.0", + "Version": "1.9.0", "Description": "Lets you stay up all night.", "UniqueID": "Omegasis.NightOwl", "EntryDll": "NightOwl.dll", diff --git a/GeneralMods/NoMorePets/manifest.json b/GeneralMods/NoMorePets/manifest.json index 6c1a9aae..d337fdbb 100644 --- a/GeneralMods/NoMorePets/manifest.json +++ b/GeneralMods/NoMorePets/manifest.json @@ -1,7 +1,7 @@ { "Name": "No More Pets", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Removes all pets from the game.", "UniqueID": "Omegasis.NoMorePets", "EntryDll": "NoMorePets.dll", diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 6b0615c2..ad67cc21 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -35,11 +35,27 @@ namespace Revitalize.Framework.Objects [JsonIgnore] public Texture2D displayTexture => this.animationManager.getTexture(); + public string ItemInfo + { + get + { + return Revitalize.ModCore.Serializer.ToJSONString(this.info); + } + set + { + Revitalize.ModCore.log("GUESS SERIALIZATION IS WORKING???"); + this.info =(BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation)); + } + } + + + protected Netcode.NetString netItemInfo; /// Empty constructor. public CustomObject() { this.guid = Guid.NewGuid(); + InitNetFields(); } /// Construct an instance. @@ -77,13 +93,14 @@ namespace Revitalize.Framework.Objects this.bigCraftable.Value = false; - this.initNetFields(); - - + //this.initNetFields(); + InitNetFields(); //if (this.info.ignoreBoundingBox) // this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0); } + + public override bool isPassable() { return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject==this; @@ -223,6 +240,12 @@ namespace Revitalize.Framework.Objects return base.placementAction(location, x, y, who); } + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + if (this.info.ignoreBoundingBox) return true; + return base.canBePlacedHere(l, tile); + } + public virtual void rotate() { if (this.info.facingDirection == Enums.Direction.Down) this.info.facingDirection = Enums.Direction.Right; @@ -371,11 +394,35 @@ namespace Revitalize.Framework.Objects public void InitNetFields() { + if (Game1.IsMultiplayer == false &&(Game1.IsClient==false || Game1.IsClient==false)) return; this.initNetFields(); this.syncObject = new PySync(this); this.NetFields.AddField(this.syncObject); + this.netItemInfo = new Netcode.NetString(this.ItemInfo); + this.NetFields.AddField(this.netItemInfo); } + /// + /// Gets all of the data necessary for syncing. + /// + /// + public override Dictionary getSyncData() + { + Dictionary syncData= base.getSyncData(); + syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + return syncData; + } + + /// + /// Syncs all of the info to all players. + /// + /// + public override void sync(Dictionary syncData) + { + Revitalize.ModCore.log("SYNC OBJECT DATA!"); + base.sync(syncData); + this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]); + } public string getDisplayNameFromStringsFile(string objectID) { diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs index 16e7357d..c8958818 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs @@ -24,7 +24,7 @@ namespace Revitalize.Framework.Objects.Furniture } - public Bench(BasicItemInformation info,Vector2 TilePosition, Dictionary Objects): base(info, TilePosition, Objects) + public Bench(BasicItemInformation info,Vector2 TilePosition, Dictionary Objects) : base(info, TilePosition, Objects) { } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs index 74465c07..4e69e136 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs @@ -62,6 +62,7 @@ namespace Revitalize.Framework.Objects.Furniture objs.Add(pair.Key, (MultiTiledComponent)pair.Value); } + return new ChairMultiTiledObject(this.info, this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs new file mode 100644 index 00000000..d3b14494 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects.InformationFiles +{ + public class ObjectGUIDInfo + { + public enum ObjectType + { + Solid, + Display + } + + public ObjectGUIDInfo() + { + + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 335b121c..f53713d2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -188,22 +188,27 @@ namespace Revitalize.Framework.Objects /// What happens when the object is drawn at a tile location. public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { - if (this.info == null) Revitalize.ModCore.log("info is null"); + if (this.info.ignoreBoundingBox == true) + { + x *= -1; + y *= -1; + } + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); - if (x <= -1) - { - spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f)); - } - else - { + //The actual planter box being drawn. if (this.animationManager == null) { if (this.animationManager.getExtendedTexture() == null) ModCore.ModMonitor.Log("Tex Extended is null???"); - spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f)); + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } @@ -222,7 +227,7 @@ namespace Revitalize.Framework.Objects { addedDepth += 1.0f; } - this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f)); + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f)+.00001f); try { this.animationManager.tickAnimation(); @@ -235,7 +240,7 @@ namespace Revitalize.Framework.Objects } // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); - } + } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 8cc01385..d0172ee9 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -101,13 +101,17 @@ namespace Revitalize.Framework.Objects public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { foreach (KeyValuePair pair in this.objects) - pair.Value.draw(spriteBatch, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, alpha); + { + (pair.Value as MultiTiledComponent).draw(spriteBatch, x + ((int)pair.Key.X), y + ((int)pair.Key.Y), alpha); + } } public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { foreach (KeyValuePair pair in this.objects) + { pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile + (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); + } //base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); } @@ -147,9 +151,18 @@ namespace Revitalize.Framework.Objects x = (int)translatedVector2.X * 64; y = (int)translatedVector2.Y * 64; } - bool flag = Utility.playerCanPlaceItemHere(location, (Item)pair.Value, x, y, Game1.player); + bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x/Game1.tileSize, y/Game1.tileSize)); spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f); - this.draw(spriteBatch, x / 64, y / 64, 0.5f); + + //Revitalize.ModCore.log(new Vector2(x + ((int)pair.Key.X), y + ((int)pair.Key.Y))); + if((pair.Value as MultiTiledComponent).info.ignoreBoundingBox) + { + x *= -1; + y *= -1; + } + (pair.Value as MultiTiledComponent).draw(spriteBatch, x/Game1.tileSize, y/Game1.tileSize, 0.5f); + //break; + //this.draw(spriteBatch, x / 64, y / 64, 0.5f); } } @@ -183,7 +196,14 @@ namespace Revitalize.Framework.Objects { foreach (KeyValuePair pair in this.objects) { - pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + if ((pair.Value as CustomObject).info.ignoreBoundingBox) + { + pair.Value.placementAction(location, -1 * (x + (int)pair.Key.X * Game1.tileSize), -1 * (y + (int)pair.Key.Y * Game1.tileSize), who); + } + else + { + pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + } //ModCore.log(pair.Value.TileLocation); } this.location = location; diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 2a2229f1..8dc7b96d 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -106,6 +106,8 @@ namespace Revitalize public static Serializer Serializer; + public static Dictionary ObjectsToDraw; + public override void Entry(IModHelper helper) { ModHelper = helper; @@ -128,6 +130,7 @@ namespace Revitalize loadContent(); Serializer = new Serializer(); + ObjectsToDraw = new Dictionary(); } @@ -155,6 +158,7 @@ namespace Revitalize [bigObject] = 1 }, new KeyValuePair(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>() { @@ -246,8 +250,8 @@ namespace Revitalize 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, 0), chairTop); - oakChair.addComponent(new Vector2(0, 1), chairBottom); + 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); @@ -290,6 +294,9 @@ namespace Revitalize //Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"].getOne()); Game1.player.addItemToInventory(getObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair")); + Netcode.NetString str = new Netcode.NetString("AHHH"); + Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "str.json"),str); + /* StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe(); Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e1fa1111..cd3d1dee 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -69,6 +69,7 @@ + diff --git a/GeneralMods/SaveAnywhere/manifest.json b/GeneralMods/SaveAnywhere/manifest.json index ffd84748..ce472d68 100644 --- a/GeneralMods/SaveAnywhere/manifest.json +++ b/GeneralMods/SaveAnywhere/manifest.json @@ -1,7 +1,7 @@ { "Name": "Save Anywhere", "Author": "Alpha_Omegasis", - "Version": "2.10.0", + "Version": "2.11.0", "Description": "Lets you save almost anywhere.", "UniqueID": "Omegasis.SaveAnywhere", "EntryDll": "SaveAnywhere.dll", diff --git a/GeneralMods/SimpleSoundManager/Framework/WavSound.cs b/GeneralMods/SimpleSoundManager/Framework/WavSound.cs index 4c31fdf2..d7f40618 100644 --- a/GeneralMods/SimpleSoundManager/Framework/WavSound.cs +++ b/GeneralMods/SimpleSoundManager/Framework/WavSound.cs @@ -150,7 +150,7 @@ namespace SimpleSoundManager /// Used to resume the currently playing song. public void resume() { - dynamicSound?.Resume(); + this.dynamicSound?.Resume(); } /// Used to stop the currently playing song. diff --git a/GeneralMods/SimpleSoundManager/manifest.json b/GeneralMods/SimpleSoundManager/manifest.json index bd16daeb..b80f64b4 100644 --- a/GeneralMods/SimpleSoundManager/manifest.json +++ b/GeneralMods/SimpleSoundManager/manifest.json @@ -1,7 +1,7 @@ { "Name": "Simple Sound Manager", "Author": "Alpha_Omegasis", - "Version": "2.1.0", + "Version": "2.2.0", "Description": "A simple framework to play sounds from wave banks and wav files.", "UniqueID": "Omegasis.SimpleSoundManager", "EntryDll": "SimpleSoundManager.dll", diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json index 5218ccf9..69b5ad6f 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json @@ -1,7 +1,7 @@ { "Name": "Stardew Symphony Remastered", "Author": "Alpha_Omegasis", - "Version": "2.3.0", + "Version": "2.4.0", "Description": "Adding more music to the game one beep at a time. Now with streaming!", "UniqueID": "Omegasis.StardewSymphonyRemastered", "EntryDll": "StardewSymphonyRemastered.dll", diff --git a/GeneralMods/StardustCore/manifest.json b/GeneralMods/StardustCore/manifest.json index 4010f9dc..78b5f7a6 100644 --- a/GeneralMods/StardustCore/manifest.json +++ b/GeneralMods/StardustCore/manifest.json @@ -1,7 +1,7 @@ { "Name": "StardustCore", "Author": "Alpha_Omegasis", - "Version": "2.1.0", + "Version": "2.2.0", "Description": "A core mod that allows for other mods of mine to be run.", "UniqueID": "Omegasis.StardustCore", "EntryDll": "StardustCore.dll", diff --git a/GeneralMods/TimeFreeze/manifest.json b/GeneralMods/TimeFreeze/manifest.json index e2876405..2b596628 100644 --- a/GeneralMods/TimeFreeze/manifest.json +++ b/GeneralMods/TimeFreeze/manifest.json @@ -1,7 +1,7 @@ { "Name": "Time Freeze", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Emulates old Harvest Moon-style games where time is frozen inside.", "UniqueID": "Omegasis.TimeFreeze", "EntryDll": "TimeFreeze.dll", From 839a385b3214d469a2bc15b83bccc140fb4a1d2d Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 21 Jan 2019 00:01:07 -0800 Subject: [PATCH 2/2] Rugs work!wq --- .../Objects/Furniture/RugMultiTiledObject.cs | 113 +++++++++++++ .../Objects/Furniture/RugTileComponent.cs | 156 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 12 +- GeneralMods/Revitalize/Revitalize.csproj | 2 + 4 files changed, 278 insertions(+), 5 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs new file mode 100644 index 00000000..15b2871b --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using PyTK.CustomElementHandler; +using StardewValley; + +namespace Revitalize.Framework.Objects.Furniture +{ + public class RugMultiTiledObject:MultiTiledObject + { + public RugMultiTiledObject() : base() + { + + } + + public RugMultiTiledObject(BasicItemInformation Info) : base(Info) + { + + } + + public RugMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition) : base(Info, TilePosition) + { + + } + + public RugMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(Info, TilePosition, Objects) + { + + + } + + /// + /// Rotate all chair components associated with this chair object. + /// + public override void rotate() + { + Revitalize.ModCore.log("Rotate!"); + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as RugTileComponent).rotate(); + } + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as RugTileComponent).checkForSpecialUpSittingAnimation(); + } + + base.rotate(); + } + + public override Item getOne() + { + Dictionary objs = new Dictionary(); + foreach (var pair in this.objects) + { + objs.Add(pair.Key, (MultiTiledComponent)pair.Value); + } + + + return new RugMultiTiledObject(this.info, this.TileLocation, objs); + } + + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + RugMultiTiledObject obj = (RugMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (obj == null) + { + return null; + } + + Dictionary guids = new Dictionary(); + + foreach (KeyValuePair pair in obj.childrenGuids) + { + guids.Add(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in guids) + { + obj.childrenGuids.Remove(pair.Key); + //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); + RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(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"]]; + } + + + } + + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + return base.canBePlacedHere(l, tile); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs new file mode 100644 index 00000000..a49556ae --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; +using StardewValley; + +namespace Revitalize.Framework.Objects.Furniture +{ + public class RugTileComponent:MultiTiledComponent + { + + public RugTileComponent() : base() + { + + } + + public RugTileComponent(BasicItemInformation Info) : base(Info) + { + this.info.ignoreBoundingBox = true; + } + + public RugTileComponent(BasicItemInformation Info, Vector2 TileLocation) : base(Info, TileLocation) + { + this.info.ignoreBoundingBox = true; + } + + + + /// + /// When the chair is right clicked ensure that all pieces associated with it are also rotated. + /// + /// + /// + public override bool rightClicked(Farmer who) + { + this.containerObject.rotate(); //Ensure that all of the chair pieces rotate at the same time. + return true; + //return base.rightClicked(who); + } + + public override Item getOne() + { + RugTileComponent component = new RugTileComponent(this.info); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + } + + public override ICustomObject recreate(Dictionary 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"])); + RugTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + RugMultiTiledObject obj = (RugMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(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 Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + + return saveData; + + } + + + /// + ///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden. + /// + public void checkForSpecialUpSittingAnimation() + { + if (this.info.facingDirection == Enums.Direction.Up && Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject) + { + string animationKey = "Sitting_" + (int)Enums.Direction.Up; + if (this.animationManager.animations.ContainsKey(animationKey)) + { + this.animationManager.setAnimation(animationKey); + } + } + } + + /// What happens when the object is drawn at a tile location. + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (this.info.ignoreBoundingBox == true) + { + x *= -1; + y *= -1; + } + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, 0.0001f)); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + } + + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 8dc7b96d..d291196d 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -203,8 +203,6 @@ namespace Revitalize } } }, "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>() { { "Default_" + (int)Framework.Enums.Direction.Down , new List() { @@ -255,6 +253,12 @@ namespace Revitalize 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); } private void createDirectories() @@ -293,9 +297,7 @@ namespace Revitalize } //Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"].getOne()); Game1.player.addItemToInventory(getObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair")); - - Netcode.NetString str = new Netcode.NetString("AHHH"); - Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "str.json"),str); + Game1.player.addItemToInventory(getObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); /* StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe(); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index cd3d1dee..7ca0d58c 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -67,6 +67,8 @@ + +