Add quick interactions locally
This commit is contained in:
40
Quick Interactions/CSharp/Shared/Utils/GhostDetector.cs
Normal file
40
Quick Interactions/CSharp/Shared/Utils/GhostDetector.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using Barotrauma;
|
||||
using HarmonyLib;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace QuickInteractions
|
||||
{
|
||||
public static class GhostDetector
|
||||
{
|
||||
public static int MaxDetections = 3;
|
||||
|
||||
public static Dictionary<string, int> Detections = new();
|
||||
public static bool AmIDead(Mod instance, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
if (instance?.Disposed == true)
|
||||
{
|
||||
if (!Detections.ContainsKey(memberName)) Detections[memberName] = 0;
|
||||
Detections[memberName] += 1;
|
||||
|
||||
if (Detections[memberName] <= MaxDetections)
|
||||
{
|
||||
Mod.Log($"{Mod.Name}:", Color.Yellow);
|
||||
Mod.Log($"A proximity detector has detected an invisible creature at {memberName}", Color.Orange);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user