Guest User

Untitled

a guest
Apr 3rd, 2024
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. namespace Mimics.API {
  2.   public static class MimicsAPI {
  3.     internal static List<MimicEventHandler> mimicEventHandlers = new List<MimicEventHandler>();
  4.  
  5.     public static void RegisterMimicEventHandler(MimicEventHandler handler){
  6.       mimicEventHandlers.Add(handler);
  7.     }
  8.  
  9.     public static MimicEventHandler currentMimicEventHandler { get; internal set; }
  10.  
  11.     internal static void RefreshMimicEventHandler(){
  12.       currentMimicEventHandler = null;
  13.       foreach(var m in mimicEventHandlers){
  14.         if (m.IsMyInteriorLoaded) {
  15.           currentMimicEventHandler = m;
  16.           return;
  17.         }
  18.       }
  19.     }
  20.  
  21.     internal static bool IgnoreBasePlacementValidation(Doorway doorway){
  22.       if (currentMimicEventHandler == null) return false;
  23.       return currentMimicEventHandler.IgnoreDefaultPlacementValidation(doorway);
  24.     }
  25.  
  26.     internal static bool IsPlacementValid(Doorway doorway){
  27.       if (currentMimicEventHandler == null) return true;
  28.       return currentMimicEventHandler.IsPlacementValid(doorway);
  29.     }
  30.  
  31.   }
  32.  
  33.   public abstract class MimicEventHandler {
  34.     public virtual bool IsMyInteriorLoaded => false;
  35.     public virtual bool IsPlacementValid(Doorway doorway) => true;
  36.     public virtual bool IgnoreDefaultPlacementValidation(Doorway doorway) => false;
  37.  
  38.     public virtual void OnMimicCreated(MimicDoor mimicDoor, Doorway doorway) { }
  39.     public virtual void OnMimicAttackStart(MimicDoor mimicDoor) { }
  40.     public virtual void OnMimicAttackEnd(MimicDoor mimicDoor) { }
  41.   }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment