Skip to content

Commit

Permalink
Finalize 1.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dretax committed Jul 16, 2022
1 parent 2acc412 commit ebf4a06
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 4 deletions.
16 changes: 14 additions & 2 deletions Fougerite.Patcher/Fougerite.Patcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,20 @@
<Content Include="g3115-6.ico" />
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
<HintPath>PatcherReferences\Mono.Cecil.dll</HintPath>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net35\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net35\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net35\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net35\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions Fougerite.Patcher/Fougerite.Patcher/ILPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,24 @@ private void AirdropPatch()
iLProcessor.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg_0));
iLProcessor.Body.Instructions.Add(Instruction.Create(OpCodes.Callvirt, this.rustAssembly.MainModule.Import(method)));
iLProcessor.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));

MethodDefinition SupplyDropPlaneConstructor = null;
foreach (var x in SupplyDropPlane.GetConstructors())
{
if (x.IsConstructor && x.Parameters.Count == 1)
{
SupplyDropPlaneConstructor = x;
break;
}
}

Position = SupplyDropPlaneConstructor.Body.Instructions.Count - 1;

method = hooksClass.GetMethod("SupplyDropPlaneCreated");
iLProcessor = SupplyDropPlaneConstructor.Body.GetILProcessor();
iLProcessor.InsertBefore(SupplyDropPlaneConstructor.Body.Instructions[Position],
Instruction.Create(OpCodes.Callvirt, this.rustAssembly.MainModule.Import(method)));
iLProcessor.InsertBefore(SupplyDropPlaneConstructor.Body.Instructions[Position], Instruction.Create(OpCodes.Ldarg_0));
}

private void ClientConnectionPatch()
Expand Down
Binary file not shown.
18 changes: 18 additions & 0 deletions Fougerite/Fougerite/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,24 @@ public static void Airdrop2(SupplyDropZone srz)
}
}

public static void SupplyDropPlaneCreated(SupplyDropPlane plane)
{
using (new Stopper(nameof(Hooks), nameof(SupplyDropPlaneCreated)))
{
try
{
if (OnSupplyDropPlaneCreated != null)
{
OnSupplyDropPlaneCreated(plane);
}
}
catch (Exception ex)
{
Logger.LogError("SupplyDropPlaneCreated Error: " + ex);
}
}
}

public static void AirdropCrateDropped(SupplyDropPlane plane)
{
using (new Stopper(nameof(Hooks), nameof(AirdropCrateDropped)))
Expand Down
8 changes: 8 additions & 0 deletions Fougerite/Fougerite/Hooks_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public partial class Hooks
/// </summary>
public static event AirdropDelegate OnAirdropCalled;

/// <summary>
/// This delegate runs when a supplydropplane is created.
/// </summary>
public static event SupplyDropPlaneCreatedDelegate OnSupplyDropPlaneCreated;

/// <summary>
/// This delegate runs when the crate is created from the airdrop.
/// </summary>
Expand Down Expand Up @@ -371,6 +376,7 @@ public static void ResetHooks()
OnBeltUse = delegate { };
OnLogger = delegate { };
OnAirdropCrateDropped = delegate { };
OnSupplyDropPlaneCreated = delegate { };
}

public delegate void BlueprintUseHandlerDelegate(Player player, BPUseEvent ae);
Expand Down Expand Up @@ -486,5 +492,7 @@ public delegate void PlayerMoveDelegate(HumanController hc, Vector3 origin, int
public delegate void LoggerDelegate(LoggerEvent loggerEvent);

public delegate void AirdropCrateDroppedDelegate(SupplyDropPlane plane, Entity supplyCrate);

public delegate void SupplyDropPlaneCreatedDelegate(SupplyDropPlane plane);
}
}
5 changes: 5 additions & 0 deletions Fougerite/Fougerite/PluginLoaders/BasePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -964,5 +964,10 @@ public void OnGrenade(GrenadeThrowEvent ev)
{
this.Invoke("On_GrenadeThrow", ev);
}

public void OnSupplyDropPlaneCreated(SupplyDropPlane plane)
{
this.Invoke("On_SupplyDropPlaneCreated", plane);
}
}
}
9 changes: 8 additions & 1 deletion Fougerite/Fougerite/PluginLoaders/PluginLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public class PluginLoader : Singleton<PluginLoader>, ISingleton
"On_Logger",
"On_GrenadeThrow",
"On_ConsoleWithCancel",
"On_AirdropCrateDropped"
"On_AirdropCrateDropped",
"On_SupplyDropPlaneCreated"
};

public void Initialize()
Expand Down Expand Up @@ -332,6 +333,9 @@ public void InstallHooks(BasePlugin plugin)
case "On_GrenadeThrow":
Hooks.OnGrenadeThrow += plugin.OnGrenade;
break;
case "On_SupplyDropPlaneCreated":
Hooks.OnSupplyDropPlaneCreated += plugin.OnSupplyDropPlaneCreated;
break;
}
}
}
Expand Down Expand Up @@ -506,6 +510,9 @@ public void RemoveHooks(BasePlugin plugin)
case "On_GrenadeThrow":
Hooks.OnGrenadeThrow -= plugin.OnGrenade;
break;
case "On_SupplyDropPlaneCreated":
Hooks.OnSupplyDropPlaneCreated -= plugin.OnSupplyDropPlaneCreated;
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Fougerite/Fougerite/Stopper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void IDisposable.Dispose()
{
if (_stopper.ElapsedMilliseconds > _warnTimeMS)
{
Logger.LogWarning(string.Format("[{0}.{1}] Took: {2}s ({3}ms)",
Logger.LogWarning(string.Format("[Stopper.{0}.{1}] Took: {2}s ({3}ms)",
_type,
_method,
_stopper.Elapsed.Seconds,
Expand Down
Binary file modified Fougerite/References/PatchedRustDlls/Assembly-CSharp.dll
Binary file not shown.
Binary file modified Fougerite/References/PatchedRustDlls/Facepunch.MeshBatch.dll
Binary file not shown.
Binary file modified Fougerite/References/PatchedRustDlls/uLink.dll
Binary file not shown.

0 comments on commit ebf4a06

Please sign in to comment.