From 5ae867aaef1b03d7e5824584ba0c72132e92d265 Mon Sep 17 00:00:00 2001 From: dymanoid <9433345+dymanoid@users.noreply.github.com> Date: Sun, 22 Mar 2020 23:59:44 +0100 Subject: [PATCH] Prevent fishing boots from spawning at night --- src/RealTime/Core/RealTimeCore.cs | 3 ++- .../GameConnection/Patches/BuildingAIPatch.cs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/RealTime/Core/RealTimeCore.cs b/src/RealTime/Core/RealTimeCore.cs index 5812302..8f38e2c 100644 --- a/src/RealTime/Core/RealTimeCore.cs +++ b/src/RealTime/Core/RealTimeCore.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) dymanoid. All rights reserved. // @@ -309,6 +309,7 @@ namespace RealTime.Core BuildingAIPatch.GetColor, BuildingAIPatch.CalculateUnspawnPosition, BuildingAIPatch.ProduceGoods, + BuildingAIPatch.TrySpawnBoot, ResidentAIPatch.Location, ResidentAIPatch.ArriveAtTarget, ResidentAIPatch.StartMoving, diff --git a/src/RealTime/GameConnection/Patches/BuildingAIPatch.cs b/src/RealTime/GameConnection/Patches/BuildingAIPatch.cs index 6b80fd3..8e445b8 100644 --- a/src/RealTime/GameConnection/Patches/BuildingAIPatch.cs +++ b/src/RealTime/GameConnection/Patches/BuildingAIPatch.cs @@ -47,6 +47,9 @@ namespace RealTime.GameConnection.Patches /// Gets the patch for the building AI method 'ProduceGoods'. public static IPatch ProduceGoods { get; } = new PlayerBuildingAI_ProduceGoods(); + /// Gets the patch for the fishing harbor AI method 'TrySpawnBoot'. + public static IPatch TrySpawnBoot { get; } = new FishingHarborAI_TrySpawnBoat(); + private sealed class CommercialBuildingA_SimulationStepActive : PatchBase { protected override MethodInfo GetMethod() => @@ -340,5 +343,19 @@ namespace RealTime.GameConnection.Patches } } } + + private sealed class FishingHarborAI_TrySpawnBoat : PatchBase + { + protected override MethodInfo GetMethod() => + typeof(FishingHarborAI).GetMethod( + nameof(FishingHarborAI.TrySpawnBoat), + BindingFlags.Instance | BindingFlags.Public, + null, + new[] { typeof(ushort), typeof(Building).MakeByRefType() }, + new ParameterModifier[0]); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1213", Justification = "Harmony patch")] + private static bool Prefix(ref Building buildingData) => (buildingData.m_flags & Building.Flags.Active) != 0; + } } } -- GitLab