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 bool OnPlayerEnter()
{
if (base.OnPlayerEnter() == false) return false;
else
{
Game1.warpFarmer(Game1.getLocationFromName(this.warpInfo.targetMapName), this.warpInfo.targetX, this.warpInfo.targetY, this.warpInfo.facingDirection, this.warpInfo.isStructure);
return true;
}
}
///
/// Runs when the player is not on the tile and resets player interaction.
///
public override bool OnPlayerLeave()
{
if (base.OnPlayerLeave() == false) return false;
return true;
}
///
/// Used to update the event and check for interaction.
///
public override void update()
{
this.OnPlayerEnter();
this.OnPlayerLeave();
}
}
}