using System; using System.Collections; using UnityEngine; namespace SUISSEngine { public class BeachTiler : MonoBehaviour { private void Start() { if (this.tilesX < 1) { throw new ArgumentException("Number of tiles must be at least 1", (this.tilesX >= 1) ? "tilesY" : "tilesX"); } SpriteRenderer component = base.GetComponent(); if (component == null) { throw new InvalidOperationException("Can't tile this game object because it has no SpriteRenderer."); } Sprite sprite = component.sprite; if (sprite == null) { throw new InvalidOperationException("Can't tile this game object because its SpriteRenderer has no sprite."); } GameObject gameObject = base.gameObject; string name = gameObject.name; int num = Array.IndexOf(base.GetComponents(), this); ArrayList arrayList = new ArrayList(); Vector3 position = gameObject.transform.position; float num2 = 580f; if (this.reverseX) { num2 = -num2; } for (int i = 0; i < this.tilesX; i++) { if (i != 0) { GameObject gameObject2 = UnityEngine.Object.Instantiate(gameObject, new Vector3(position.x + num2 * (float)i, position.y - (float)(290 * i), position.z), Quaternion.identity); if (this.doNotCopyScripts) { foreach (MonoBehaviour obj in gameObject2.GetComponents()) { UnityEngine.Object.Destroy(obj); } } else { UnityEngine.Object.Destroy(gameObject2.GetComponents()[num]); } gameObject2.name = string.Concat(new object[] { name, " (", i, ")" }); arrayList.Add(gameObject2); } } IEnumerator enumerator = arrayList.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj2 = enumerator.Current; GameObject gameObject3 = (GameObject)obj2; gameObject3.transform.parent = gameObject.transform; } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } public int tilesX = 1; public bool reverseX; public bool reverseY; public bool doNotCopyScripts = true; } }