Skip to content

Commit

Permalink
Various fixes (#402)
Browse files Browse the repository at this point in the history
* Update game lib reference

* LanguageAPI: ignore case in language name

* DamageAPI: Adding support for ChainGunOrb #395

* Logging: fix header centering #388

* DotAPI: update xml doc

* Readme update
  • Loading branch information
KingEnderBrine authored Jun 5, 2022
1 parent 62b272e commit ca4eeb5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
22 changes: 22 additions & 0 deletions R2API/DamageAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ internal static void SetHooks() {
IL.RoR2.Orbs.DamageOrb.OnArrival += DamageOrbOnArrivalIL;
IL.RoR2.Orbs.GenericDamageOrb.OnArrival += GenericDamageOrbOnArrivalIL;
IL.RoR2.Orbs.LightningOrb.OnArrival += LightningOrbOnArrivalIL;
IL.RoR2.Orbs.ChainGunOrb.OnArrival += ChainGunOrbOnArrivalIL;

IL.RoR2.Projectile.DeathProjectile.FixedUpdate += DeathProjectileFixedUpdateIL;
IL.RoR2.Projectile.ProjectileDotZone.ResetOverlap += ProjectileDotZoneResetOverlapIL;
Expand Down Expand Up @@ -99,6 +100,7 @@ internal static void UnsetHooks() {
IL.RoR2.Orbs.DamageOrb.OnArrival -= DamageOrbOnArrivalIL;
IL.RoR2.Orbs.GenericDamageOrb.OnArrival -= GenericDamageOrbOnArrivalIL;
IL.RoR2.Orbs.LightningOrb.OnArrival -= LightningOrbOnArrivalIL;
IL.RoR2.Orbs.ChainGunOrb.OnArrival -= ChainGunOrbOnArrivalIL;

IL.RoR2.Projectile.DeathProjectile.FixedUpdate -= DeathProjectileFixedUpdateIL;
IL.RoR2.Projectile.ProjectileDotZone.ResetOverlap -= ProjectileDotZoneResetOverlapIL;
Expand Down Expand Up @@ -222,6 +224,26 @@ private static void DamageOrbOnArrivalIL(ILContext il) {

EmitCopyCall(c);
}

private static void ChainGunOrbOnArrivalIL(ILContext il) {
var c = new ILCursor(il);
var damageInfoIndex = GotoDamageInfo(c);

c.Emit(OpCodes.Ldarg_0);
c.Emit(OpCodes.Ldloc, damageInfoIndex);

EmitCopyCall(c);

var chainGunOrbIndex = -1;
c.GotoNext(
x => x.MatchNewobj<ChainGunOrb>(),
x => x.MatchStloc(out chainGunOrbIndex));

c.Emit(OpCodes.Ldarg_0);
c.Emit(OpCodes.Ldloc, chainGunOrbIndex);

EmitCopyCall(c);
}
#endregion

#region Projectiles
Expand Down
2 changes: 1 addition & 1 deletion R2API/DotAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static void ResizeDotDefs(int newSize) {
private static readonly Dictionary<DotController, bool[]> ActiveCustomDots = new Dictionary<DotController, bool[]>();

/// <summary>
/// Allows for custom behaviours when applying the dot. EG, percentburn. <see cref="DotController.AddDot(GameObject, float, DotController.DotIndex, float, uint?, float?)"/>
/// Allows for custom behaviours when applying the dot. EG, percentburn. <see cref="DotController.AddDot(GameObject, float, DotController.DotIndex, float, uint?, float?, DotController.DotIndex?)"/>
/// </summary>
/// <param name="self"></param>
/// <param name="dotStack"></param>
Expand Down
4 changes: 2 additions & 2 deletions R2API/LanguageAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ private static void ThrowIfNotLoaded() {
}
}

private static readonly Dictionary<string, Dictionary<string, string>> CustomLanguage = new Dictionary<string, Dictionary<string, string>>();
private static readonly Dictionary<string, Dictionary<string, string>> OverlayLanguage = new Dictionary<string, Dictionary<string, string>>();
private static readonly Dictionary<string, Dictionary<string, string>> CustomLanguage = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, Dictionary<string, string>> OverlayLanguage = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
private static readonly List<LanguageOverlay> temporaryOverlays = new List<LanguageOverlay>();
private const string genericLanguage = "generic";

Expand Down
2 changes: 1 addition & 1 deletion R2API/R2API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class R2API : BaseUnityPlugin {
public const string PluginName = "R2API";
public const string PluginVersion = "0.0.1";

private const string GameBuildId = "1.2.3.1";
private const string GameBuildId = "1.2.4.1";

internal static new ManualLogSource Logger { get; set; }
public static bool DebugMode { get; private set; } = false;
Expand Down
4 changes: 2 additions & 2 deletions R2API/R2API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bbepis-BepInExPack" Version="5.4.1905" GeneratePathProperty="true" PrivateAssets="all" ExcludeAssets="all" IncludeAssets="none" />
<PackageReference Include="BepInEx.Analyzers" Version="1.0.8" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="BepInEx.Core" Version="5.4.19" />
<PackageReference Include="Microsoft.Unity.Analyzers" Version="1.13.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="MMHOOK.RoR2" Version="2022.4.19" NoWarn="NU1701" />
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="RiskOfRain2.GameLibs" Version="1.2.3.1-r.0" NoWarn="NU5104" />
<PackageReference Include="RiskOfRain2.GameLibs" Version="1.2.4-r.0" NoWarn="NU5104" />
<PackageReference Include="UnityEngine.Modules" Version="2019.4.26" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion R2API/Utils/ManualLogSourceExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void LogBlock(this ManualLogSource? logger, LogLevel level, string

logger.Log(level, barrier);
logger.Log(level, empty);
logger.Log(level, CenterText($"!{header}!"));
logger.Log(level, CenterText($"!{header}!", width));

lines.ToList().ForEach(x => logger.Log(level, CenterText(x, width)));

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ A lot of documentation is in the included *xmldocs*, and further information may
The most recent changelog can always be found on the [GitHub](https://github.com/risk-of-thunder/R2API/blob/master/Archived%20changelogs.md). In this readme, only the most recent *minor* version will have a changelog.

**Current**
* [Fix LanguageAPI being case dependent, add support for ChainGunOrb in DamageAPI by @KingEnderBrine](https://github.com/risk-of-thunder/R2API/pull/402)
* [UnlockableAPI: Fix custom achievements not working for current patch by @xiaoxiao921](https://github.com/risk-of-thunder/R2API/pull/391)
* [UnlockableAPI: Marked as Obsolete by @Nebby1999](https://github.com/risk-of-thunder/R2API/pull/390)
* [DirectorAPI: Add AddNewMonsterToStagesWhere & AddSelectedNewMonsters, and publicize base AddNewMonster by @bb010g](https://github.com/risk-of-thunder/R2API/pull/382)
Expand Down

0 comments on commit ca4eeb5

Please sign in to comment.