| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using HarmonyLib;
- using GadgetCore.API;
- using UnityEngine;
- using System.Collections;
- namespace First.Patches
- {
- [HarmonyPatch(typeof(Chunk))]
- [HarmonyPatch("GeneratePlatforms")]
- [HarmonyGadget("First")]
- public static class Patch_Chunk_GeneratePlatforms
- {
- [HarmonyPrefix]
- public static bool Prefix(Chunk __instance)
- {
- int type = UnityEngine.Random.Range(0, 4);
- if (type < 3)
- {
- for (int i = 0; i < 5; i++)
- {
- if (UnityEngine.Random.Range(0, 2) == 0)
- {
- Network.Instantiate(Resources.Load("plat/plat1"), GetPlatPos(i, __instance.transform.position), Quaternion.identity, 0);
- }
- }
- }
- else
- {
- for (int i = 0; i < 5; i++)
- {
- if (UnityEngine.Random.Range(0, 2) == 0)
- {
- Network.Instantiate(Resources.Load("plat/platMove"), GetPlatPos(i, __instance.transform.position), Quaternion.identity, 0);
- }
- }
- }
- // Add code to run before `MethodName` is called.
- return false; // Return false to prevent the vanilla method from running.
- }
- // Token: 0x0600013F RID: 319 RVA: 0x0001AB44 File Offset: 0x00018F44
- private static Vector3 GetPlatPos(int i, Vector3 position)
- {
- Vector3 result = new Vector3(0f, 0f, 0f);
- float num = (float)UnityEngine.Random.Range(-10, 11) * 0.7f;
- float num2 = (float)UnityEngine.Random.Range(-7, 8) * 0.7f;
- switch (i)
- {
- case 0:
- result = new Vector3(position.x - 16f + num, position.y + 16f + num2, 5f);
- break;
- case 1:
- result = new Vector3(position.x + 16f + num, position.y + 16f + num2, 5f);
- break;
- case 2:
- result = new Vector3(position.x + 16f + num, position.y - 16f + num2, 5f);
- break;
- case 3:
- result = new Vector3(position.x - 16f + num, position.y - 16f + num2, 5f);
- break;
- case 4:
- result = new Vector3(position.x + num * 2f, position.y + num2, 5f);
- break;
- }
- return result;
- }
- /*
- [HarmonyPostfix]
- public static void Postfix(ClassName __instance)
- {
- // Add code to run after `MethodName` is called.
- }
- */
- }
- }
|