finished work on warp events

This commit is contained in:
2018-02-23 13:55:51 -08:00
parent 44a5887e1b
commit 534eda1414
23 changed files with 593 additions and 100 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net45" />
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net45" />
</packages>

View File

@ -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)
{
}
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BB737337-2D82-4245-AA46-F3B82FC6F228}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EventSystem</RootNamespace>
<AssemblyName>EventSystem</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EventSystem.cs" />
<Compile Include="Framework\Delegates.cs" />
<Compile Include="Framework\EventManager.cs" />
<Compile Include="Framework\Events\WarpEvent.cs" />
<Compile Include="Framework\FunctionEvents\functionEvent.cs" />
<Compile Include="Framework\FunctionEvents\MouseButtonEvents.cs" />
<Compile Include="Framework\FunctionEvents\MouseEntryLeaveEvent.cs" />
<Compile Include="Framework\FunctionEvents\PlayerEvents.cs" />
<Compile Include="Framework\Information\WarpInformation.cs" />
<Compile Include="Framework\MapEvent.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -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);

View File

@ -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<GameLocation, List<MapEvent>> mapEvents;
/// <summary>
/// Constructor.
/// </summary>
public EventManager()
{
this.mapEvents = new Dictionary<GameLocation, List<MapEvent>>();
foreach(var v in Game1.locations)
{
addLocation(v.name, false);
}
}
/// <summary>
/// Adds an event to the map given the name of the map.
/// </summary>
/// <param name="mapName"></param>
/// <param name="mapEvent"></param>
public virtual void addEvent(string mapName,MapEvent mapEvent)
{
foreach(var pair in this.mapEvents)
{
if (pair.Key.name == mapName)
{
pair.Value.Add(mapEvent);
}
}
}
/// <summary>
/// Adds an event to a map.
/// </summary>
/// <param name="Location"></param>
/// <param name="mapEvent"></param>
public virtual void addEvent(GameLocation Location, MapEvent mapEvent)
{
foreach (var pair in this.mapEvents)
{
if (pair.Key == Location)
{
pair.Value.Add(mapEvent);
}
}
}
/// <summary>
/// Adds a location to have events handled.
/// </summary>
/// <param name="Location">The location to handle events.</param>
public virtual void addLocation(GameLocation Location)
{
EventSystem.ModMonitor.Log("Adding event processing for location: " + Location.name);
this.mapEvents.Add(Location, new List<MapEvent>());
}
/// <summary>
/// Adds a location to have events handled.
/// </summary>
/// <param name="Location"></param>
/// <param name="Events"></param>
public virtual void addLocation(GameLocation Location,List<MapEvent> Events)
{
EventSystem.ModMonitor.Log("Adding event processing for location: " + Location.name);
this.mapEvents.Add(Location, Events);
}
/// <summary>
/// Adds a location to handle events.
/// </summary>
/// <param name="Location">The name of the location. Can include farm buildings.</param>
/// <param name="isStructure">Used if the building is a stucture. True=building.</param>
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<MapEvent>());
}
/// <summary>
/// Adds a location to have events handled.
/// </summary>
/// <param name="Location">The name of the location. Can include farm buildings.</param>
/// <param name="isStructure">Used if the building is a stucture. True=building.</param>
/// <param name="Events">A list of pre-initialized events.</param>
public virtual void addLocation(string Location, bool isStructure, List<MapEvent> Events)
{
EventSystem.ModMonitor.Log("Adding event processing for location: " + Location);
this.mapEvents.Add(Game1.getLocationFromName(Location,isStructure), Events);
}
/// <summary>
/// Updates all events associated with the event manager.
/// </summary>
public virtual void update()
{
List<MapEvent> events = new List<MapEvent>();
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();
}
}
}
}
}

View File

@ -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
{
/// <summary>
/// Used to handle warp events on the map.
/// </summary>
public class WarpEvent :MapEvent
{
WarpInformation warpInfo;
/// <summary>
/// Constructor for handling warp events.
/// </summary>
/// <param name="Name">The name of the event.</param>
/// <param name="Location">The game location that this event is located at.</param>
/// <param name="Position">The x,y tile position of the event.</param>
/// <param name="playerEvents">The events to occur when the player enters the warp tile before the warp.</param>
/// <param name="WarpInfo">The information for warping the farmer.</param>
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;
}
/// <summary>
/// Occurs when the player enters the warp tile event position.
/// </summary>
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);
}
}
/// <summary>
/// Runs when the player is not on the tile and resets player interaction.
/// </summary>
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();
}
}
/// <summary>
/// Used to update the event and check for interaction.
/// </summary>
public override void update()
{
this.OnPlayerEnter();
this.OnPlayerLeave();
}
}
}

View File

@ -4,12 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MapEvents.Framework.FunctionEvents
namespace EventSystem.Framework.FunctionEvents
{
/// <summary>
/// Used to handle mouse interactions with button clicks and scrolling the mouse wheel.
/// </summary>
class MouseButtonEvents
public class MouseButtonEvents
{
/// <summary>
/// Function that runs when the user left clicks.

View File

@ -4,12 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MapEvents.Framework.FunctionEvents
namespace EventSystem.Framework.FunctionEvents
{
/// <summary>
/// Used to handle events that happens when a mouse enters/leaves a specified position.
/// </summary>
class MouseEntryLeaveEvent
public class MouseEntryLeaveEvent
{
/// <summary>
/// A function that is called when a mouse enters a certain position.

View File

@ -4,12 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MapEvents.Framework.FunctionEvents
namespace EventSystem.Framework.FunctionEvents
{
/// <summary>
/// Used to handle various functions that occur on player interaction.
/// </summary>
class PlayerEvents
public class PlayerEvents
{
/// <summary>
/// Occurs when the player enters the same tile as this event.

View File

@ -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
{
/// <summary>
/// Used to pair a function and a parameter list using the super object class to run virtually any function for map events.
/// </summary>
class functionEvent
public class functionEvent
{
public paramFunction function;
public List<object> parameters;

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EventSystem.Framework.Information
{
/// <summary>
/// Used to store all of the information necessary to warp the farmer.
/// </summary>
public class WarpInformation
{
public string targetMapName;
public int targetX;
public int targetY;
public int facingDirection;
public bool isStructure;
/// <summary>
/// Constructor used to bundle together necessary information to warp the player character.
/// </summary>
/// <param name="MapName">The target map name to warp the farmer to.</param>
/// <param name="TargetX">The target X location on the map to warp the farmer to.</param>
/// <param name="TargetY">The target Y location on the map to warp the farmer to.</param>
/// <param name="FacingDirection">The facing direction for the farmer to be facing after the warp.</param>
/// <param name="IsStructure">Used to determine the position to be warped to when leaving a structure.</param>
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;
}
}
}

View File

@ -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
/// <summary>
/// Base class used to handle map tile events.
/// </summary>
public class MapEvent
{
/// <summary>
/// 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<Loc.List<Events>>
/// //MAKE NAME FOR EVENTS
/// </summary>
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;
/// <summary>
/// A simple map event that doesn't do anything.
/// </summary>
/// <param name="Location"></param>
/// <param name="Position"></param>
public MapEvent(GameLocation Location,Vector2 Position)
{
this.location = Location;
this.tilePosition = Position;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Constructors
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#region
/// <summary>
/// Empty Constructor
@ -55,6 +51,17 @@ namespace MapEvents.Framework
}
/// <summary>
/// A simple map event that doesn't do anything.
/// </summary>
/// <param name="Location"></param>
/// <param name="Position"></param>
public MapEvent(string name,GameLocation Location,Vector2 Position)
{
this.name = name;
this.location = Location;
this.tilePosition = Position;
}
/// <summary>
/// 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
/// <param name="position">The x,y position on the map the event is.</param>
/// <param name="PlayerEvents">Handles various events that runs when the player enters/leaves a tile, etc.</param>
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
/// <param name="Location">The game location where the event is.</param>
/// <param name="Position">The x,y position of the tile at the game location.</param>
/// <param name="mouseEvents">A class used to handle mouse entry/leave events.</param>
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
/// <param name="Location">The game location where the event is.</param>
/// <param name="Position">The x,y position of the tile at the game location.</param>
/// <param name="mouseEvents">A class used to handle mouse click/scroll events.</param>
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
/// <param name="playerEvents">The events that occur associated with the player. I.E player entry, etc.</param>
/// <param name="mouseButtonEvents">The events associated with clicking a mouse button while on this tile.</param>
/// <param name="mouseEntryLeaveEvents">The events that occur when the mouse enters or leaves the same tile position as this event.</param>
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
/// <summary>
/// Occurs when the player enters the same tile as this event. The function associated with this event is then ran.
/// </summary>
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();
}
}
/// <summary>
/// Occurs when the player leaves the same tile that this event is on. The function associated with thie event is then ran.
/// </summary>
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();
}
}
/// <summary>
/// Checks if the player is on the same tile as this event.
/// </summary>
/// <returns></returns>
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
/// <summary>
/// Occurs when the player left clicks the same tile that this event is on.
/// </summary>
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
/// <summary>
/// Occurs when the player right clicks the same tile that this event is on.
/// </summary>
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
/// <summary>
/// Occurs when the mouse tile position is the same as this event's x,y position.
/// </summary>
public void OnMouseEnter()
public virtual void OnMouseEnter()
{
if (isMouseOnTile())
{
@ -164,7 +205,7 @@ namespace MapEvents.Framework
/// <summary>
/// Occurs when the mouse tile position leaves the the same x,y position as this event.
/// </summary>
public void OnMouseLeave()
public virtual void OnMouseLeave()
{
if (isMouseOnTile() == false && this.mouseOnTile == true)
{
@ -174,52 +215,49 @@ namespace MapEvents.Framework
}
/// <summary>
/// UNUSED!!!!
/// Occurs when the mouse is on the same position as the tile AND the user scrolls the mouse wheel.
/// </summary>
public void OnMouseScroll()
public virtual void OnMouseScroll()
{
if (isMouseOnTile() == false) return;
if (this.mouseButtonEvents.onMouseScroll != null) this.mouseButtonEvents.onMouseScroll.run();
}
/// <summary>
/// Checks if the player is on the same tile as this event.
/// </summary>
/// <returns></returns>
public bool isPlayerOnTile()
{
if (Game1.player.getTileX() == this.tilePosition.X && Game1.player.getTileY() == this.tilePosition.Y) return true;
else return false;
}
/// <summary>
/// Checks if the player is on the same tile as the event and then runs the associated event.
/// </summary>
public void isPlayerOnTileRunEvent()
{
if (isPlayerOnTile() == true) OnPlayerEnter();
}
/// <summary>
/// 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.
/// </summary>
public void didPlayerLeaveTileRunEvent()
{
if (this.playerOnTile == true && isPlayerOnTile() == false) this.OnPlayerLeave();
}
/// <summary>
/// Checks if the mouse is on the tile.
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// Occurs when the tile is clicked. Runs the appropriate event.
/// </summary>
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
/// <summary>
/// Used to check if any sort of events need to run on this tile right now.
/// </summary>
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.
}
}
}

View File

@ -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": [ ]
}

View File

@ -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

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardustCore.Math
namespace StardustCore.StardustMath
{
/// <summary>
/// Base class for hex representation.

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardustCore.Math
namespace StardustCore.StardustMath
{
/// <summary>
/// A Class that helps represents 32 bit hex.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net45" />
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net45" />
</packages>

View File

@ -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)));
}
}
}

View File

@ -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")]

View File

@ -4,11 +4,11 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BB737337-2D82-4245-AA46-F3B82FC6F228}</ProjectGuid>
<ProjectGuid>{29A68F94-B23C-442B-8867-8B8F3502E64F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MapEvents</RootNamespace>
<AssemblyName>MapEvents</AssemblyName>
<RootNamespace>SundropMapEvents</RootNamespace>
<AssemblyName>SundropMapEvents</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
@ -30,6 +30,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EventSystem">
<HintPath>..\MapEvents\bin\Release\EventSystem.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />

View File

@ -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
}
]
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net45" />
</packages>