From 534eda1414c93ab51952cccc3bda3a52fde06ff3 Mon Sep 17 00:00:00 2001 From: Date: Fri, 23 Feb 2018 13:55:51 -0800 Subject: [PATCH] finished work on warp events --- .../AdditionalCropsFramework/packages.config | 2 +- GeneralMods/MapEvents/Class1.cs | 17 -- GeneralMods/MapEvents/EventSystem.cs | 37 ++++ GeneralMods/MapEvents/EventSystem.csproj | 75 ++++++++ GeneralMods/MapEvents/Framework/Delegates.cs | 4 +- .../MapEvents/Framework/EventManager.cs | 122 +++++++++++++ .../MapEvents/Framework/Events/WarpEvent.cs | 77 ++++++++ .../FunctionEvents/MouseButtonEvents.cs | 4 +- .../FunctionEvents/MouseEntryLeaveEvent.cs | 4 +- .../Framework/FunctionEvents/PlayerEvents.cs | 4 +- .../Framework/FunctionEvents/functionEvent.cs | 6 +- .../Framework/Information/WarpInformation.cs | 37 ++++ GeneralMods/MapEvents/Framework/MapEvent.cs | 168 +++++++++++------- GeneralMods/MapEvents/manifest.json | 10 ++ GeneralMods/StardewMods.sln | 22 +++ GeneralMods/StardustCore/Math/Hex.cs | 2 +- GeneralMods/StardustCore/Math/Hex32.cs | 2 +- GeneralMods/StardustCore/packages.config | 2 +- GeneralMods/SundropMapEvents/Class1.cs | 32 ++++ .../Properties/AssemblyInfo.cs | 36 ++++ .../SundropMapEvents.csproj} | 9 +- GeneralMods/SundropMapEvents/manifest.json | 16 ++ GeneralMods/SundropMapEvents/packages.config | 5 + 23 files changed, 593 insertions(+), 100 deletions(-) delete mode 100644 GeneralMods/MapEvents/Class1.cs create mode 100644 GeneralMods/MapEvents/EventSystem.cs create mode 100644 GeneralMods/MapEvents/EventSystem.csproj create mode 100644 GeneralMods/MapEvents/Framework/EventManager.cs create mode 100644 GeneralMods/MapEvents/Framework/Events/WarpEvent.cs create mode 100644 GeneralMods/MapEvents/Framework/Information/WarpInformation.cs create mode 100644 GeneralMods/MapEvents/manifest.json create mode 100644 GeneralMods/SundropMapEvents/Class1.cs create mode 100644 GeneralMods/SundropMapEvents/Properties/AssemblyInfo.cs rename GeneralMods/{MapEvents/MapEvents.csproj => SundropMapEvents/SundropMapEvents.csproj} (91%) create mode 100644 GeneralMods/SundropMapEvents/manifest.json create mode 100644 GeneralMods/SundropMapEvents/packages.config diff --git a/GeneralMods/AdditionalCropsFramework/packages.config b/GeneralMods/AdditionalCropsFramework/packages.config index ffa27b4a..0dfc12f8 100644 --- a/GeneralMods/AdditionalCropsFramework/packages.config +++ b/GeneralMods/AdditionalCropsFramework/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/GeneralMods/MapEvents/Class1.cs b/GeneralMods/MapEvents/Class1.cs deleted file mode 100644 index 7dadf81e..00000000 --- a/GeneralMods/MapEvents/Class1.cs +++ /dev/null @@ -1,17 +0,0 @@ -using StardewModdingAPI; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MapEvents -{ - public class MapEvents: Mod - { - public override void Entry(IModHelper helper) - { - - } - } -} diff --git a/GeneralMods/MapEvents/EventSystem.cs b/GeneralMods/MapEvents/EventSystem.cs new file mode 100644 index 00000000..f396aab4 --- /dev/null +++ b/GeneralMods/MapEvents/EventSystem.cs @@ -0,0 +1,37 @@ +using EventSystem.Framework; +using StardewModdingAPI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EventSystem +{ + public class EventSystem: Mod + { + public static IModHelper ModHelper; + public static IMonitor ModMonitor; + + public static EventManager eventManager; + public override void Entry(IModHelper helper) + { + + ModHelper = this.Helper; + ModMonitor = this.Monitor; + StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; + StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + } + + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + eventManager = new EventManager(); + } + + private void GameEvents_UpdateTick(object sender, EventArgs e) + { + if (eventManager == null) return; + eventManager.update(); + } + } +} diff --git a/GeneralMods/MapEvents/EventSystem.csproj b/GeneralMods/MapEvents/EventSystem.csproj new file mode 100644 index 00000000..6b437ff4 --- /dev/null +++ b/GeneralMods/MapEvents/EventSystem.csproj @@ -0,0 +1,75 @@ + + + + + Debug + AnyCPU + {BB737337-2D82-4245-AA46-F3B82FC6F228} + Library + Properties + EventSystem + EventSystem + v4.5 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/GeneralMods/MapEvents/Framework/Delegates.cs b/GeneralMods/MapEvents/Framework/Delegates.cs index 206d1294..617d0080 100644 --- a/GeneralMods/MapEvents/Framework/Delegates.cs +++ b/GeneralMods/MapEvents/Framework/Delegates.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MapEvents.Framework +namespace EventSystem.Framework { - class Delegates + public class Delegates { public delegate void voidDel(); public delegate void strDel(string s); diff --git a/GeneralMods/MapEvents/Framework/EventManager.cs b/GeneralMods/MapEvents/Framework/EventManager.cs new file mode 100644 index 00000000..79c68a15 --- /dev/null +++ b/GeneralMods/MapEvents/Framework/EventManager.cs @@ -0,0 +1,122 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EventSystem.Framework +{ + public class EventManager + { + public Dictionary> mapEvents; + + /// + /// Constructor. + /// + public EventManager() + { + this.mapEvents = new Dictionary>(); + foreach(var v in Game1.locations) + { + addLocation(v.name, false); + } + } + + /// + /// Adds an event to the map given the name of the map. + /// + /// + /// + public virtual void addEvent(string mapName,MapEvent mapEvent) + { + foreach(var pair in this.mapEvents) + { + if (pair.Key.name == mapName) + { + pair.Value.Add(mapEvent); + } + } + } + + /// + /// Adds an event to a map. + /// + /// + /// + public virtual void addEvent(GameLocation Location, MapEvent mapEvent) + { + foreach (var pair in this.mapEvents) + { + if (pair.Key == Location) + { + + pair.Value.Add(mapEvent); + } + } + } + + /// + /// Adds a location to have events handled. + /// + /// The location to handle events. + public virtual void addLocation(GameLocation Location) + { + EventSystem.ModMonitor.Log("Adding event processing for location: " + Location.name); + this.mapEvents.Add(Location, new List()); + } + + /// + /// Adds a location to have events handled. + /// + /// + /// + public virtual void addLocation(GameLocation Location,List Events) + { + EventSystem.ModMonitor.Log("Adding event processing for location: " + Location.name); + this.mapEvents.Add(Location, Events); + } + + /// + /// Adds a location to handle events. + /// + /// The name of the location. Can include farm buildings. + /// Used if the building is a stucture. True=building. + public virtual void addLocation(string Location,bool isStructure) + { + EventSystem.ModMonitor.Log("Adding event processing for location: " + Location); + this.mapEvents.Add(Game1.getLocationFromName(Location,isStructure), new List()); + } + + /// + /// Adds a location to have events handled. + /// + /// The name of the location. Can include farm buildings. + /// Used if the building is a stucture. True=building. + /// A list of pre-initialized events. + public virtual void addLocation(string Location, bool isStructure, List Events) + { + EventSystem.ModMonitor.Log("Adding event processing for location: " + Location); + this.mapEvents.Add(Game1.getLocationFromName(Location,isStructure), Events); + } + + /// + /// Updates all events associated with the event manager. + /// + public virtual void update() + { + List events = new List(); + if (Game1.player == null) return; + if (Game1.hasLoadedGame == false) return; + bool ok=this.mapEvents.TryGetValue(Game1.player.currentLocation, out events); + if (ok == false) return; + else + { + foreach(var v in events) + { + v.update(); + } + } + } + } +} diff --git a/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs b/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs new file mode 100644 index 00000000..68ae3f3b --- /dev/null +++ b/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs @@ -0,0 +1,77 @@ +using EventSystem.Framework.FunctionEvents; +using EventSystem.Framework.Information; +using Microsoft.Xna.Framework; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EventSystem.Framework.Events +{ + /// + /// Used to handle warp events on the map. + /// + public class WarpEvent :MapEvent + { + WarpInformation warpInfo; + + /// + /// Constructor for handling warp events. + /// + /// The name of the event. + /// The game location that this event is located at. + /// The x,y tile position of the event. + /// The events to occur when the player enters the warp tile before the warp. + /// The information for warping the farmer. + public WarpEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents,WarpInformation WarpInfo) : base(Name, Location, Position, playerEvents) + { + this.name = Name; + this.location = Location; + this.tilePosition = Position; + this.playerEvents = playerEvents; + this.warpInfo = WarpInfo; + + this.doesInteractionNeedToRun = true; + } + + /// + /// Occurs when the player enters the warp tile event position. + /// + public override void OnPlayerEnter() + { + if (isPlayerOnTile() == true&& this.doesInteractionNeedToRun==true) + { + this.doesInteractionNeedToRun = false; + this.playerOnTile = true; + if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); //used to run a function before the warp. + Game1.warpFarmer(Game1.getLocationFromName(this.warpInfo.targetMapName),this.warpInfo.targetX,this.warpInfo.targetY,this.warpInfo.facingDirection,this.warpInfo.isStructure); + } + } + + /// + /// Runs when the player is not on the tile and resets player interaction. + /// + public override void OnPlayerLeave() + { + if (isPlayerOnTile() == false && this.playerOnTile == true) + { + this.playerOnTile = false; + this.doesInteractionNeedToRun = true; + if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + } + } + + /// + /// Used to update the event and check for interaction. + /// + public override void update() + { + this.OnPlayerEnter(); + this.OnPlayerLeave(); + } + + + } +} diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs index e44ae354..634f9086 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MapEvents.Framework.FunctionEvents +namespace EventSystem.Framework.FunctionEvents { /// /// Used to handle mouse interactions with button clicks and scrolling the mouse wheel. /// - class MouseButtonEvents + public class MouseButtonEvents { /// /// Function that runs when the user left clicks. diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs index dd8487f7..7ae55635 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MapEvents.Framework.FunctionEvents +namespace EventSystem.Framework.FunctionEvents { /// /// Used to handle events that happens when a mouse enters/leaves a specified position. /// - class MouseEntryLeaveEvent + public class MouseEntryLeaveEvent { /// /// A function that is called when a mouse enters a certain position. diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs index 382e7bc0..e29d55ae 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MapEvents.Framework.FunctionEvents +namespace EventSystem.Framework.FunctionEvents { /// /// Used to handle various functions that occur on player interaction. /// - class PlayerEvents + public class PlayerEvents { /// /// Occurs when the player enters the same tile as this event. diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs index d1487719..896c2050 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static MapEvents.Framework.Delegates; +using static EventSystem.Framework.Delegates; -namespace MapEvents.Framework +namespace EventSystem.Framework { /// /// Used to pair a function and a parameter list using the super object class to run virtually any function for map events. /// - class functionEvent + public class functionEvent { public paramFunction function; public List parameters; diff --git a/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs b/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs new file mode 100644 index 00000000..7cda2745 --- /dev/null +++ b/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EventSystem.Framework.Information +{ + /// + /// Used to store all of the information necessary to warp the farmer. + /// + public class WarpInformation + { + public string targetMapName; + public int targetX; + public int targetY; + public int facingDirection; + public bool isStructure; + + /// + /// Constructor used to bundle together necessary information to warp the player character. + /// + /// The target map name to warp the farmer to. + /// The target X location on the map to warp the farmer to. + /// The target Y location on the map to warp the farmer to. + /// The facing direction for the farmer to be facing after the warp. + /// Used to determine the position to be warped to when leaving a structure. + public WarpInformation(string MapName, int TargetX,int TargetY, int FacingDirection, bool IsStructure) + { + this.targetMapName = MapName; + this.targetX = TargetX; + this.targetY = TargetY; + this.facingDirection = FacingDirection; + this.isStructure = IsStructure; + } + } +} diff --git a/GeneralMods/MapEvents/Framework/MapEvent.cs b/GeneralMods/MapEvents/Framework/MapEvent.cs index fe89b7b4..d07d213e 100644 --- a/GeneralMods/MapEvents/Framework/MapEvent.cs +++ b/GeneralMods/MapEvents/Framework/MapEvent.cs @@ -1,51 +1,47 @@ -using MapEvents.Framework.FunctionEvents; +using EventSystem.Framework.FunctionEvents; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; using StardewValley; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static MapEvents.Framework.Delegates; -namespace MapEvents.Framework +namespace EventSystem.Framework { - class MapEvent + + /// + /// Base class used to handle map tile events. + /// + public class MapEvent { /// - /// Make an update function that runs associated functions to check which events need to be ran. - /// make way to detect which button is clicked when on this tile. - /// //MAKE A MAP EVENT MANAGER TO HOLD GAME LOCATIONS AND A LIST OF MAP EVENTS!!!!!! Dic> + /// //MAKE NAME FOR EVENTS /// - + public string name; + public Vector2 tilePosition; public GameLocation location; public PlayerEvents playerEvents; - public bool playerOnTile; - public MouseButtonEvents mouseButtonEvents; public MouseEntryLeaveEvent mouseEntryLeaveEvents; public bool mouseOnTile; - - public bool doesInteractionNeedToRun; public bool loopInteraction; - /// - /// A simple map event that doesn't do anything. - /// - /// - /// - public MapEvent(GameLocation Location,Vector2 Position) - { - this.location = Location; - this.tilePosition = Position; - } + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Constructors + + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + #region + /// /// Empty Constructor @@ -55,6 +51,17 @@ namespace MapEvents.Framework } + /// + /// A simple map event that doesn't do anything. + /// + /// + /// + public MapEvent(string name,GameLocation Location,Vector2 Position) + { + this.name = name; + this.location = Location; + this.tilePosition = Position; + } /// /// A simple map function that runs when the player enters and leaves a tile. Set values to null for nothing to happen. @@ -63,8 +70,9 @@ namespace MapEvents.Framework /// The x,y position on the map the event is. /// Handles various events that runs when the player enters/leaves a tile, etc. - public MapEvent(GameLocation Location,Vector2 position, PlayerEvents PlayerEvents) + public MapEvent(string name,GameLocation Location,Vector2 position, PlayerEvents PlayerEvents) { + this.name = name; this.location = Location; this.tilePosition = position; this.playerEvents = PlayerEvents; @@ -76,8 +84,9 @@ namespace MapEvents.Framework /// The game location where the event is. /// The x,y position of the tile at the game location. /// A class used to handle mouse entry/leave events. - public MapEvent(GameLocation Location, Vector2 Position, MouseEntryLeaveEvent mouseEvents) + public MapEvent(string name,GameLocation Location, Vector2 Position, MouseEntryLeaveEvent mouseEvents) { + this.name = name; this.location = Location; this.tilePosition = Position; this.mouseEntryLeaveEvents = mouseEvents; @@ -89,8 +98,9 @@ namespace MapEvents.Framework /// The game location where the event is. /// The x,y position of the tile at the game location. /// A class used to handle mouse click/scroll events. - public MapEvent(GameLocation Location, Vector2 Position, MouseButtonEvents mouseEvents) + public MapEvent(string name,GameLocation Location, Vector2 Position, MouseButtonEvents mouseEvents) { + this.name = name; this.location = Location; this.tilePosition = Position; this.mouseButtonEvents = mouseEvents; @@ -104,37 +114,68 @@ namespace MapEvents.Framework /// The events that occur associated with the player. I.E player entry, etc. /// The events associated with clicking a mouse button while on this tile. /// The events that occur when the mouse enters or leaves the same tile position as this event. - public MapEvent(GameLocation Location, Vector2 Position, PlayerEvents playerEvents, MouseButtonEvents mouseButtonEvents, MouseEntryLeaveEvent mouseEntryLeaveEvents) + public MapEvent(string name,GameLocation Location, Vector2 Position, PlayerEvents playerEvents, MouseButtonEvents mouseButtonEvents, MouseEntryLeaveEvent mouseEntryLeaveEvents) { + this.name = name; this.location = Location; this.tilePosition = Position; this.playerEvents = playerEvents; this.mouseButtonEvents = mouseButtonEvents; this.mouseEntryLeaveEvents = mouseEntryLeaveEvents; } + #endregion + + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Player related functions + + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + #region /// /// Occurs when the player enters the same tile as this event. The function associated with this event is then ran. /// - private void OnPlayerEnter() + public virtual void OnPlayerEnter() { - this.playerOnTile = true; - if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); + if (isPlayerOnTile() == true) + { + this.playerOnTile = true; + if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); + } } /// /// Occurs when the player leaves the same tile that this event is on. The function associated with thie event is then ran. /// - private void OnPlayerLeave() + public virtual void OnPlayerLeave() { - this.playerOnTile = false; - if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerEnter.run(); + if(isPlayerOnTile() == false && this.playerOnTile==true){ + this.playerOnTile = false; + if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + } } + /// + /// Checks if the player is on the same tile as this event. + /// + /// + public virtual bool isPlayerOnTile() + { + if (Game1.player.getTileX() == this.tilePosition.X && Game1.player.getTileY() == this.tilePosition.Y) return true; + else return false; + } + #endregion + + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Mouse related functions + + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + #region /// /// Occurs when the player left clicks the same tile that this event is on. /// - public void OnLeftClick() + public virtual void OnLeftClick() { if (this.mouseOnTile==false) return; if (this.mouseButtonEvents.onLeftClick != null) this.mouseButtonEvents.onLeftClick.run(); @@ -143,7 +184,7 @@ namespace MapEvents.Framework /// /// Occurs when the player right clicks the same tile that this event is on. /// - public void OnRightClick() + public virtual void OnRightClick() { if (this.mouseOnTile == false) return; if (this.mouseButtonEvents.onRightClick != null) this.mouseButtonEvents.onRightClick.run(); @@ -152,7 +193,7 @@ namespace MapEvents.Framework /// /// Occurs when the mouse tile position is the same as this event's x,y position. /// - public void OnMouseEnter() + public virtual void OnMouseEnter() { if (isMouseOnTile()) { @@ -164,7 +205,7 @@ namespace MapEvents.Framework /// /// Occurs when the mouse tile position leaves the the same x,y position as this event. /// - public void OnMouseLeave() + public virtual void OnMouseLeave() { if (isMouseOnTile() == false && this.mouseOnTile == true) { @@ -174,52 +215,49 @@ namespace MapEvents.Framework } /// + /// UNUSED!!!! /// Occurs when the mouse is on the same position as the tile AND the user scrolls the mouse wheel. /// - public void OnMouseScroll() + public virtual void OnMouseScroll() { if (isMouseOnTile() == false) return; if (this.mouseButtonEvents.onMouseScroll != null) this.mouseButtonEvents.onMouseScroll.run(); } - /// - /// Checks if the player is on the same tile as this event. - /// - /// - public bool isPlayerOnTile() - { - if (Game1.player.getTileX() == this.tilePosition.X && Game1.player.getTileY() == this.tilePosition.Y) return true; - else return false; - } - - /// - /// Checks if the player is on the same tile as the event and then runs the associated event. - /// - public void isPlayerOnTileRunEvent() - { - if (isPlayerOnTile() == true) OnPlayerEnter(); - } - - /// - /// If the player recently entered the tile and the player is no longer on this tile then the player left the tile. If that is true then run the leaving function. - /// - public void didPlayerLeaveTileRunEvent() - { - if (this.playerOnTile == true && isPlayerOnTile() == false) this.OnPlayerLeave(); - } - /// /// Checks if the mouse is on the tile. /// /// - public bool isMouseOnTile() + public virtual bool isMouseOnTile() { Vector2 mousePosition = new Vector2(Game1.getMouseX(), Game1.getMouseY()); if (mousePosition.X == this.tilePosition.X && mousePosition.Y == this.tilePosition.Y) return true; return false; } - + /// + /// Occurs when the tile is clicked. Runs the appropriate event. + /// + public virtual void eventClickEvent() + { + if (this.mouseOnTile == false) return; + var mouseState=Mouse.GetState(); + if (mouseState.LeftButton == ButtonState.Pressed) OnLeftClick(); + if (mouseState.RightButton == ButtonState.Pressed) OnRightClick(); + } +#endregion + + /// + /// Used to check if any sort of events need to run on this tile right now. + /// + public virtual void update() + { + eventClickEvent(); //click events + OnPlayerEnter(); //player enter events + OnPlayerLeave(); //player leave events + OnMouseEnter(); //on mouse enter events + OnMouseLeave(); //on mouse leave events. + } } } diff --git a/GeneralMods/MapEvents/manifest.json b/GeneralMods/MapEvents/manifest.json new file mode 100644 index 00000000..4579d6f3 --- /dev/null +++ b/GeneralMods/MapEvents/manifest.json @@ -0,0 +1,10 @@ +{ + "Name": "EventSystem", + "Author": "Alpha_Omegasis", + "Version": "0.1.0", + "Description": "A system to manage different events that can happen on the map.", + "UniqueID": "Omegasis.EventSystem", + "EntryDll": "EventSystem.dll", + "MinimumApiVersion": "2.0", + "UpdateKeys": [ ] +} diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index f5e56d43..076cb9cb 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -71,6 +71,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewSymphonyRemastered", {0756D36A-95C8-480D-8EA6-4584C03010C6} = {0756D36A-95C8-480D-8EA6-4584C03010C6} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sundrop", "Sundrop", "{3EE26DA0-0337-4991-8B02-BCB8D408008C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventSystem", "MapEvents\EventSystem.csproj", "{BB737337-2D82-4245-AA46-F3B82FC6F228}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventSystemMods", "EventSystemMods", "{BAAC8F21-C12F-42B0-A51C-0C5F33B52575}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SundropMapEvents", "SundropMapEvents\SundropMapEvents.csproj", "{29A68F94-B23C-442B-8867-8B8F3502E64F}" + ProjectSection(ProjectDependencies) = postProject + {BB737337-2D82-4245-AA46-F3B82FC6F228} = {BB737337-2D82-4245-AA46-F3B82FC6F228} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -169,11 +180,22 @@ Global {19F64B03-6A9B-49E1-854A-C05D5A014646}.Debug|Any CPU.Build.0 = Debug|Any CPU {19F64B03-6A9B-49E1-854A-C05D5A014646}.Release|Any CPU.ActiveCfg = Release|Any CPU {19F64B03-6A9B-49E1-854A-C05D5A014646}.Release|Any CPU.Build.0 = Release|Any CPU + {BB737337-2D82-4245-AA46-F3B82FC6F228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB737337-2D82-4245-AA46-F3B82FC6F228}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB737337-2D82-4245-AA46-F3B82FC6F228}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB737337-2D82-4245-AA46-F3B82FC6F228}.Release|Any CPU.Build.0 = Release|Any CPU + {29A68F94-B23C-442B-8867-8B8F3502E64F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29A68F94-B23C-442B-8867-8B8F3502E64F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29A68F94-B23C-442B-8867-8B8F3502E64F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29A68F94-B23C-442B-8867-8B8F3502E64F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {8415BB0C-94A7-4E11-B6D5-C31649C3A95D} = {953CD0A4-8529-45E6-87C2-31837940D62C} + {BB737337-2D82-4245-AA46-F3B82FC6F228} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} + {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} + {29A68F94-B23C-442B-8867-8B8F3502E64F} = {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} EndGlobalSection EndGlobal diff --git a/GeneralMods/StardustCore/Math/Hex.cs b/GeneralMods/StardustCore/Math/Hex.cs index 03d4ae35..01ba3dd3 100644 --- a/GeneralMods/StardustCore/Math/Hex.cs +++ b/GeneralMods/StardustCore/Math/Hex.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StardustCore.Math +namespace StardustCore.StardustMath { /// /// Base class for hex representation. diff --git a/GeneralMods/StardustCore/Math/Hex32.cs b/GeneralMods/StardustCore/Math/Hex32.cs index 25da9ed0..b3065b0c 100644 --- a/GeneralMods/StardustCore/Math/Hex32.cs +++ b/GeneralMods/StardustCore/Math/Hex32.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace StardustCore.Math +namespace StardustCore.StardustMath { /// /// A Class that helps represents 32 bit hex. diff --git a/GeneralMods/StardustCore/packages.config b/GeneralMods/StardustCore/packages.config index ffa27b4a..0dfc12f8 100644 --- a/GeneralMods/StardustCore/packages.config +++ b/GeneralMods/StardustCore/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/GeneralMods/SundropMapEvents/Class1.cs b/GeneralMods/SundropMapEvents/Class1.cs new file mode 100644 index 00000000..62ad006a --- /dev/null +++ b/GeneralMods/SundropMapEvents/Class1.cs @@ -0,0 +1,32 @@ +using StardewModdingAPI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EventSystem; +using StardewValley; +using EventSystem.Framework.FunctionEvents; +using EventSystem.Framework.Information; +using Microsoft.Xna.Framework; + +namespace SundropMapEvents +{ + public class Class1 :Mod + { + + public static IModHelper ModHelper; + public static IMonitor ModMonitor; + public override void Entry(IModHelper helper) + { + ModHelper = this.Helper; + ModMonitor = this.Monitor; + StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + } + + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new EventSystem.Framework.Events.WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false))); + } + } +} diff --git a/GeneralMods/SundropMapEvents/Properties/AssemblyInfo.cs b/GeneralMods/SundropMapEvents/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..b394cc6c --- /dev/null +++ b/GeneralMods/SundropMapEvents/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SundropMapEvents")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SundropMapEvents")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("29a68f94-b23c-442b-8867-8b8f3502e64f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/MapEvents/MapEvents.csproj b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj similarity index 91% rename from GeneralMods/MapEvents/MapEvents.csproj rename to GeneralMods/SundropMapEvents/SundropMapEvents.csproj index f01a7780..95c10476 100644 --- a/GeneralMods/MapEvents/MapEvents.csproj +++ b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj @@ -4,11 +4,11 @@ Debug AnyCPU - {BB737337-2D82-4245-AA46-F3B82FC6F228} + {29A68F94-B23C-442B-8867-8B8F3502E64F} Library Properties - MapEvents - MapEvents + SundropMapEvents + SundropMapEvents v4.5 512 @@ -30,6 +30,9 @@ 4 + + ..\MapEvents\bin\Release\EventSystem.dll + diff --git a/GeneralMods/SundropMapEvents/manifest.json b/GeneralMods/SundropMapEvents/manifest.json new file mode 100644 index 00000000..9f2ab67d --- /dev/null +++ b/GeneralMods/SundropMapEvents/manifest.json @@ -0,0 +1,16 @@ +{ + "Name": "SunDropMapEvents", + "Author": "Alpha_Omegasis", + "Version": "0.1.0", + "Description": "A system to add events to the SunDropMod", + "UniqueID": "SunDrop.MapEvents", + "EntryDll": "SunDropMapEvents.dll", + "MinimumApiVersion": "2.0", + "UpdateKeys": [ ], + "Dependencies": [ + { + "UniqueID": "Omegasis.EventSystem", + "IsRequired": true + } +] +} diff --git a/GeneralMods/SundropMapEvents/packages.config b/GeneralMods/SundropMapEvents/packages.config new file mode 100644 index 00000000..ffa27b4a --- /dev/null +++ b/GeneralMods/SundropMapEvents/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file