2022-01-28 20:49:07 -08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
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; }
|
2022-01-26 00:55:47 -08:00
|
|
|
|
MonoBehaviour IWorldObject.AttachedObject => AttachedObject;
|
2021-12-20 18:35:38 -08:00
|
|
|
|
public T AttachedObject { get; init; }
|
2022-01-21 14:50:07 -08:00
|
|
|
|
public string Name => AttachedObject ? AttachedObject.name : "<NullObject!>";
|
2022-01-23 00:29:59 -08:00
|
|
|
|
public override string ToString() => $"{ObjectId}:{GetType().Name} ({Name})";
|
2020-12-23 22:43:05 +00:00
|
|
|
|
|
2022-01-28 20:50:34 -08:00
|
|
|
|
public virtual async UniTask Init(CancellationToken ct) { }
|
2021-02-09 21:35:31 +00:00
|
|
|
|
public virtual void OnRemoval() { }
|
2022-01-21 14:50:07 -08:00
|
|
|
|
public virtual bool ShouldDisplayDebug() => QSBWorldSync.AllObjectsReady && AttachedObject && AttachedObject.gameObject.activeInHierarchy;
|
2022-01-23 00:29:59 -08:00
|
|
|
|
public virtual string ReturnLabel() => ToString();
|
2022-01-06 16:10:44 +00:00
|
|
|
|
public virtual void DisplayLines() { }
|
2021-12-02 00:42:24 -08:00
|
|
|
|
|
2022-01-25 23:40:38 -08:00
|
|
|
|
public abstract void SendInitialState(uint to);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2021-11-10 21:51:14 -08:00
|
|
|
|
}
|