using UnityEngine; using VLB; namespace Oxide.Plugins { [Info("LadderFlyhack", "Razor", "1.0.0")] [Description("Fix Ladder Flyhack Violation")] public class LadderFlyhack : RustPlugin { #region Init/Unload private void Init() => Unsubscribe(nameof(OnEntitySpawned)); private void OnServerInitialized() { foreach (var entity in BaseNetworkable.serverEntities) { var miningQuarry = entity as MiningQuarry; if (miningQuarry == null) continue; OnEntitySpawned(miningQuarry); } Subscribe(nameof(OnEntitySpawned)); } private void Unload() { foreach (var entity in BaseNetworkable.serverEntities) { var quarry = entity as MiningQuarry; if ((object)quarry == null || quarry.isStatic) continue; FlyHackFix.RemoveFromEntity(quarry); } } #endregion #region Hooks private void OnEntitySpawned(MiningQuarry entity) { if (!entity.isStatic) FlyHackFix.AddToEntity(entity); } #endregion #region QuarryTrigger private class FlyHackFix : MonoBehaviour { public static void AddToEntity(BaseEntity entity) { BaseEntity test = null; var companion = entity.gameObject.AddComponent(); var gameObject = entity.gameObject.CreateChild(); gameObject.layer = (int)Rust.Layer.Trigger; companion._child = gameObject; var collider = gameObject.GetOrAddComponent(); collider.isTrigger = true; if (entity.name.Contains("pumpjack")) { gameObject.transform.localPosition = new Vector3(-3.85f, 3.03f, 1.65f); } else { gameObject.transform.localPosition = new Vector3(1.55f, 6.03f, -2.01f); } collider.size = new Vector3(0.90f, 10.27f, 0.50f); TriggerLadder triggerLadder = gameObject.AddComponent(); triggerLadder.interestLayers = Rust.Layers.Mask.Player_Server; triggerLadder.Type = TriggerLadder.LadderType.Rungs; triggerLadder.name = "ladder trigger"; collider.name = "ladder trigger"; } public static void RemoveFromEntity(BaseEntity entity) { DestroyImmediate(entity.gameObject.GetComponent()); } private GameObject _child; private void OnDestroy() { DestroyImmediate(_child); } } #endregion } }