From 373773906dde1c734588e44deff13dd2643cba49 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Fri, 6 Dec 2019 12:09:31 -0800 Subject: [PATCH] Added in more functionallity for junimos and moving actors in an event. --- .../HappyBirthday/Framework/BirthdayEvents.cs | 17 ++++--- .../StardustCore/Events/EventHelper.cs | 48 ++++++++++++++++++- .../Events/EventHelperExtensions.cs | 27 +++++++++++ .../StardustCore/Events/EventManager.cs | 1 + .../StardustCore/Events/ExtraEventActions.cs | 34 +++++++++++++ .../PlayerSpecific/CanReadJunimo.cs | 29 +++++++++++ GeneralMods/StardustCore/StardustCore.csproj | 1 + 7 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 GeneralMods/StardustCore/Events/Preconditions/PlayerSpecific/CanReadJunimo.cs diff --git a/GeneralMods/HappyBirthday/Framework/BirthdayEvents.cs b/GeneralMods/HappyBirthday/Framework/BirthdayEvents.cs index cc0219bd..205d7544 100644 --- a/GeneralMods/HappyBirthday/Framework/BirthdayEvents.cs +++ b/GeneralMods/HappyBirthday/Framework/BirthdayEvents.cs @@ -8,6 +8,7 @@ using StardustCore.Events; using StardustCore.Events.Preconditions; using StardustCore.Events.Preconditions.TimeSpecific; using StardewValley; +using Microsoft.Xna.Framework; namespace Omegasis.HappyBirthday.Framework { @@ -22,14 +23,20 @@ namespace Omegasis.HappyBirthday.Framework conditions.Add(new LocationPrecondition(Game1.getLocationFromName("CommunityCenter"))); 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())); + + e.AddInJunimoActor("Juni", new Microsoft.Xna.Framework.Vector2(32, 14), Color.Blue); + e.globalFadeIn(); e.moveFarmerUp(6, EventHelper.FacingDirection.Up, false); 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.addTemporaryActor_NPC("Junimo", 16, 16, 32, 14, EventHelper.FacingDirection.Down, false); - e.actorJump("Junimo"); + //e.addTemporaryActor_NPC("Junimo", 16, 16, 32, 14, EventHelper.FacingDirection.Down, false); + e.showMessage("Community center birthday here."); + //Notes //Add a temporary actor (or sprite) to the screen. //Use the attachCharacterToTempSprite command to stitch them together? @@ -39,11 +46,7 @@ namespace Omegasis.HappyBirthday.Framework * * else if (strArray[index].Equals("Junimo")) { - List 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); + } */ diff --git a/GeneralMods/StardustCore/Events/EventHelper.cs b/GeneralMods/StardustCore/Events/EventHelper.cs index 1762d584..86f89d9b 100644 --- a/GeneralMods/StardustCore/Events/EventHelper.cs +++ b/GeneralMods/StardustCore/Events/EventHelper.cs @@ -1202,6 +1202,50 @@ namespace StardustCore.Events this.add(b); } + /// + /// Move the given actor a certain amount of tiles. + /// + /// + /// + /// + /// + /// + 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); + } + /// /// 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 is set to true the movement is asynchronous and will run simultaneously with other event commands. /// @@ -1238,12 +1282,12 @@ namespace StardustCore.Events 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) { - 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) diff --git a/GeneralMods/StardustCore/Events/EventHelperExtensions.cs b/GeneralMods/StardustCore/Events/EventHelperExtensions.cs index a242f3e1..7a48ecd8 100644 --- a/GeneralMods/StardustCore/Events/EventHelperExtensions.cs +++ b/GeneralMods/StardustCore/Events/EventHelperExtensions.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using StardewValley; +using StardewValley.Characters; namespace StardustCore.Events { @@ -73,6 +74,32 @@ namespace StardustCore.Events } + /// + /// Creates the code to add in a junimo actor at the given location. + /// + /// + /// + /// + /// + 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); + } + } } diff --git a/GeneralMods/StardustCore/Events/EventManager.cs b/GeneralMods/StardustCore/Events/EventManager.cs index 0566850a..b95759d6 100644 --- a/GeneralMods/StardustCore/Events/EventManager.cs +++ b/GeneralMods/StardustCore/Events/EventManager.cs @@ -32,6 +32,7 @@ namespace StardustCore.Events this.customEventLogic.Add("Omegasis.EventFramework.AddObjectToPlayersInventory", ExtraEventActions.addObjectToPlayerInventory); this.customEventLogic.Add("Omegasis.EventFramework.ViewportLerp", ExtraEventActions.ViewportLerp); + this.customEventLogic.Add("Omegasis.EventFramework.AddInJunimoActor", ExtraEventActions.AddInJumimoActorForEvent); } /// diff --git a/GeneralMods/StardustCore/Events/ExtraEventActions.cs b/GeneralMods/StardustCore/Events/ExtraEventActions.cs index f2a59908..ab382ba3 100644 --- a/GeneralMods/StardustCore/Events/ExtraEventActions.cs +++ b/GeneralMods/StardustCore/Events/ExtraEventActions.cs @@ -4,7 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Netcode; +using StardewModdingAPI; using StardewValley; +using StardewValley.Characters; 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)); Game1.viewport.Location = new xTile.Dimensions.Location((int)currentLerp.X, (int)currentLerp.Y); } + + /// + /// Adds in a junimo actor at the current location. Allows for multiple. + /// + /// + /// + 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 actors = Game1.CurrentEvent.actors; + Junimo junimo = new Junimo(new Vector2(xPos * 64, yPos * 64), -1, false); + junimo.Name = actorName; + junimo.EventActor = true; + + IReflectedField colorF=StardustCore.ModCore.ModHelper.Reflection.GetField(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 ++ is more efficient than ++; + } } } diff --git a/GeneralMods/StardustCore/Events/Preconditions/PlayerSpecific/CanReadJunimo.cs b/GeneralMods/StardustCore/Events/Preconditions/PlayerSpecific/CanReadJunimo.cs new file mode 100644 index 00000000..e18f039a --- /dev/null +++ b/GeneralMods/StardustCore/Events/Preconditions/PlayerSpecific/CanReadJunimo.cs @@ -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"); + } + + + } +} diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 6175872e..1a7541f3 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -104,6 +104,7 @@ +