2022-01-29 04:49:07 +00:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using UnityEngine;
|
2021-01-29 15:29:50 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.WorldSync;
|
|
|
|
|
|
|
|
|
|
public abstract class WorldObject<T> : IWorldObject
|
|
|
|
|
where T : MonoBehaviour
|
2020-08-13 17:25:12 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public int ObjectId { get; init; }
|
|
|
|
|
MonoBehaviour IWorldObject.AttachedObject => AttachedObject;
|
|
|
|
|
public T AttachedObject { get; init; }
|
|
|
|
|
public string Name => AttachedObject ? AttachedObject.name : "<NullObject!>";
|
2022-03-11 08:58:14 +00:00
|
|
|
|
public override string ToString() => $"{ObjectId}:{GetType().Name} ({Name})";
|
2020-12-23 22:43:05 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public virtual async UniTask Init(CancellationToken ct) { }
|
|
|
|
|
public virtual void OnRemoval() { }
|
|
|
|
|
public virtual bool ShouldDisplayDebug() => QSBWorldSync.AllObjectsReady && AttachedObject && AttachedObject.gameObject.activeInHierarchy;
|
|
|
|
|
public virtual string ReturnLabel() => ToString();
|
|
|
|
|
public virtual void DisplayLines() { }
|
2021-12-02 08:42:24 +00:00
|
|
|
|
|
2022-08-02 23:45:47 +00:00
|
|
|
|
public virtual void SendInitialState(uint to) { }
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|