Skip to content

Commit

Permalink
EF 2.4.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Entoarox committed Jul 4, 2019
1 parent ed8092b commit 840552e
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 347 deletions.
19 changes: 15 additions & 4 deletions Framework/Core/EntoaroxFrameworkMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal class EntoaroxFrameworkMod : Mod
/*********
** Fields
*********/
private static bool SkipSerializer = false;
private static readonly List<string> Farms = new List<string> { "standard", "river", "forest", "hilltop", "wilderniss" };
private static string Verify;
internal static JsonSerializer Serializer;
Expand Down Expand Up @@ -123,6 +124,9 @@ internal class EntoaroxFrameworkMod : Mod
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
// Check if the serializer override should be skipped
if (typeof(SaveGame).GetField("contract") == null)
SkipSerializer = true;
Serializer = new JsonSerializer();
Serializer.Converters.Add(new RectangleConverter());
Serializer.Formatting = Formatting.None;
Expand Down Expand Up @@ -150,12 +154,20 @@ public override void Entry(IModHelper helper)
.Add("player_warp", "player_warp <location> <x> <y> | Warps the player to the given position in the game.", this.Commands);
}

helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;

helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saving += this.OnSaving;
helper.Events.GameLoop.Saved += this.OnSaved;
helper.Events.Input.ButtonReleased += this.OnButtonReleased;

if (SkipSerializer)
{
this.Monitor.Log("Detected incompatible SDV version for serializer function, function is disabled.", LogLevel.Warn);
return;
}
helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
helper.Events.GameLoop.UpdateTicked += this.EnforceSerializer;
}

/// <summary>Get an API that other mods can access. This is always called after <see cref="Entry" />.</summary>
Expand Down Expand Up @@ -465,7 +477,6 @@ private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
/// <param name="e">The event arguments.</param>
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
this.EnforceSerializer();
if (!Context.IsWorldReady)
return;
if (Game1.player.CurrentItem == null && this.PrevItem != null || Game1.player.CurrentItem != null && !Game1.player.CurrentItem.Equals(this.PrevItem))
Expand Down Expand Up @@ -857,10 +868,10 @@ private void SetupSerializer()
this.FarmerSerializer = new XmlSerializer(typeof(Farmer), EntoaroxFrameworkMod.FarmerTypes.Concat(EntoaroxFrameworkMod.SerializerTypes).ToArray());
this.LocationSerializer = new XmlSerializer(typeof(GameLocation), EntoaroxFrameworkMod.LocationTypes.Concat(EntoaroxFrameworkMod.SerializerTypes).ToArray());
EntoaroxFrameworkMod.SerializerInjected = true;
this.EnforceSerializer();
this.EnforceSerializer(null, null);
}

private void EnforceSerializer()
private void EnforceSerializer(object sender, UpdateTickedEventArgs e)
{
SaveGame.serializer = this.MainSerializer;
SaveGame.farmerSerializer = this.FarmerSerializer;
Expand Down
2 changes: 2 additions & 0 deletions Framework/IContentHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public static class IContentHelperExtensions
/// <summary>Allows you to add a new type to the serializer, provided the serializer has not yet been initialized.</summary>
/// <typeparam name="T">The Type to add</typeparam>
/// <param name="helper">The <see cref="IContentHelper" /> this extension method is attached to</param>
[Obsolete("Deprecated, use save events to add/remove custom content instead.")]
public static void RegisterSerializerType<T>(this IContentHelper helper)
{
EntoaroxFrameworkMod.Logger.Log($"[IContentHelper] The `{Globals.GetModName(helper)}` mod uses deprecated serializer injection, this will be removed in a future update.", LogLevel.Alert);
if (EntoaroxFrameworkMod.SerializerInjected)
EntoaroxFrameworkMod.Logger.Log($"[IContentHelper] The `{Globals.GetModName(helper)}` mod failed to augment the serializer, serializer has already been created.", LogLevel.Error);
else if (!EntoaroxFrameworkMod.SerializerTypes.Contains(typeof(T)))
Expand Down
7 changes: 5 additions & 2 deletions Framework/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## Release notes
## 2.4.3
Not yet released
Released 04 July 2019
* Updated for the upcoming SMAPI 3.0 again.
* Detect when a SDV version uses a different serializer mechanic and disable the custom serializer on those versions (Android & similar)
* Deprecated the ability to add types to the save serializer
* Added new `world_reset` command with `bushes` and `characters` options, enables reloading relevant data from disk when triggered in a active save.
* Restored some lost ICustomItem supported types (`TerrainFeature` & `GameLocation`), due to technical limits ``Building` support is not yet back.
* Restored some lost ICustomItem supported types (`TerrainFeature` & `GameLocation`), due to technical limits `Building` support is not yet back.

## 2.4.2
Released 28 December 2018. (Thanks to Pathoschild!)
Expand Down
2 changes: 1 addition & 1 deletion Framework/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Entoarox Framework",
"Author": "Entoarox",
"Version": "2.4.3-beta.1",
"Version": "2.4.3",
"Description": "A collection of APIs to make modding easier.",
"UniqueID": "Entoarox.EntoaroxFramework",
"EntryDll": "EntoaroxFramework.dll",
Expand Down
43 changes: 38 additions & 5 deletions SundropCity/SundropCityMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using SundropCity.TerrainFeatures;

using xTile;
using xTile.Dimensions;
using xTile.ObjectModel;
using xTile.Layers;
using xTile.Tiles;

Expand Down Expand Up @@ -48,6 +50,7 @@ public override void Entry(IModHelper helper)
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.Saved += this.OnSaved;
helper.Events.GameLoop.Saving += this.OnSaving;
helper.Events.Input.ButtonReleased += this.OnButtonReleased;

// Handle ALL not providing extra layer drawing
if (!helper.ModRegistry.IsLoaded("Entoarox.AdvancedLocationLoader") || helper.ModRegistry.Get("Entoarox.AdvancedLocationLoader").Manifest.Version.IsOlderThan("1.5.0"))
Expand Down Expand Up @@ -170,11 +173,6 @@ private void Setup()
toLayer.Tiles[x, y] = new StaticTile(toLayer, town.map.GetTileSheet(tile.TileSheet.Id), BlendMode.Additive, tile.TileIndex);
}
}
// Setup warps to sundrop [TEMP: Will become warps to SundropBusStop map in the future]
town.warps.Add(new Warp(120, 55, "SundropPromenade", 1, 29, false));
town.warps.Add(new Warp(120, 56, "SundropPromenade", 1, 30, false));
town.warps.Add(new Warp(120, 57, "SundropPromenade", 1, 31, false));
town.warps.Add(new Warp(120, 58, "SundropPromenade", 1, 32, false));
// Add new locations
foreach (string map in this.Maps)
{
Expand All @@ -191,6 +189,16 @@ private void Setup()
}
}
var promenade = Game1.getLocationFromName("SundropPromenade");
if(promenade==null)
{
this.Monitor.Log("Promenade failed to load, cancelling further setup as a result.", LogLevel.Error);
return;
}
// Setup warps to sundrop [TEMP: Will become warps to SundropBusStop map in the future]
town.warps.Add(new Warp(120, 55, "SundropPromenade", 1, 29, false));
town.warps.Add(new Warp(120, 56, "SundropPromenade", 1, 30, false));
town.warps.Add(new Warp(120, 57, "SundropPromenade", 1, 31, false));
town.warps.Add(new Warp(120, 58, "SundropPromenade", 1, 32, false));
// Add warp back to Pelican [TEMP: Will be removed once proper travel is implemented]
promenade.setTileProperty(3, 37, "Buildings", "Action", "Warp 119 56 Town");
// Temp NPC spawns
Expand Down Expand Up @@ -271,6 +279,31 @@ private void SpawnCars(GameLocation location, double chance)
}


private void OnButtonReleased(object sender, ButtonReleasedEventArgs e)
{
if (e.Button.IsActionButton() && Game1.activeClickableMenu == null && !Game1.player.UsingTool && !Game1.pickingTool && !Game1.menuUp && (!Game1.eventUp || Game1.currentLocation.currentEvent.playerControlSequence) && !Game1.nameSelectUp && Game1.numberOfSelectedItems == -1 && !Game1.fadeToBlack)
{
Vector2 grabTile = new Vector2(Game1.getOldMouseX() + Game1.viewport.X, Game1.getOldMouseY() + Game1.viewport.Y) / Game1.tileSize;
if (!Utility.tileWithinRadiusOfPlayer((int)grabTile.X, (int)grabTile.Y, 1, Game1.player))
grabTile = Game1.player.GetGrabTile();
Tile tile = Game1.currentLocation.map.GetLayer("Buildings").PickTile(new Location((int)grabTile.X * Game1.tileSize, (int)grabTile.Y * Game1.tileSize), Game1.viewport.Size);
PropertyValue propertyValue = null;
tile?.Properties.TryGetValue("Action", out propertyValue);
if (propertyValue != null)
{
string[] split = ((string)propertyValue).Split(' ');
string[] args = new string[split.Length - 1];
Array.Copy(split, 1, args, 0, args.Length);
switch(split[0])
{
case "SundropMessage":

break;
}
}
}
}

private void OnSaveLoaded(object s, EventArgs e)
{
this.Setup();
Expand Down
3 changes: 0 additions & 3 deletions SundropCity/assets/Hotel/Data/GenericFurnitureTypes.json

This file was deleted.

Loading

0 comments on commit 840552e

Please sign in to comment.