29 lines
1.0 KiB
C#
Raw Normal View History

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
{
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; }
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
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;
public virtual bool ShouldDisplayDebug() => QSBWorldSync.AllObjectsReady && AttachedObject && AttachedObject.gameObject.activeInHierarchy;
2021-12-28 18:06:34 +00:00
public virtual string ReturnLabel() => LogName;
public virtual void DisplayLines() { }
2022-01-21 15:13:16 -08:00
public virtual void SendResyncInfo(uint to) { }
2022-01-21 14:56:45 -08:00
/// indicates that this won't become ready immediately
protected void StartDelayedReady() => QSBWorldSync._numObjectsReadying++;
/// indicates that this is now ready
protected void FinishDelayedReady() => QSBWorldSync._numObjectsReadying--;
2020-12-02 21:23:01 +00:00
}
2021-11-10 21:51:14 -08:00
}