Added gas grid optimization, various despawn optimizations, new hauling optimizations utilizing events and regions, bugfixes for old patches and for vanilla functions too, as well as smaller additions. 1.3 files removed.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2023 bradson
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
global using LwmCompCache = PerformanceFish.Cache.ByReference<Verse.Thing, PerformanceFish.Hauling.LwmCompCacheValue>;
|
||||
|
||||
namespace PerformanceFish.Hauling;
|
||||
|
||||
public record struct LwmCompCacheValue
|
||||
{
|
||||
public CompProperties? CompProperties;
|
||||
|
||||
public static CompProperties? TryGetLwmProps(Thing slotGroupParent)
|
||||
=> ModCompatibility.Types.LWM.CompProperties != null
|
||||
? slotGroupParent.def.comps?.Find(static props
|
||||
=> props.GetType() == ModCompatibility.Types.LWM.CompProperties)
|
||||
: null;
|
||||
|
||||
static LwmCompCacheValue() => EnsureInitialized();
|
||||
|
||||
public static void EnsureInitialized()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _initialized, 1) == 0)
|
||||
LwmCompCache.ValueInitializer = static key => new() { CompProperties = TryGetLwmProps(key) };
|
||||
}
|
||||
|
||||
private static volatile int _initialized;
|
||||
|
||||
public static AccessTools.FieldRef<CompProperties, int>?
|
||||
LwmMaxNumberStacks = TryGetLwmField("maxNumberStacks"),
|
||||
LwmMinNumberStacks = TryGetLwmField("minNumberStacks");
|
||||
|
||||
private static AccessTools.FieldRef<CompProperties, int>? TryGetLwmField(string name)
|
||||
=> ModCompatibility.Types.LWM.CompProperties is { } propsType
|
||||
? AccessTools.FieldRefAccess<CompProperties, int>(AccessTools.Field(propsType, name))
|
||||
: null;
|
||||
}
|
||||
Reference in New Issue
Block a user