Skip to content

Commit

Permalink
Merge pull request #81 from Tess-y/main
Browse files Browse the repository at this point in the history
Fix for onceHooks
  • Loading branch information
pdcook authored Jun 18, 2022
2 parents b9027c2 + 20561ce commit ebacf25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
19 changes: 11 additions & 8 deletions UnboundLib/GameModes/GameModeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,38 +261,41 @@ public static void AddOnceHook(string key, Func<IGameModeHandler, IEnumerator> a

if (!onceHooks.ContainsKey(key))
{
onceHooks.Add(key, new List<GameModeHooks.Hook>{ new GameModeHooks.Hook(action, priority) });
onceHooks.Add(key, new List<GameModeHooks.Hook>{ AddHook(key, action, priority) });
}
else
{
onceHooks[key].Add(new GameModeHooks.Hook(action, priority));
onceHooks[key].Add(AddHook(key, action, priority));
}

AddHook(key, action);

}

public static void AddHook(string key, Func<IGameModeHandler, IEnumerator> action)
{
AddHook(key, action, GameModeHooks.Priority.Normal);
}
public static void AddHook(string key, Func<IGameModeHandler, IEnumerator> action, int priority)
}
public static GameModeHooks.Hook AddHook(string key, Func<IGameModeHandler, IEnumerator> action, int priority)
{
if (action == null)
{
return;
return null;
}

// Case-insensitive keys for QoL
key = key.ToLower();

GameModeHooks.Hook hook = new GameModeHooks.Hook(action, priority);

if (!hooks.ContainsKey(key))
{
hooks.Add(key, new List<GameModeHooks.Hook> { new GameModeHooks.Hook(action, priority) });
hooks.Add(key, new List<GameModeHooks.Hook> { hook });
}
else
{
hooks[key].Add(new GameModeHooks.Hook(action, priority));
hooks[key].Add(hook);
}
return hook;
}
public static void RemoveHook(string key, GameModeHooks.Hook hook)
{
Expand Down
2 changes: 1 addition & 1 deletion UnboundLib/Unbound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Unbound : BaseUnityPlugin
{
private const string ModId = "com.willis.rounds.unbound";
private const string ModName = "Rounds Unbound";
public const string Version = "3.1.2";
public const string Version = "3.1.3";

public static Unbound Instance { get; private set; }
public static readonly ConfigFile config = new ConfigFile(Path.Combine(Paths.ConfigPath, "UnboundLib.cfg"), true);
Expand Down
4 changes: 2 additions & 2 deletions UnboundLib/UnboundLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<DebugType>portable</DebugType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup>
<RoundsFolder>C:\Program Files (x86)\Steam\steamapps\common\ROUNDS</RoundsFolder>
<IndirectBuildTask>true</IndirectBuildTask>
Expand Down Expand Up @@ -134,7 +134,7 @@
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>

<Target Name="PostBuildTaskWin" Condition="'$(OS)' == 'Windows_NT'" DependsOnTargets="Build" AfterTargets="Build">
<CallTarget Targets="ReadPackageVersionFromOutputAssembly">
<Output TaskParameter="TargetOutputs" PropertyName="PackageVersion" />
Expand Down

0 comments on commit ebacf25

Please sign in to comment.