Added in more functionallity for junimos and moving actors in an event.

This commit is contained in:
JoshuaNavarro 2019-12-06 12:09:31 -08:00
parent 2609f3339a
commit 373773906d
7 changed files with 148 additions and 9 deletions

View File

@ -8,6 +8,7 @@ using StardustCore.Events;
using StardustCore.Events.Preconditions; using StardustCore.Events.Preconditions;
using StardustCore.Events.Preconditions.TimeSpecific; using StardustCore.Events.Preconditions.TimeSpecific;
using StardewValley; using StardewValley;
using Microsoft.Xna.Framework;
namespace Omegasis.HappyBirthday.Framework namespace Omegasis.HappyBirthday.Framework
{ {
@ -22,14 +23,20 @@ namespace Omegasis.HappyBirthday.Framework
conditions.Add(new LocationPrecondition(Game1.getLocationFromName("CommunityCenter"))); conditions.Add(new LocationPrecondition(Game1.getLocationFromName("CommunityCenter")));
conditions.Add(new TimePrecondition(600, 2600)); conditions.Add(new TimePrecondition(600, 2600));
EventHelper e = new EventHelper("CommunityCenterBirthday",19950, conditions, new EventStartData(EventStartData.MusicToPlayType.Continue, 32, 16, new EventStartData.FarmerData(32, 22, EventHelper.FacingDirection.Up),new List<EventStartData.NPCData>())); EventHelper e = new EventHelper("CommunityCenterBirthday",19950, conditions, new EventStartData(EventStartData.MusicToPlayType.Continue, 32, 16, new EventStartData.FarmerData(32, 22, EventHelper.FacingDirection.Up),new List<EventStartData.NPCData>()));
e.AddInJunimoActor("Juni", new Microsoft.Xna.Framework.Vector2(32, 14), Color.Blue);
e.globalFadeIn(); e.globalFadeIn();
e.moveFarmerUp(6, EventHelper.FacingDirection.Up, false); e.moveFarmerUp(6, EventHelper.FacingDirection.Up, false);
e.ViewportLerpTileOffset(new Microsoft.Xna.Framework.Point(0,-6),60*6,true); e.ViewportLerpTileOffset(new Microsoft.Xna.Framework.Point(0,-6),60*6,true);
e.moveActorLeft("Juni", 1, EventHelper.FacingDirection.Down, false);
//e.addObjectToPlayersInventory(64, 22,true); //e.addObjectToPlayersInventory(64, 22,true);
e.addTemporaryActor_NPC("Junimo", 16, 16, 32, 14, EventHelper.FacingDirection.Down, false); //e.addTemporaryActor_NPC("Junimo", 16, 16, 32, 14, EventHelper.FacingDirection.Down, false);
e.actorJump("Junimo");
e.showMessage("Community center birthday here."); e.showMessage("Community center birthday here.");
//Notes //Notes
//Add a temporary actor (or sprite) to the screen. //Add a temporary actor (or sprite) to the screen.
//Use the attachCharacterToTempSprite command to stitch them together? //Use the attachCharacterToTempSprite command to stitch them together?
@ -39,11 +46,7 @@ namespace Omegasis.HappyBirthday.Framework
* *
* else if (strArray[index].Equals("Junimo")) * else if (strArray[index].Equals("Junimo"))
{ {
List<NPC> actors = this.actors;
Junimo junimo = new Junimo(new Vector2((float)(Convert.ToInt32(strArray[index + 1]) * 64), (float)(Convert.ToInt32(strArray[index + 2]) * 64 - 32)), Game1.currentLocation.Name.Equals("AbandonedJojaMart") ? 6 : -1, false);
junimo.Name = "Junimo";
junimo.EventActor = true;
actors.Add((NPC)junimo);
} }
*/ */

View File

@ -1202,6 +1202,50 @@ namespace StardustCore.Events
this.add(b); this.add(b);
} }
/// <summary>
/// Move the given actor a certain amount of tiles.
/// </summary>
/// <param name="Actor"></param>
/// <param name="xOffset"></param>
/// <param name="yOffset"></param>
/// <param name="Dir"></param>
/// <param name="Continue"></param>
public virtual void moveActor(string Actor, int xOffset, int yOffset, FacingDirection Dir, bool Continue)
{
StringBuilder b = new StringBuilder();
b.Append("move ");
b.Append(Actor);
b.Append(" ");
b.Append(xOffset);
b.Append(" ");
b.Append(yOffset);
b.Append(" ");
b.Append(this.getFacingDirectionNumber(Dir));
b.Append(" ");
b.Append(Continue);
this.add(b);
}
public virtual void moveActorUp(string Actor, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause)
{
this.moveActor(Actor, 0, -TileAmount, FinishingFacingDirection, EventDoesntPause);
}
public virtual void moveActorDown(string Actor, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause)
{
this.moveActor(Actor, 0, TileAmount, FinishingFacingDirection, EventDoesntPause);
}
public virtual void moveActorLeft(string Actor, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause)
{
this.moveActor(Actor, -TileAmount, 0, FinishingFacingDirection, EventDoesntPause);
}
public virtual void moveActorRight(string Actor, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause)
{
this.moveActor(Actor, TileAmount, 0, FinishingFacingDirection, EventDoesntPause);
}
/// <summary> /// <summary>
/// Make a named NPC move by the given tile offset from their current position (along one axis only), and face the given direction when they're done. To move along multiple axes, you must specify multiple move commands. By default the event pauses while a move command is occurring, but if <continue> is set to true the movement is asynchronous and will run simultaneously with other event commands. /// Make a named NPC move by the given tile offset from their current position (along one axis only), and face the given direction when they're done. To move along multiple axes, you must specify multiple move commands. By default the event pauses while a move command is occurring, but if <continue> is set to true the movement is asynchronous and will run simultaneously with other event commands.
/// </summary> /// </summary>
@ -1238,12 +1282,12 @@ namespace StardustCore.Events
public virtual void moveNPCLeft(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) public virtual void moveNPCLeft(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause)
{ {
this.moveNPC(npc, TileAmount,0,FinishingFacingDirection, EventDoesntPause); this.moveNPC(npc, -TileAmount,0,FinishingFacingDirection, EventDoesntPause);
} }
public virtual void moveNPCRight(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause) public virtual void moveNPCRight(NPC npc, int TileAmount, FacingDirection FinishingFacingDirection, bool EventDoesntPause)
{ {
this.moveNPC(npc,-TileAmount,0,FinishingFacingDirection, EventDoesntPause); this.moveNPC(npc,TileAmount,0,FinishingFacingDirection, EventDoesntPause);
} }
public virtual void moveFarmer(int xOffset, int yOffset, FacingDirection Dir, bool Continue) public virtual void moveFarmer(int xOffset, int yOffset, FacingDirection Dir, bool Continue)

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using StardewValley; using StardewValley;
using StardewValley.Characters;
namespace StardustCore.Events namespace StardustCore.Events
{ {
@ -73,6 +74,32 @@ namespace StardustCore.Events
} }
/// <summary>
/// Creates the code to add in a junimo actor at the given location.
/// </summary>
/// <param name="EventHelper"></param>
/// <param name="ActorName"></param>
/// <param name="Position"></param>
/// <param name="Color"></param>
public static void AddInJunimoActor(this EventHelper EventHelper,string ActorName,Vector2 Position,Color Color)
{
StringBuilder b = new StringBuilder();
b.Append("Omegasis.EventFramework.AddInJunimoActor ");
b.Append(ActorName);
b.Append(" ");
b.Append(Position.X);
b.Append(" ");
b.Append(Position.Y);
b.Append(" ");
b.Append(Color.R);
b.Append(" ");
b.Append(Color.G);
b.Append(" ");
b.Append(Color.B);
EventHelper.add(b);
}
} }
} }

View File

@ -32,6 +32,7 @@ namespace StardustCore.Events
this.customEventLogic.Add("Omegasis.EventFramework.AddObjectToPlayersInventory", ExtraEventActions.addObjectToPlayerInventory); this.customEventLogic.Add("Omegasis.EventFramework.AddObjectToPlayersInventory", ExtraEventActions.addObjectToPlayerInventory);
this.customEventLogic.Add("Omegasis.EventFramework.ViewportLerp", ExtraEventActions.ViewportLerp); this.customEventLogic.Add("Omegasis.EventFramework.ViewportLerp", ExtraEventActions.ViewportLerp);
this.customEventLogic.Add("Omegasis.EventFramework.AddInJunimoActor", ExtraEventActions.AddInJumimoActorForEvent);
} }
/// <summary> /// <summary>

View File

@ -4,7 +4,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Netcode;
using StardewModdingAPI;
using StardewValley; using StardewValley;
using StardewValley.Characters;
namespace StardustCore.Events namespace StardustCore.Events
{ {
@ -83,5 +86,36 @@ namespace StardustCore.Events
Vector2 currentLerp = Vector2.Lerp(new Vector2(OldViewportPosition.X, OldViewportPosition.Y), new Vector2(OldViewportPosition.X + xEndPosition, OldViewportPosition.Y + yEndPosition), (float)((float)CurrentViewportLerpAmount/(float)frames)); Vector2 currentLerp = Vector2.Lerp(new Vector2(OldViewportPosition.X, OldViewportPosition.Y), new Vector2(OldViewportPosition.X + xEndPosition, OldViewportPosition.Y + yEndPosition), (float)((float)CurrentViewportLerpAmount/(float)frames));
Game1.viewport.Location = new xTile.Dimensions.Location((int)currentLerp.X, (int)currentLerp.Y); Game1.viewport.Location = new xTile.Dimensions.Location((int)currentLerp.X, (int)currentLerp.Y);
} }
/// <summary>
/// Adds in a junimo actor at the current location. Allows for multiple.
/// </summary>
/// <param name="EventManager"></param>
/// <param name="EventData"></param>
public static void AddInJumimoActorForEvent(EventManager EventManager, string EventData)
{
string[] splits = EventData.Split(' ');
string name = splits[0];
string actorName = splits[1];
int xPos = Convert.ToInt32(splits[2]);
int yPos = Convert.ToInt32(splits[3]);
Color color = new Color(Convert.ToInt32(splits[4]), Convert.ToInt32(splits[5]), Convert.ToInt32(splits[6]));
List<NPC> actors = Game1.CurrentEvent.actors;
Junimo junimo = new Junimo(new Vector2(xPos * 64, yPos * 64), -1, false);
junimo.Name = actorName;
junimo.EventActor = true;
IReflectedField<NetColor> colorF=StardustCore.ModCore.ModHelper.Reflection.GetField<NetColor>(junimo, "color", true);
NetColor c = colorF.GetValue();
c.R = color.R;
c.G = color.G;
c.B = color.B;
colorF.SetValue(c);
actors.Add((NPC)junimo);
++Game1.CurrentEvent.CurrentCommand; //I've been told ++<int> is more efficient than <int>++;
}
} }
} }

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
namespace StardustCore.Events.Preconditions.PlayerSpecific
{
public class CanReadJunimo:EventPrecondition
{
public CanReadJunimo()
{
}
public override string ToString()
{
return "StardewVally.Player.CanReadJunimo";
}
public override bool meetsCondition()
{
return Game1.player.mailReceived.Contains("canReadJunimoText");
}
}
}

View File

@ -104,6 +104,7 @@
<Compile Include="Events\Preconditions\NPCSpecific\NotMarriedTo.cs" /> <Compile Include="Events\Preconditions\NPCSpecific\NotMarriedTo.cs" />
<Compile Include="Events\Preconditions\NPCSpecific\NPCInThisLocation.cs" /> <Compile Include="Events\Preconditions\NPCSpecific\NPCInThisLocation.cs" />
<Compile Include="Events\Preconditions\PlayerSpecific\AnsweredDialogueOptions.cs" /> <Compile Include="Events\Preconditions\PlayerSpecific\AnsweredDialogueOptions.cs" />
<Compile Include="Events\Preconditions\PlayerSpecific\CanReadJunimo.cs" />
<Compile Include="Events\Preconditions\PlayerSpecific\CommunityCenterCompleted.cs" /> <Compile Include="Events\Preconditions\PlayerSpecific\CommunityCenterCompleted.cs" />
<Compile Include="Events\Preconditions\PlayerSpecific\CurrentMoney.cs" /> <Compile Include="Events\Preconditions\PlayerSpecific\CurrentMoney.cs" />
<Compile Include="Events\Preconditions\PlayerSpecific\DaysPlayedFor.cs" /> <Compile Include="Events\Preconditions\PlayerSpecific\DaysPlayedFor.cs" />