2021-11-11 05:51:14 +00:00
|
|
|
|
using QSB.Player;
|
|
|
|
|
using UnityEngine;
|
2021-01-29 15:29:50 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.WorldSync
|
2020-08-13 17:25:12 +00:00
|
|
|
|
{
|
2020-12-24 08:41:38 +00: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-21 02:35:38 +00:00
|
|
|
|
public int ObjectId { get; init; }
|
|
|
|
|
public T AttachedObject { get; init; }
|
2021-02-19 21:25:17 +00:00
|
|
|
|
public string Name => AttachedObject == null ? "<NullObject!>" : AttachedObject.name;
|
2021-11-11 05:51:14 +00:00
|
|
|
|
public string LogName => $"{QSBPlayerManager.LocalPlayerId}.{ObjectId}:{GetType().Name}";
|
2020-12-23 22:43:05 +00:00
|
|
|
|
|
2021-12-11 22:38:54 +00:00
|
|
|
|
public virtual void Init() { }
|
2021-02-09 21:35:31 +00:00
|
|
|
|
public virtual void OnRemoval() { }
|
2021-04-16 10:40:13 +00:00
|
|
|
|
public MonoBehaviour ReturnObject() => AttachedObject;
|
2021-12-02 08:42:24 +00:00
|
|
|
|
|
|
|
|
|
/// indicates that this won't become ready immediately
|
|
|
|
|
protected void StartDelayedReady() => WorldObjectManager._numObjectsReadying++;
|
|
|
|
|
|
|
|
|
|
/// indicates that this is now ready
|
|
|
|
|
protected void FinishDelayedReady() => WorldObjectManager._numObjectsReadying--;
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2021-11-11 05:51:14 +00:00
|
|
|
|
}
|