2020-08-13 18:43:47 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-08-16 15:15:36 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-08-13 18:43:47 +00:00
|
|
|
|
using UnityEngine;
|
2020-08-12 20:22:52 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.ElevatorSync
|
|
|
|
|
{
|
|
|
|
|
public class ElevatorManager : MonoBehaviour
|
|
|
|
|
{
|
2020-08-13 18:43:47 +00:00
|
|
|
|
public static ElevatorManager Instance { get; private set; }
|
|
|
|
|
|
|
|
|
|
private List<Elevator> _elevators;
|
|
|
|
|
|
2020-08-12 20:22:52 +00:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2020-08-13 18:43:47 +00:00
|
|
|
|
Instance = this;
|
|
|
|
|
|
|
|
|
|
LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad;
|
2020-08-12 20:22:52 +00:00
|
|
|
|
|
|
|
|
|
QSB.Helper.HarmonyHelper.AddPostfix<Elevator>("StartLift", typeof(ElevatorPatches), nameof(ElevatorPatches.StartLift));
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-13 18:43:47 +00:00
|
|
|
|
private void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
|
2020-08-12 20:22:52 +00:00
|
|
|
|
{
|
2020-08-13 18:43:47 +00:00
|
|
|
|
_elevators = Resources.FindObjectsOfTypeAll<Elevator>().ToList();
|
|
|
|
|
for (var id = 0; id < _elevators.Count; id++)
|
2020-08-12 20:22:52 +00:00
|
|
|
|
{
|
2020-08-16 15:15:36 +00:00
|
|
|
|
var qsbElevator = new QSBElevator();
|
|
|
|
|
qsbElevator.Init(_elevators[id], id);
|
|
|
|
|
WorldRegistry.AddObject(qsbElevator);
|
2020-08-12 20:22:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-13 18:43:47 +00:00
|
|
|
|
|
|
|
|
|
public int GetId(Elevator elevator) => _elevators.IndexOf(elevator);
|
2020-08-12 20:22:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|