SHARE
TWEET

Untitled

a guest Jan 12th, 2019 32 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using Modding.Mapper;
  3. using UnityEngine;
  4.  
  5. namespace lto_particle
  6. {
  7.     class MVector3 : MCustom<Vector3>
  8.     {
  9.         public MVector3(string displayName, string key, Vector3 defaultValue) : base(displayName, key, defaultValue)
  10.         {
  11.         }
  12.  
  13.         public override Vector3 DeSerializeValue(XData data)
  14.         {
  15.             return ((XVector3)data).Value;
  16.         }
  17.  
  18.         public override XData SerializeValue(Vector3 value)
  19.         {
  20.             return new XVector3(base.SerializationKey, value);
  21.         }
  22.     }
  23. }
  24.  
  25.  
  26.  
  27. using Modding.Mapper;
  28. using UnityEngine;
  29. using System.Collections;
  30. using System.Collections.Generic;
  31. using System.Runtime.CompilerServices;
  32. using Selectors;
  33. using System;
  34. using System.Text.RegularExpressions;
  35.  
  36. namespace lto_particle
  37. {
  38.     internal class Vector3Selector : CustomSelector<Vector3, MVector3>
  39.     {
  40.         private static GameObject _prefab;
  41.  
  42.         private static bool _failedOnce;
  43.  
  44.         private DynamicText _fieldName;
  45.  
  46.         private MValue[] _values;
  47.  
  48.         private ValueSelector[] _valueSelectors;
  49.  
  50.         static Vector3Selector()
  51.         {
  52.             Vector3Selector.CreatePrefab();
  53.         }
  54.  
  55.         public Vector3Selector()
  56.         {
  57.         }
  58.  
  59.         protected override void CreateInterface()
  60.         {
  61.             Vector3 vector3 = base.CustomMapperType.Value;
  62.             this._values = new MValue[] { new MValue(string.Concat("  ", base.CustomMapperType.DisplayName), "x", vector3.x), new MValue(string.Concat("  ", base.CustomMapperType.DisplayName), "y", vector3.y), new MValue(string.Concat("  ", base.CustomMapperType.DisplayName), "z", vector3.z) };
  63.             if (!Vector3Selector._failedOnce)
  64.             {
  65.                 Transform content = base.Content;
  66.                 Transform _transform = ((GameObject)UnityEngine.Object.Instantiate(Vector3Selector._prefab, content)).transform;
  67.                 _transform.localPosition=Vector3.zero;
  68.                 _transform.name = "Vector3Selector";
  69.                 this._fieldName = _transform.FindChild("TextHolder/r_Text").GetComponent<DynamicText>();
  70.                 Transform[] transformArray = new Transform[] { _transform.FindChild("ValueHolder1"), _transform.FindChild("ValueHolder2"), _transform.FindChild("ValueHolder3") };
  71.                 this._valueSelectors = Array.ConvertAll<Transform, ValueSelector>(transformArray, (Transform holder) => holder.GetComponent<ValueSelector>());
  72.                 for (int i = 0; i < 3; i++)
  73.                 {
  74.                     int num = i;
  75.                     ValueSelector component = transformArray[i].GetComponent<ValueSelector>();
  76.                     component.mValue = this._values[i];
  77.                     this._values[i].ValueChanged += new ValueChangeHandler((float v) => {
  78.                         Vector3 value = this.CustomMapperType.Value;
  79.                         value[num]=v;
  80.                         this.CustomMapperType.Value = value;
  81.                     });
  82.                 }
  83.                 this.UpdateInterface();
  84.             }
  85.         }
  86.  
  87.         public static void CreatePrefab()
  88.         {
  89.             //string versionString = VersionNumber.GetVersionString();
  90.             //versionString = string.Concat(Regex.Match(versionString, "^[0-9.]*").Value, ".", Regex.Match(versionString, "[0-9]*$").Value);
  91.             if ((Vector3Selector._prefab != null ? false : !Vector3Selector._failedOnce))
  92.             {
  93.                 //Debug.Log(string.Concat("You're running version ", versionString));
  94.                 GameObject gameObject = Vector3Selector.GetPool().Get();
  95.                 gameObject.name=("Vector3Selector");
  96.                 UnityEngine.Object.Destroy(gameObject.GetComponent<ContainerDetails>());
  97.                 Vector3Selector._prefab = gameObject;
  98.                 UnityEngine.Object.DontDestroyOnLoad(Vector3Selector._prefab);
  99.                 UnityEngine.Object.Destroy(gameObject.transform.FindChild("Background").gameObject);
  100.                 GameObject _gameObject = gameObject.transform.FindChild("ValueHolder").gameObject;
  101.                 GameObject gameObject1 = UnityEngine.Object.Instantiate(_gameObject, gameObject.transform) as GameObject;
  102.                 GameObject gameObject2 = UnityEngine.Object.Instantiate(_gameObject, gameObject.transform) as GameObject;
  103.                 Vector3 _localPosition = _gameObject.transform.localPosition.y * Vector3.up;
  104.                 Transform transform = _gameObject.transform.FindChild("Background");
  105.                 Bounds _bounds = transform.GetComponent<Renderer>().bounds;
  106.                 float _size = _bounds.size.x * 1.2f;
  107.                 _gameObject.transform.localPosition=(((Vector3.right * _size) * -0.5f) + _localPosition);
  108.                 gameObject1.transform.localPosition=(((Vector3.right * _size) * 0.5f) + _localPosition);
  109.                 gameObject2.transform.localPosition=(((Vector3.right * _size) * 1.5f) + _localPosition);
  110.                 _gameObject.name=("ValueHolder1");
  111.                 gameObject1.name=("ValueHolder2");
  112.                 gameObject2.name=("ValueHolder3");
  113.             }
  114.         }
  115.  
  116.         private static BMWidgetPool.Pool GetPool()
  117.         {
  118.             return BMWidgetPool.GetPool("Prefabs/BlockMapper/ValueContainer");
  119.         }
  120.  
  121.         protected override void UpdateInterface()
  122.         {
  123.             MVector3 customMapperType = base.CustomMapperType;
  124.             for (int i = 0; i < 3; i++)
  125.             {
  126.                 this._values[i].SetValue(customMapperType.Value[i]);
  127.                 if (!Vector3Selector._failedOnce)
  128.                 {
  129.                     this._valueSelectors[i].Init();
  130.                 }
  131.             }
  132.         }
  133.     }
  134. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top