2022-01-20 22:36:23 -08:00
|
|
|
|
using UnityEngine;
|
2021-01-29 15:29:50 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.WorldSync
|
2020-08-13 19:25:12 +02:00
|
|
|
|
{
|
2020-12-24 09:41:38 +01:00
|
|
|
|
public abstract class WorldObject<T> : IWorldObject
|
2021-01-29 15:29:50 +00:00
|
|
|
|
where T : MonoBehaviour
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-12-20 18:35:38 -08:00
|
|
|
|
public int ObjectId { get; init; }
|
|
|
|
|
public T AttachedObject { get; init; }
|
2022-01-21 14:50:07 -08:00
|
|
|
|
public string Name => AttachedObject ? AttachedObject.name : "<NullObject!>";
|
2022-01-20 22:36:23 -08:00
|
|
|
|
public string LogName => $"{ObjectId}:{GetType().Name} ({Name})";
|
2020-12-23 22:43:05 +00:00
|
|
|
|
|
2021-12-11 14:38:54 -08:00
|
|
|
|
public virtual void Init() { }
|
2021-02-09 21:35:31 +00:00
|
|
|
|
public virtual void OnRemoval() { }
|
2021-04-16 11:40:13 +01:00
|
|
|
|
public MonoBehaviour ReturnObject() => AttachedObject;
|
2022-01-21 14:50:07 -08:00
|
|
|
|
public virtual bool ShouldDisplayDebug() => QSBWorldSync.AllObjectsReady && AttachedObject && AttachedObject.gameObject.activeInHierarchy;
|
2021-12-28 18:06:34 +00:00
|
|
|
|
public virtual string ReturnLabel() => LogName;
|
2022-01-06 16:10:44 +00:00
|
|
|
|
public virtual void DisplayLines() { }
|
2021-12-02 00:42:24 -08:00
|
|
|
|
|
2022-01-21 15:13:16 -08:00
|
|
|
|
public virtual void SendResyncInfo(uint to) { }
|
2022-01-21 14:56:45 -08:00
|
|
|
|
|
2021-12-02 00:42:24 -08:00
|
|
|
|
/// indicates that this won't become ready immediately
|
2022-01-18 00:27:32 -08:00
|
|
|
|
protected void StartDelayedReady() => QSBWorldSync._numObjectsReadying++;
|
2021-12-02 00:42:24 -08:00
|
|
|
|
|
|
|
|
|
/// indicates that this is now ready
|
2022-01-18 00:27:32 -08:00
|
|
|
|
protected void FinishDelayedReady() => QSBWorldSync._numObjectsReadying--;
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2021-11-10 21:51:14 -08:00
|
|
|
|
}
|