private void FindValidLifts() { Puts("Finding lifts..."); ProceduralLift[] lifts = UnityEngine.Object.FindObjectsOfType <ProceduralLift>(); if (lifts?.Length == 0) { return; } for (int i = 0; i < lifts.Length; i++) { ProceduralLift target = lifts[i]; if (target == null || target.IsDestroyed) { continue; } Vector3 targetPosition = target.transform.position; for (int y = 0; y < lifts.Length; y++) { ProceduralLift other = lifts[y]; if (other == null || other == target || other.IsDestroyed) { continue; } Vector3 otherPosition = other.transform.position; if (Approximately(otherPosition.x, targetPosition.x) && Approximately(otherPosition.z, targetPosition.z) && Approximately(Vector3.Distance(otherPosition, targetPosition), APPROX_DISTANCE)) { Vector3 bottom = otherPosition.y < targetPosition.y ? otherPosition : targetPosition; Vector3 top = otherPosition.y > targetPosition.y ? otherPosition : targetPosition; float rotationBottom = otherPosition.y < targetPosition.y ? other.transform.rotation.eulerAngles.y : target.transform.rotation.eulerAngles.y; float rotationTop = otherPosition.y > targetPosition.y ? other.transform.rotation.eulerAngles.y : target.transform.rotation.eulerAngles.y; RecursiveKill(target); RecursiveKill(other); Puts("Found Lift at Space Needle"); storedData.lifts.Add(new StoredData.LiftPositions(bottom, top, rotationBottom, rotationTop)); } } } if (storedData.lifts.Count == 0) { Puts("No lifts found..."); return; } SaveData(); CreateLifts(); }
private object OnLiftUse(ProceduralLift lift, BasePlayer player) { NeedleLift needleLift = lift.GetComponent <NeedleLift>(); if (needleLift != null) { needleLift.OnLiftUse(); return(true); } return(null); }
private void CreateLift(StoredData.LiftPositions data) { ProceduralLift lift = GameManager.server.CreateEntity(LIFT_PREFAB, data.bottom, Quaternion.Euler(0f, data.rotationBottom, 0f)) as ProceduralLift; lift.enableSaving = false; lift.Spawn(); NeedleLift needleLift = lift.gameObject.AddComponent <NeedleLift>(); needleLift.Initialize(data); lifts.Add(needleLift); Puts($"Created Lift at Space Needle {lift.transform.position}"); }
private void OnLiftUse(ProceduralLift lift, BasePlayer player) => PlayerStats.TryFind(player.userID).LiftUsages++;