1.5, added stuff, fixed stuff
- mod icon - fixes for new vanilla clipping issues - GenClosest optimization improving repairing, wardening, tending jobs - caching for new ListerBuildings methods - DynamicDrawManager single threading - Type.GetFields caching - StatParts analyzer category - removed duplicate steam warning and optionally window - added exception handling for debug menu, incidentworker, Graphic_Multi, InitializeComps, making all those now log what mod broke and not cause black screens or whatever
This commit is contained in:
@@ -35,4 +35,17 @@ public static class CellIndexExtensions
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int CellToIndex(int x, int z, int mapSizeX) => (z * mapSizeX) + x;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static List<Thing> ThingsListAtFast(this ThingGrid thingGrid, CellIndex cellIndex)
|
||||
=> thingGrid.thingGrid[cellIndex.Value];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsFogged(this FogGrid fogGrid, CellIndex cellIndex) => fogGrid.fogGrid[cellIndex.Value];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float GetDepth(this SnowGrid snowGrid, CellIndex cellIndex) => snowGrid.depthGrid[cellIndex.Value];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float GetDepth(this SnowGrid snowGrid, int cellIndex) => snowGrid.depthGrid[cellIndex];
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Unity.Collections;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
|
||||
namespace PerformanceFish.Utility;
|
||||
|
||||
@@ -308,6 +310,28 @@ public static class CollectionExtensions
|
||||
}
|
||||
|
||||
public static List<T> AsOrToList<T>(this IEnumerable<T> enumerable) => enumerable as List<T> ?? enumerable.ToList();
|
||||
|
||||
public static unsafe ref T GetReference<T>(this NativeArray<T> nativeArray, int index) where T : struct
|
||||
=> ref Unsafe.AsRef<T>(Unsafe.Add<T>(NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(nativeArray),
|
||||
index));
|
||||
|
||||
public static void UnwrapArray<T>(this List<T> list, out T[] array, out int count)
|
||||
{
|
||||
array = list._items;
|
||||
count = list._size;
|
||||
Guard.IsLessThanOrEqualTo(count, array.Length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void SetSize<T>(this List<T> list, int size) => list._size = size;
|
||||
|
||||
public static void AddRange<T>(this List<T> list, IndexedFishSet<T> set)
|
||||
{
|
||||
list.EnsureCapacity(list._size + set.Count);
|
||||
set.CopyTo(list._items, list._size);
|
||||
list._size += set.Count;
|
||||
list._version++;
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
private static T ThrowForNoElements<T>()
|
||||
|
||||
+12
-2
@@ -5,16 +5,19 @@
|
||||
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
#if V1_5
|
||||
using LudeonTK;
|
||||
#endif
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace PerformanceFish.Utility;
|
||||
|
||||
public static class PipetteTool
|
||||
public static class DebugActions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DebugAction("Misc", "Pipette tool", actionType = DebugActionType.ToolMap,
|
||||
allowedGameStates = AllowedGameStates.PlayingOnMap)]
|
||||
public static void Action()
|
||||
public static void PipetteTool()
|
||||
{
|
||||
var things = UI.MouseCell().GetThingList(Find.CurrentMap).ToList();
|
||||
things.Sort(static (x, y) => ((int)x.def.altitudeLayer).CompareTo((int)y.def.altitudeLayer));
|
||||
@@ -77,4 +80,11 @@ public static class PipetteTool
|
||||
|
||||
private static byte GetAverage(IEnumerable<Color32> colors, Func<Color32, int> selector)
|
||||
=> (byte)Mathf.RoundToInt((float)colors.Average(selector));
|
||||
|
||||
#if testing
|
||||
[UsedImplicitly]
|
||||
[DebugAction("Misc", "Test ListerThings", actionType = DebugActionType.ToolMap,
|
||||
allowedGameStates = AllowedGameStates.PlayingOnMap)]
|
||||
public static void TestListerThings() => Find.CurrentMap.listerThings.Remove(ThingMaker.MakeThing(ThingDefOf.Beer));
|
||||
#endif
|
||||
}
|
||||
@@ -95,6 +95,9 @@ public static class MiscExtensions
|
||||
return false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int SizeX(this Map map) => map.cellIndices.mapSizeX;
|
||||
|
||||
public static Map? TryGetMapHeld(this Thing thing)
|
||||
{
|
||||
var maps = Current.Game.Maps;
|
||||
|
||||
@@ -24,4 +24,12 @@ public static class StringExtensions
|
||||
|
||||
public static string AppendWhenNotNull(this string instance, object? value)
|
||||
=> value != null ? instance + value : instance;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool Contains(this string self, string value, StringComparison comparison)
|
||||
{
|
||||
Guard.IsNotNull(self);
|
||||
Guard.IsNotNull(value);
|
||||
return self.IndexOf(value, comparison) >= 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user