From d31456fdc7cd55576523bc32ff8a7c2c18d66710 Mon Sep 17 00:00:00 2001 From: Zoryn Aaron Date: Tue, 22 Mar 2016 20:36:04 -0400 Subject: okay. things. --- StardewModdingAPI/Inheritance/ItemStackChange.cs | 5 - StardewModdingAPI/Inheritance/Menus/SBobberBar.cs | 7 +- StardewModdingAPI/Inheritance/Menus/SGameMenu.cs | 15 +- .../Inheritance/Menus/SInventoryPage.cs | 8 +- .../Inheritance/Minigames/SMinigameBase.cs | 10 +- StardewModdingAPI/Inheritance/SGame.cs | 199 +++++++-------------- StardewModdingAPI/Inheritance/SGameLocation.cs | 4 - StardewModdingAPI/Inheritance/SObject.cs | 52 +++--- 8 files changed, 95 insertions(+), 205 deletions(-) (limited to 'StardewModdingAPI/Inheritance') diff --git a/StardewModdingAPI/Inheritance/ItemStackChange.cs b/StardewModdingAPI/Inheritance/ItemStackChange.cs index 88003579..cfadea04 100644 --- a/StardewModdingAPI/Inheritance/ItemStackChange.cs +++ b/StardewModdingAPI/Inheritance/ItemStackChange.cs @@ -1,9 +1,4 @@ using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StardewModdingAPI.Inheritance { diff --git a/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs b/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs index c2d51ba0..ecfc0c38 100644 --- a/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs +++ b/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; +using System.Reflection; using Microsoft.Xna.Framework; using StardewValley.BellsAndWhistles; using StardewValley.Menus; diff --git a/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs b/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs index 721e04d8..43ea30d7 100644 --- a/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs +++ b/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs @@ -1,18 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.Eventing.Reader; -using System.Linq; +using System.Collections.Generic; using System.Reflection; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework.Graphics; -using StardewValley; using StardewValley.Menus; namespace StardewModdingAPI.Inheritance.Menus { - public class SGameMenu : StardewValley.Menus.GameMenu + public class SGameMenu : GameMenu { public GameMenu BaseGameMenu { get; private set; } @@ -41,9 +33,6 @@ namespace StardewModdingAPI.Inheritance.Menus { Log.Verbose("INV SCREEN"); } - else - { - } base.receiveRightClick(x, y, playSound); } diff --git a/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs b/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs index 6bcb7662..d798fc95 100644 --- a/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs +++ b/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using StardewValley; -using StardewValley.Menus; +using StardewValley.Menus; namespace StardewModdingAPI.Inheritance.Menus { diff --git a/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs b/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs index 5ce29d8d..08a5e861 100644 --- a/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs +++ b/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs @@ -1,15 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using StardewValley.Minigames; namespace StardewModdingAPI.Inheritance.Minigames { - abstract class SMinigameBase : StardewValley.Minigames.IMinigame + abstract class SMinigameBase : IMinigame { public abstract bool tick(GameTime time); diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index 53d9df59..8ba76ed3 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -2,24 +2,17 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Xml.Serialization; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using StardewModdingAPI.Events; using StardewValley; -using StardewValley.Characters; using StardewValley.Menus; -using StardewValley.Monsters; -using StardewValley.Quests; -using StardewValley.TerrainFeatures; -using StardewModdingAPI.Events; namespace StardewModdingAPI.Inheritance { public class SGame : Game1 { - public static List ModLocations = new List(); - public static SGameLocation CurrentLocation { get; internal set; } public static Dictionary ModItems { get; private set; } public const Int32 LowestModItemID = 1000; @@ -70,9 +63,12 @@ namespace StardewModdingAPI.Inheritance return WasButtonJustReleased(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex); } + public bool PreviouslyLoadedGame { get; private set; } + private bool FireLoadedGameEvent; + public Buttons[] GetButtonsDown(PlayerIndex index) { - GamePadState state = GamePad.GetState((PlayerIndex)index); + GamePadState state = GamePad.GetState(index); List buttons = new List(); if (state.IsConnected) { @@ -99,7 +95,7 @@ namespace StardewModdingAPI.Inheritance public Buttons[] GetFramePressedButtons(PlayerIndex index) { - GamePadState state = GamePad.GetState((PlayerIndex)index); + GamePadState state = GamePad.GetState(index); List buttons = new List(); if (state.IsConnected) { @@ -126,7 +122,7 @@ namespace StardewModdingAPI.Inheritance public Buttons[] GetFrameReleasedButtons(PlayerIndex index) { - GamePadState state = GamePad.GetState((PlayerIndex)index); + GamePadState state = GamePad.GetState(index); List buttons = new List(); if (state.IsConnected) { @@ -153,7 +149,6 @@ namespace StardewModdingAPI.Inheritance public int PreviousGameLocations { get; private set; } public int PreviousLocationObjects { get; private set; } - public int PreviousItems_ { get; private set; } public Dictionary PreviousItems { get; private set; } public int PreviousCombatLevel { get; private set; } @@ -179,54 +174,18 @@ namespace StardewModdingAPI.Inheritance public RenderTarget2D Screen { get { return typeof (Game1).GetBaseFieldValue(Program.gamePtr, "screen"); } - set { typeof (Game1).SetBaseFieldValue("screen", value); } + set { typeof (Game1).SetBaseFieldValue(this, "screen", value); } } private static SGame instance; - public static SGame Instance { get { return instance; } } + public static SGame Instance => instance; - public Farmer CurrentFarmer { get { return player; } } + public Farmer CurrentFarmer => player; public SGame() { instance = this; FirstUpdate = true; - - /* -#if DEBUG - SaveGame.serializer = new XmlSerializer(typeof (SaveGame), new Type[28] - { - typeof (Tool), - typeof (GameLocation), - typeof (Crow), - typeof (Duggy), - typeof (Bug), - typeof (BigSlime), - typeof (Fireball), - typeof (Ghost), - typeof (Child), - typeof (Pet), - typeof (Dog), - typeof (StardewValley.Characters.Cat), - typeof (Horse), - typeof (GreenSlime), - typeof (LavaCrab), - typeof (RockCrab), - typeof (ShadowGuy), - typeof (SkeletonMage), - typeof (SquidKid), - typeof (Grub), - typeof (Fly), - typeof (DustSpirit), - typeof (Quest), - typeof (MetalHead), - typeof (ShadowGirl), - typeof (Monster), - typeof (TerrainFeature), - typeof (SObject) - }); -#endif - */ } protected override void Initialize() @@ -238,14 +197,14 @@ namespace StardewModdingAPI.Inheritance for (int i = 0; i < 4; ++i) PreviouslyPressedButtons[i] = new Buttons[0]; base.Initialize(); - Events.GameEvents.InvokeInitialize(); + GameEvents.InvokeInitialize(); } protected override void LoadContent() { Log.Verbose("XNA LoadContent"); base.LoadContent(); - Events.GameEvents.InvokeLoadContent(); + GameEvents.InvokeLoadContent(); } protected override void Update(GameTime gameTime) @@ -262,7 +221,7 @@ namespace StardewModdingAPI.Inheritance Console.ReadKey(); } - Events.GameEvents.InvokeUpdateTick(); + GameEvents.InvokeUpdateTick(); if (FirstUpdate) { GameEvents.InvokeFirstUpdateTick(); @@ -270,22 +229,22 @@ namespace StardewModdingAPI.Inheritance } if (CurrentUpdateTick % 2 == 0) - Events.GameEvents.InvokeSecondUpdateTick(); + GameEvents.InvokeSecondUpdateTick(); if (CurrentUpdateTick % 4 == 0) - Events.GameEvents.InvokeFourthUpdateTick(); + GameEvents.InvokeFourthUpdateTick(); if (CurrentUpdateTick % 8 == 0) - Events.GameEvents.InvokeEighthUpdateTick(); + GameEvents.InvokeEighthUpdateTick(); if (CurrentUpdateTick % 15 == 0) - Events.GameEvents.InvokeQuarterSecondTick(); + GameEvents.InvokeQuarterSecondTick(); if (CurrentUpdateTick % 30 == 0) - Events.GameEvents.InvokeHalfSecondTick(); + GameEvents.InvokeHalfSecondTick(); if (CurrentUpdateTick % 60 == 0) - Events.GameEvents.InvokeOneSecondTick(); + GameEvents.InvokeOneSecondTick(); CurrentUpdateTick += 1; if (CurrentUpdateTick >= 60) @@ -301,20 +260,7 @@ namespace StardewModdingAPI.Inheritance protected override void Draw(GameTime gameTime) { base.Draw(gameTime); - Events.GraphicsEvents.InvokeDrawTick(); - - if (false) - { - spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); - - if (CurrentLocation != null) - CurrentLocation.draw(spriteBatch); - - if (player != null && player.position != null) - spriteBatch.DrawString(dialogueFont, player.position.ToString(), new Vector2(0, 180), Color.Orange); - - spriteBatch.End(); - } + GraphicsEvents.InvokeDrawTick(); } public static Int32 RegisterModItem(SObject modItem) @@ -341,44 +287,14 @@ namespace StardewModdingAPI.Inheritance { return ModItems.ElementAt(id).Value.Clone(); } - Log.Error("ModItem Dictionary does not contain index: " + id.ToString()); + Log.Error("ModItem Dictionary does not contain index: " + id); return null; } if (ModItems.ContainsKey(id)) { return ModItems[id].Clone(); } - Log.Error("ModItem Dictionary does not contain ID: " + id.ToString()); - return null; - } - - public static SGameLocation GetLocationFromName(String name) - { - return ModLocations.FirstOrDefault(n => n.name == name); - } - - public static SGameLocation LoadOrCreateSGameLocationFromName(String name) - { - if (GetLocationFromName(name) != null) - return GetLocationFromName(name); - GameLocation gl = locations.FirstOrDefault(x => x.name == name); - if (gl != null) - { - Log.Debug("A custom location was created for the new name: " + name); - SGameLocation s = SGameLocation.ConstructFromBaseClass(gl); - ModLocations.Add(s); - return s; - } - if (currentLocation != null && currentLocation.name == name) - { - gl = currentLocation; - Log.Debug("A custom location was created from the current location for the new name: " + name); - SGameLocation s = SGameLocation.ConstructFromBaseClass(gl); - ModLocations.Add(s); - return s; - } - - Log.Debug("A custom location could not be created for: " + name); + Log.Error("ModItem Dictionary does not contain ID: " + id); return null; } @@ -390,10 +306,10 @@ namespace StardewModdingAPI.Inheritance MStateNow = Mouse.GetState(); foreach (Keys k in FramePressedKeys) - Events.ControlEvents.InvokeKeyPressed(k); + ControlEvents.InvokeKeyPressed(k); foreach (Keys k in FrameReleasedKeys) - Events.ControlEvents.InvokeKeyReleased(k); + ControlEvents.InvokeKeyReleased(k); for (PlayerIndex i = PlayerIndex.One; i <= PlayerIndex.Four; i++) { @@ -402,11 +318,11 @@ namespace StardewModdingAPI.Inheritance { if(b == Buttons.LeftTrigger || b == Buttons.RightTrigger) { - Events.ControlEvents.InvokeTriggerPressed(i, b, b == Buttons.LeftTrigger ? GamePad.GetState(i).Triggers.Left : GamePad.GetState(i).Triggers.Right); + ControlEvents.InvokeTriggerPressed(i, b, b == Buttons.LeftTrigger ? GamePad.GetState(i).Triggers.Left : GamePad.GetState(i).Triggers.Right); } else { - Events.ControlEvents.InvokeButtonPressed(i, b); + ControlEvents.InvokeButtonPressed(i, b); } } } @@ -417,11 +333,11 @@ namespace StardewModdingAPI.Inheritance { if (b == Buttons.LeftTrigger || b == Buttons.RightTrigger) { - Events.ControlEvents.InvokeTriggerReleased(i, b, b == Buttons.LeftTrigger ? GamePad.GetState(i).Triggers.Left : GamePad.GetState(i).Triggers.Right); + ControlEvents.InvokeTriggerReleased(i, b, b == Buttons.LeftTrigger ? GamePad.GetState(i).Triggers.Left : GamePad.GetState(i).Triggers.Right); } else { - Events.ControlEvents.InvokeButtonReleased(i, b); + ControlEvents.InvokeButtonReleased(i, b); } } } @@ -429,138 +345,151 @@ namespace StardewModdingAPI.Inheritance if (KStateNow != KStatePrior) { - Events.ControlEvents.InvokeKeyboardChanged(KStatePrior, KStateNow); + ControlEvents.InvokeKeyboardChanged(KStatePrior, KStateNow); KStatePrior = KStateNow; } if (MStateNow != MStatePrior) { - Events.ControlEvents.InvokeMouseChanged(MStatePrior, MStateNow); + ControlEvents.InvokeMouseChanged(MStatePrior, MStateNow); MStatePrior = MStateNow; } if (activeClickableMenu != null && activeClickableMenu != PreviousActiveMenu) { - Events.MenuEvents.InvokeMenuChanged(PreviousActiveMenu, activeClickableMenu); + MenuEvents.InvokeMenuChanged(PreviousActiveMenu, activeClickableMenu); PreviousActiveMenu = activeClickableMenu; } if (locations.GetHash() != PreviousGameLocations) { - Events.LocationEvents.InvokeLocationsChanged(locations); + LocationEvents.InvokeLocationsChanged(locations); PreviousGameLocations = locations.GetHash(); } if (currentLocation != PreviousGameLocation) { - Events.LocationEvents.InvokeCurrentLocationChanged(PreviousGameLocation, currentLocation); + LocationEvents.InvokeCurrentLocationChanged(PreviousGameLocation, currentLocation); PreviousGameLocation = currentLocation; } if (player != null && player != PreviousFarmer) { - Events.PlayerEvents.InvokeFarmerChanged(PreviousFarmer, player); + PlayerEvents.InvokeFarmerChanged(PreviousFarmer, player); PreviousFarmer = player; } if (player != null && player.combatLevel != PreviousCombatLevel) { - Events.PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Combat, player.combatLevel); + PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Combat, player.combatLevel); PreviousCombatLevel = player.combatLevel; } if (player != null && player.farmingLevel != PreviousFarmingLevel) { - Events.PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Farming, player.farmingLevel); + PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Farming, player.farmingLevel); PreviousFarmingLevel = player.farmingLevel; } if (player != null && player.fishingLevel != PreviousFishingLevel) { - Events.PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Fishing, player.fishingLevel); + PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Fishing, player.fishingLevel); PreviousFishingLevel = player.fishingLevel; } if (player != null && player.foragingLevel != PreviousForagingLevel) { - Events.PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Foraging, player.foragingLevel); + PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Foraging, player.foragingLevel); PreviousForagingLevel = player.foragingLevel; } if (player != null && player.miningLevel != PreviousMiningLevel) { - Events.PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Mining, player.miningLevel); + PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Mining, player.miningLevel); PreviousMiningLevel = player.miningLevel; } if (player != null && player.luckLevel != PreviousLuckLevel) { - Events.PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Luck, player.luckLevel); + PlayerEvents.InvokeLeveledUp(EventArgsLevelUp.LevelType.Luck, player.luckLevel); PreviousLuckLevel = player.luckLevel; } List changedItems; if (player != null && HasInventoryChanged(player.items, out changedItems)) { - Events.PlayerEvents.InvokeInventoryChanged(player.items, changedItems); + PlayerEvents.InvokeInventoryChanged(player.items, changedItems); PreviousItems = player.items.Where(n => n != null).ToDictionary(n => n, n => n.Stack); } var objectHash = currentLocation?.objects?.GetHash(); if(objectHash != null && PreviousLocationObjects != objectHash) { - Events.LocationEvents.InvokeOnNewLocationObject(currentLocation.objects); + LocationEvents.InvokeOnNewLocationObject(currentLocation.objects); PreviousLocationObjects = objectHash ?? -1; } if (timeOfDay != PreviousTimeOfDay) { - Events.TimeEvents.InvokeTimeOfDayChanged(PreviousTimeOfDay, timeOfDay); + TimeEvents.InvokeTimeOfDayChanged(PreviousTimeOfDay, timeOfDay); PreviousTimeOfDay = timeOfDay; } if (dayOfMonth != PreviousDayOfMonth) { - Events.TimeEvents.InvokeDayOfMonthChanged(PreviousDayOfMonth, dayOfMonth); + TimeEvents.InvokeDayOfMonthChanged(PreviousDayOfMonth, dayOfMonth); PreviousDayOfMonth = dayOfMonth; } if (currentSeason != PreviousSeasonOfYear) { - Events.TimeEvents.InvokeSeasonOfYearChanged(PreviousSeasonOfYear, currentSeason); + TimeEvents.InvokeSeasonOfYearChanged(PreviousSeasonOfYear, currentSeason); PreviousSeasonOfYear = currentSeason; } if (year != PreviousYearOfGame) { - Events.TimeEvents.InvokeYearOfGameChanged(PreviousYearOfGame, year); + TimeEvents.InvokeYearOfGameChanged(PreviousYearOfGame, year); PreviousYearOfGame = year; } + + //NOTE THAT THIS MUST CHECK BEFORE SETTING IT TO TRUE BECAUSE OF SOME SILLY ISSUES + if (FireLoadedGameEvent) + { + PlayerEvents.InvokeLoadedGame(new EventArgsLoadedGameChanged(hasLoadedGame)); + FireLoadedGameEvent = false; + } + + if (hasLoadedGame != PreviouslyLoadedGame) + { + FireLoadedGameEvent = true; + PreviouslyLoadedGame = hasLoadedGame; + } } private bool HasInventoryChanged(List items, out List changedItems) { changedItems = new List(); - IEnumerable actualItems = items.Where(n => n != null); + IEnumerable actualItems = items.Where(n => n != null)?.ToArray(); foreach (var item in actualItems) { if (PreviousItems != null && PreviousItems.ContainsKey(item)) { if(PreviousItems[item] != item.Stack) { - changedItems.Add(new ItemStackChange() { Item = item, StackChange = item.Stack - PreviousItems[item], ChangeType = ChangeType.StackChange }); + changedItems.Add(new ItemStackChange { Item = item, StackChange = item.Stack - PreviousItems[item], ChangeType = ChangeType.StackChange }); } } else { - changedItems.Add(new ItemStackChange() { Item = item, StackChange = item.Stack, ChangeType = ChangeType.Added }); + changedItems.Add(new ItemStackChange { Item = item, StackChange = item.Stack, ChangeType = ChangeType.Added }); } } if (PreviousItems != null) { - changedItems.AddRange(PreviousItems.Where(n => !actualItems.Any(i => i == n.Key)).Select(n => - new ItemStackChange() { Item = n.Key, StackChange = -n.Key.Stack, ChangeType = ChangeType.Removed })); + changedItems.AddRange(PreviousItems.Where(n => actualItems.All(i => i != n.Key)).Select(n => + new ItemStackChange { Item = n.Key, StackChange = -n.Key.Stack, ChangeType = ChangeType.Removed })); } return (changedItems.Any()); diff --git a/StardewModdingAPI/Inheritance/SGameLocation.cs b/StardewModdingAPI/Inheritance/SGameLocation.cs index 437b0bfa..2d9a17ec 100644 --- a/StardewModdingAPI/Inheritance/SGameLocation.cs +++ b/StardewModdingAPI/Inheritance/SGameLocation.cs @@ -1,14 +1,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Eventing.Reader; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; -using StardewValley.BellsAndWhistles; namespace StardewModdingAPI.Inheritance { diff --git a/StardewModdingAPI/Inheritance/SObject.cs b/StardewModdingAPI/Inheritance/SObject.cs index 3dcddb9e..ea32d2fc 100644 --- a/StardewModdingAPI/Inheritance/SObject.cs +++ b/StardewModdingAPI/Inheritance/SObject.cs @@ -1,17 +1,13 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Xml.Serialization; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; -using StardewValley.Locations; +using Object = StardewValley.Object; namespace StardewModdingAPI.Inheritance { - public class SObject : StardewValley.Object + public class SObject : Object { public override String Name { get { return name; } @@ -68,7 +64,7 @@ namespace StardewModdingAPI.Inheritance { if (Texture != null) { - spriteBatch.Draw(Texture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(((x * Game1.tileSize) + (Game1.tileSize / 2)) + ((this.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0)), (float)(((y * Game1.tileSize) + (Game1.tileSize / 2)) + ((this.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0)))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.ParentSheetIndex)), (Color)(Color.White * alpha), 0f, new Vector2(8f, 8f), (this.scale.Y > 1f) ? this.getScale().Y : ((float)Game1.pixelZoom), this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.isPassable() ? ((float)this.getBoundingBox(new Vector2((float)x, (float)y)).Top) : ((float)this.getBoundingBox(new Vector2((float)x, (float)y)).Bottom)) / 10000f); + spriteBatch.Draw(Texture, Game1.GlobalToLocal(Game1.viewport, new Vector2(((x * Game1.tileSize) + (Game1.tileSize / 2)) + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), ((y * Game1.tileSize) + (Game1.tileSize / 2)) + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))), Game1.currentLocation.getSourceRectForObject(ParentSheetIndex), Color.White * alpha, 0f, new Vector2(8f, 8f), (scale.Y > 1f) ? getScale().Y : Game1.pixelZoom, flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (isPassable() ? getBoundingBox(new Vector2(x, y)).Top : getBoundingBox(new Vector2(x, y)).Bottom) / 10000f); } } @@ -86,8 +82,8 @@ namespace StardewModdingAPI.Inheritance if (Texture != null) { int targSize = Game1.tileSize; - int midX = (int) ((xNonTile) + 32); - int midY = (int) ((yNonTile) + 32); + int midX = (xNonTile) + 32; + int midY = (yNonTile) + 32; int targX = midX - targSize / 2; int targY = midY - targSize / 2; @@ -113,7 +109,7 @@ namespace StardewModdingAPI.Inheritance public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) { - if (this.isRecipe) + if (isRecipe) { transparency = 0.5f; scaleSize *= 0.75f; @@ -133,7 +129,7 @@ namespace StardewModdingAPI.Inheritance if (drawStackNumber) { float scale = 0.5f + scaleSize; - Game1.drawWithBorder(string.Concat(this.stack.ToString()), Color.Black, Color.White, location + new Vector2((float) Game1.tileSize - Game1.tinyFont.MeasureString(string.Concat(this.stack.ToString())).X * scale, (float) Game1.tileSize - (float) ((double) Game1.tinyFont.MeasureString(string.Concat(this.stack.ToString())).Y * 3.0f / 4.0f) * scale), 0.0f, scale, 1f, true); + Game1.drawWithBorder(string.Concat(stack.ToString()), Color.Black, Color.White, location + new Vector2(Game1.tileSize - Game1.tinyFont.MeasureString(string.Concat(stack.ToString())).X * scale, Game1.tileSize - (float) ((double) Game1.tinyFont.MeasureString(string.Concat(stack.ToString())).Y * 3.0f / 4.0f) * scale), 0.0f, scale, 1f, true); } } @@ -183,27 +179,27 @@ namespace StardewModdingAPI.Inheritance { SObject toRet = new SObject(); - toRet.Name = this.Name; - toRet.CategoryName = this.CategoryName; - toRet.Description = this.Description; - toRet.Texture = this.Texture; - toRet.IsPassable = this.IsPassable; - toRet.IsPlaceable = this.IsPlaceable; - toRet.quality = this.quality; - toRet.scale = this.scale; - toRet.isSpawnedObject = this.isSpawnedObject; - toRet.isRecipe = this.isRecipe; - toRet.questItem = this.questItem; + toRet.Name = Name; + toRet.CategoryName = CategoryName; + toRet.Description = Description; + toRet.Texture = Texture; + toRet.IsPassable = IsPassable; + toRet.IsPlaceable = IsPlaceable; + toRet.quality = quality; + toRet.scale = scale; + toRet.isSpawnedObject = isSpawnedObject; + toRet.isRecipe = isRecipe; + toRet.questItem = questItem; toRet.stack = 1; - toRet.HasBeenRegistered = this.HasBeenRegistered; - toRet.RegisteredId = this.RegisteredId; + toRet.HasBeenRegistered = HasBeenRegistered; + toRet.RegisteredId = RegisteredId; return toRet; } public override Item getOne() { - return this.Clone(); + return Clone(); } public override void actionWhenBeingHeld(Farmer who) @@ -247,10 +243,10 @@ namespace StardewModdingAPI.Inheritance SObject s = Clone(); s.PlacedAt = key; - s.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + s.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, boundingBox.Width, boundingBox.Height); location.objects.Add(key, s); - Log.Verbose("{0} - {1}", this.GetHashCode(), s.GetHashCode()); + Log.Verbose("{0} - {1}", GetHashCode(), s.GetHashCode()); return true; } @@ -268,7 +264,7 @@ namespace StardewModdingAPI.Inheritance int x = Game1.oldMouseState.X + Game1.viewport.X; int y = Game1.oldMouseState.Y + Game1.viewport.Y; - spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / Game1.tileSize * Game1.tileSize - Game1.viewport.X), (float)(y / Game1.tileSize * Game1.tileSize - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(Utility.playerCanPlaceItemHere(location, (Item)this, x, y, Game1.player) ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.01f); + spriteBatch.Draw(Game1.mouseCursors, new Vector2(x / Game1.tileSize * Game1.tileSize - Game1.viewport.X, y / Game1.tileSize * Game1.tileSize - Game1.viewport.Y), new Rectangle(Utility.playerCanPlaceItemHere(location, this, x, y, Game1.player) ? 194 : 210, 388, 16, 16), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 0.01f); } } } -- cgit