Advertisement
Guest User

NoBounds source code

a guest
Aug 10th, 2018
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.99 KB | None | 0 0
  1. using Modding;
  2. using Selectors;
  3. using UnityEngine;
  4.  
  5. namespace NoBounds
  6. {
  7.     public class Mod : ModEntryPoint
  8.     {
  9.  
  10.         NoBoundsMod noBoundsMod;
  11.         public override void OnLoad()
  12.         {
  13.             StatMaster.KeyMapper.disableSliderLimits = true;
  14.             noBoundsMod = NoBoundsMod.Instance;
  15.             UnityEngine.Object.DontDestroyOnLoad(noBoundsMod);
  16.         }
  17.     }
  18.  
  19.     public class NoBoundsMod : SingleInstance<NoBoundsMod>
  20.     {
  21.         public void Start()
  22.         {
  23.             Refresh = -1;
  24.         }
  25.  
  26.         private BlockMapper blockMapper;
  27.         BlockBehaviour block;
  28.  
  29.         public int Refresh;
  30.         public void Update()
  31.         {
  32.             if (StatMaster.SimulationState >= SimulationState.GlobalSimulation)
  33.             {
  34.                 return;
  35.             }
  36.             if (blockMapper == null)
  37.             {
  38.                 blockMapper = BlockMapper.CurrentInstance;
  39.                 block = null;
  40.             }
  41.             else
  42.             {
  43.                 if (blockMapper.Block != block)
  44.                 {
  45.                     block = blockMapper.Block;
  46.                     if (block != null)
  47.                     {
  48.                         block.MapperTypes.ForEach((mapperType) =>
  49.                         {
  50.                             mapperType.DisplayStateChanged += (state) =>
  51.                             {
  52.                                 Refresh = 2;
  53.                             };
  54.                         });
  55.                         ContainerDetails[] containers = blockMapper.GetComponentsInChildren<ContainerDetails>();
  56.                         for (int i = 0; i < containers.Length; i++)
  57.                         {
  58.                             ModifySelectors(containers[i].transform);
  59.                         }
  60.                     }
  61.                 }
  62.                 if (Refresh > 0)
  63.                 {
  64.                     if (--Refresh == 0)
  65.                     {
  66.                         ContainerDetails[] containers = blockMapper.GetComponentsInChildren<ContainerDetails>();
  67.                         for (int i = 0; i < containers.Length; i++)
  68.                         {
  69.                             ModifySelectors(containers[i].transform);
  70.                         }
  71.                     }
  72.                 }
  73.             }
  74.         }
  75.  
  76.         public static void ModifySelectors(Transform transform)
  77.         {
  78.             SliderSelector sliderSelector = transform.GetComponentInChildren<SliderSelector>();
  79.             ValueHolder valueHolder = transform.GetComponentInChildren<ValueHolder>();
  80.             if (sliderSelector && valueHolder)
  81.             {
  82.                 ModifySliderSelector(valueHolder);
  83.             }
  84.         }
  85.  
  86.         public static void ModifySliderSelector(ValueHolder valueHolder)
  87.         {
  88.             valueHolder.CharLimit = int.MaxValue;
  89.             valueHolder.MaxDecimals = 15;
  90.         }
  91.  
  92.  
  93.         public override string Name {
  94.             get { return "NoBoundsGameObject"; }
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement