using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using StardewValley;
using static StardustCore.Events.EventHelper;
namespace StardustCore.Events
{
public class EventStartData
{
///
/// Data pertaining to npcs information necessary for the event.
///
public class NPCData
{
private NPC npc;
int xPosition;
int yPosition;
EventHelper.FacingDirection direction;
public NPCData()
{
}
public NPCData(NPC NPC, int XTile, int YTile, EventHelper.FacingDirection Direction)
{
this.npc = NPC;
this.xPosition = XTile;
this.yPosition = YTile;
this.direction = Direction;
}
public override string ToString()
{
StringBuilder b = new StringBuilder();
b.Append(this.npc.Name);
b.Append(" ");
b.Append(this.xPosition.ToString());
b.Append(" ");
b.Append(this.yPosition.ToString());
b.Append(" ");
b.Append(this.getFacingDirectionNumber(this.direction).ToString());
return b.ToString();
}
protected int getFacingDirectionNumber(FacingDirection Dir)
{
return (int)Dir;
}
}
///
/// Data pertaining to the farmer data for the event.
///
public class FarmerData
{
int xPosition;
int yPosition;
EventHelper.FacingDirection direction;
public FarmerData()
{
}
///
///Constructor.
///
///
///
///
public FarmerData(int XTile, int YTile, EventHelper.FacingDirection Direction)
{
this.xPosition = XTile;
this.yPosition = YTile;
this.direction = Direction;
}
///
/// Gets a string representation of the farmer's starting data.
///
///
public override string ToString()
{
StringBuilder b = new StringBuilder();
b.Append("farmer");
b.Append(" ");
b.Append(this.xPosition.ToString());
b.Append(" ");
b.Append(this.yPosition.ToString());
b.Append(" ");
b.Append(((int)this.direction).ToString());
return b.ToString();
}
}
///
/// The string builder to output the information.
///
private StringBuilder builder;
///
/// A special variable to determined if to continue the music that is already playing or to turn off the music.
///
public enum MusicToPlayType
{
None,
Continue,
}
public EventStartData()
{
this.builder = new StringBuilder();
}
///
/// Create the start data necessary for the event.
///
/// A special type to determine what music is played. None or Continue.
/// The starting xtile for the camera
/// The starting y tile for the camera
/// The farmer data for the event. If null then the farmer won't be in this event.
/// The npc data for the event. If null then no npcs will be in the event.
public EventStartData(MusicToPlayType MusicType, int CameraTileX, int CameraTileY, FarmerData Farmer, List NPCS)
{
this.builder = new StringBuilder();
if(MusicType== MusicToPlayType.None)
{
this.add("none");
}
if(MusicType== MusicToPlayType.Continue)
{
this.add("continue");
}
this.add(CameraTileX.ToString());
this.builder.Append(" ");
this.builder.Append(CameraTileY.ToString());
StringBuilder npcData = new StringBuilder();
if (Farmer != null)
{
npcData.Append(Farmer.ToString());
}
if (NPCS != null)
{
foreach(var v in NPCS)
{
npcData.Append(" ");
npcData.Append(v.ToString());
}
}
this.add(npcData.ToString());
this.add("skippable");
}
///
/// Create the start data necessary for the event.
///
/// The name of the song to play.
/// The starting xtile for the camera
/// The starting y tile for the camera
/// The farmer data for the event. If null then the farmer won't be in this event.
/// The npc data for the event. If null then no npcs will be in the event.
public EventStartData(string SongToPlay, int CameraTileX, int CameraTileY, FarmerData Farmer, List NPCS)
{
this.builder = new StringBuilder();
this.add(SongToPlay);
this.add(CameraTileX.ToString());
this.builder.Append(" ");
this.builder.Append(CameraTileY.ToString());
StringBuilder npcData = new StringBuilder();
if (Farmer != null)
{
npcData.Append(Farmer.ToString());
}
if (NPCS != null)
{
foreach (var v in NPCS)
{
npcData.Append(" ");
npcData.Append(v.ToString());
}
}
this.add(npcData.ToString());
this.add("skippable");
}
///
/// Adds the data to a string builder to seperate out the data.
///
///
public virtual void add(string Data)
{
if (this.builder.Length > 0)
{
this.builder.Append(this.getSeperator());
}
this.builder.Append(Data);
}
///
/// The seperator character for events.
///
///
public string getSeperator()
{
return "/";
}
///
/// Returns the event data.
///
///
public override string ToString()
{
return this.builder.ToString();
}
}
}