59 lines
1.4 KiB
C#
Raw Normal View History

2021-03-13 19:54:36 +00:00
using OWML.Utils;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.SectorSync.WorldObjects
{
2020-12-23 22:43:05 +00:00
public class QSBSector : WorldObject<Sector>
2020-12-02 21:23:01 +00:00
{
2020-12-23 22:43:05 +00:00
public Sector.Name Type => AttachedObject.GetName();
public Transform Transform => AttachedObject.transform;
2020-12-02 21:23:01 +00:00
public Vector3 Position => Transform.position;
2021-03-11 20:02:23 +00:00
public bool IsFakeSector => AttachedObject.GetType() == typeof(FakeSector);
2020-08-20 19:31:10 +01:00
2020-12-23 22:43:05 +00:00
public override void Init(Sector sector, int id)
2020-12-02 21:23:01 +00:00
{
ObjectId = id;
2020-12-23 22:43:05 +00:00
AttachedObject = sector;
2021-03-11 20:02:23 +00:00
if (IsFakeSector)
{
QSBSectorManager.Instance.FakeSectors.Add(this);
}
}
public override void OnRemoval()
{
if (IsFakeSector)
{
QSBSectorManager.Instance.FakeSectors.Remove(this);
}
2020-12-02 21:23:01 +00:00
}
2021-03-12 21:46:02 +00:00
public bool ShouldSyncTo()
{
if (Type == Sector.Name.Ship)
{
return false;
}
2021-03-13 19:54:36 +00:00
if (AttachedObject.name == "Sector_Shuttle" || AttachedObject.name == "Sector_NomaiShuttleInterior")
2021-03-12 21:46:02 +00:00
{
2021-03-13 19:54:36 +00:00
if (QSBSceneManager.CurrentScene == OWScene.SolarSystem)
{
if (!AttachedObject.gameObject.GetComponentInParent<NomaiShuttleController>().IsPlayerInside())
{
return false;
}
}
else if (QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse)
{
if (!AttachedObject.gameObject.GetComponentInParent<EyeShuttleController>().GetValue<bool>("_isPlayerInside"))
{
return false;
}
}
2021-03-12 21:46:02 +00:00
}
return true;
}
2020-12-02 21:23:01 +00:00
}
2020-12-03 08:28:05 +00:00
}