Skip to content

Commit

Permalink
Merge pull request #3 from jonathan-robertson/a21
Browse files Browse the repository at this point in the history
Support A21
  • Loading branch information
jonathan-robertson committed Jun 13, 2023
2 parents 0c664f7 + f1f74b4 commit 2632c43
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 66 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- update trader restock on login
- update trader restock ui to days remaining

## [1.0.0] - 2023-06-13

- update buff reminder to match hud icon
- update readme
- update to a21 mod-info file format
- update to a21 references

## [0.1.0] - 2023-04-14

- add vend expiration buff
Expand Down
2 changes: 1 addition & 1 deletion Config/buffs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<config>
<append xpath="/buffs">
<buff name="buffDaysRemainingVendingExpiration" name_key="buffDaysRemainingVendingExpirationName" description_key="buffDaysRemainingVendingExpirationDesc" tooltip_key="buffDaysRemainingVendingExpirationTooltip" icon="ui_game_symbol_vending" icon_color="0,127,255">
<buff name="buffDaysRemainingVendingExpiration" name_key="buffDaysRemainingVendingExpirationName" description_key="buffDaysRemainingVendingExpirationDesc" tooltip_key="buffDaysRemainingVendingExpirationTooltip" icon="ui_game_symbol_vending" icon_color="255,255,0">
<duration value="30" />
<stack_type value="duration" />
<display_value_key value="buffDaysRemainingVendingExpirationFormat" />
Expand Down
Binary file modified DaysRemaining.dll
Binary file not shown.
13 changes: 6 additions & 7 deletions ModInfo.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<xml>
<ModInfo>
<Name value="Days Remaining" />
<Description value="Update trader restock date and vending expiration date to show days until vs date of." />
<Author value="Jonathan Robertson (Kanaverum)" />
<Version value="0.1.0" />
<Website value="https://github.com/jonathan-robertson/days-remaining" />
</ModInfo>
<Name value="kanaverum-days-remaining" />
<DisplayName value="Days Remaining" />
<Version value="1.0.0" />
<Description value="Update trader restock date and vending expiration date to show days until vs date of." />
<Author value="Jonathan Robertson (Kanaverum)" />
<Website value="https://github.com/jonathan-robertson/days-remaining" />
</xml>
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Days Remaining

[![🧪 Tested On](https://img.shields.io/badge/🧪%20Tested%20On-A20.6%20b9-blue.svg)](https://7daystodie.com/) [![📦 Automated Release](https://github.com/jonathan-robertson/days-remaining/actions/workflows/release.yml/badge.svg)](https://github.com/jonathan-robertson/days-remaining/actions/workflows/release.yml)
[![🧪 Tested On](https://img.shields.io/badge/🧪%20Tested%20On-A21%20b313-blue.svg)](https://7daystodie.com/) [![📦 Automated Release](https://github.com/jonathan-robertson/days-remaining/actions/workflows/release.yml/badge.svg)](https://github.com/jonathan-robertson/days-remaining/actions/workflows/release.yml)

- [Days Remaining](#days-remaining)
- [Summary](#summary)
Expand All @@ -26,5 +26,5 @@ This mod is designed to be used with another to complete your experience:
Environment | Compatible | Does EAC Need to be Disabled? | Who needs to install?
--- | --- | --- | ---
Dedicated Server | Yes | no | only server
Peer-to-Peer Hosting | Yes | only on the host | only the host
Single Player Game | Yes | Yes | self (of course)
Peer-to-Peer Hosting | Untested | N/A | N/A
Single Player Game | Untested | N/A | N/A
Binary file modified references/0Harmony.dll
Binary file not shown.
Binary file modified references/Assembly-CSharp.dll
Binary file not shown.
Binary file modified references/LogLibrary.dll
Binary file not shown.
Binary file modified references/System.Configuration.dll
Binary file not shown.
Binary file modified references/UnityEngine.CoreModule.dll
Binary file not shown.
Binary file modified references/UnityEngine.dll
Binary file not shown.
5 changes: 3 additions & 2 deletions src/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ namespace DaysRemaining
{
internal class Helpers
{
private const string CVAR_VENDING_EXPIRATION = "daysRemainingVendingExpiration";
private const string BUFF_VENDING_EXPIRATION = "buffDaysRemainingVendingExpiration";

private static readonly ModLog<Helpers> _log = new ModLog<Helpers>();
private static readonly string CVAR_VENDING_EXPIRATION = "daysRemainingVendingExpiration";
private static readonly string BUFF_VENDING_EXPIRATION = "buffDaysRemainingVendingExpiration";

public static bool TryGetTileEntityVendingMachine(Vector3i blockPos, out TileEntityVendingMachine tileEntityVendingMachine)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ModApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal class ModApi : IModApi
{
private static readonly ModLog<ModApi> _log = new ModLog<ModApi>();

public static bool DebugMode { get; set; } = true; // TODO: disable before release
public static bool DebugMode { get; set; } = false; // TODO: disable before release

public void InitMod(Mod _modInstance)
{
Expand Down
55 changes: 55 additions & 0 deletions src/Patches/GameManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using HarmonyLib;
using System;

namespace DaysRemaining.Patches
{
[HarmonyPatch(typeof(GameManager), "SetWorldTime")]
internal class GameManager_SetWorldTime_Patches
{
private static readonly ModLog<GameManager_SetWorldTime_Patches> _log = new ModLog<GameManager_SetWorldTime_Patches>();

public static void Postfix()
{
try
{
var players = GameManager.Instance.World.Players.list;
for (var i = 0; i < players.Count; i++)
{
if (Helpers.TryGetClientInfo(players[i].entityId, out var clientInfo))
{
Helpers.SetExpirationDaysRemaining(clientInfo, players[i]);
}
}
}
catch (Exception e)
{
_log.Error("Postfix", e);
}
}
}

[HarmonyPatch(typeof(GameManager), "updateTimeOfDay")]
internal class GameManager_updateTimeOfDay_Patches
{
private static readonly ModLog<GameManager_updateTimeOfDay_Patches> _log = new ModLog<GameManager_updateTimeOfDay_Patches>();

public static void Postfix()
{
try
{
var players = GameManager.Instance.World.Players.list;
for (var i = 0; i < players.Count; i++)
{
if (Helpers.TryGetClientInfo(players[i].entityId, out var clientInfo))
{
Helpers.SetExpirationDaysRemaining(clientInfo, players[i]);
}
}
}
catch (Exception e)
{
_log.Error("Postfix", e);
}
}
}
}
52 changes: 1 addition & 51 deletions src/Patches.cs → src/Patches/NetPackageTileEntity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HarmonyLib;
using System;

namespace DaysRemaining
namespace DaysRemaining.Patches
{
[HarmonyPatch(typeof(NetPackageTileEntity), "Setup", typeof(TileEntity), typeof(TileEntity.StreamModeWrite), typeof(byte))]
internal class NetPackageTileEntity_Setup_Patches
Expand Down Expand Up @@ -43,54 +43,4 @@ public static void Postfix(TileEntity _te, Vector3i ___teWorldPos)
}
}
}

[HarmonyPatch(typeof(GameManager), "SetWorldTime")]
internal class GameManager_SetWorldTime_Patches
{
private static readonly ModLog<GameManager_SetWorldTime_Patches> _log = new ModLog<GameManager_SetWorldTime_Patches>();

public static void Postfix()
{
try
{
var players = GameManager.Instance.World.Players.list;
for (var i = 0; i < players.Count; i++)
{
if (Helpers.TryGetClientInfo(players[i].entityId, out var clientInfo))
{
Helpers.SetExpirationDaysRemaining(clientInfo, players[i]);
}
}
}
catch (Exception e)
{
_log.Error("Postfix", e);
}
}
}

[HarmonyPatch(typeof(GameManager), "updateTimeOfDay")]
internal class GameManager_updateTimeOfDay_Patches
{
private static readonly ModLog<GameManager_updateTimeOfDay_Patches> _log = new ModLog<GameManager_updateTimeOfDay_Patches>();

public static void Postfix()
{
try
{
var players = GameManager.Instance.World.Players.list;
for (var i = 0; i < players.Count; i++)
{
if (Helpers.TryGetClientInfo(players[i].entityId, out var clientInfo))
{
Helpers.SetExpirationDaysRemaining(clientInfo, players[i]);
}
}
}
catch (Exception e)
{
_log.Error("Postfix", e);
}
}
}
}
3 changes: 2 additions & 1 deletion src/src.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
<ItemGroup>
<Compile Include="Helpers.cs" />
<Compile Include="ModLog.cs" />
<Compile Include="Patches.cs" />
<Compile Include="ModApi.cs" />
<Compile Include="Patches\GameManager.cs" />
<Compile Include="Patches\NetPackageTileEntity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down

0 comments on commit 2632c43

Please sign in to comment.