1
This commit is contained in:
32
Src/Unity/Scripts/Entity/Net/EntityNetConfig.cs
Normal file
32
Src/Unity/Scripts/Entity/Net/EntityNetConfig.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public sealed class EntityNetConfig : EntityBehavior
|
||||
{
|
||||
[SerializeField] private bool serverOnly;
|
||||
[SerializeReference,SubclassSelector] private INetClient netClient;
|
||||
[SerializeReference,SubclassSelector] private INetServer netServer;
|
||||
[SerializeReference,SubclassSelector] private ITicker ticker;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
ticker?.Add(OnTick);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
ticker?.Remove(OnTick);
|
||||
}
|
||||
private void OnTick(float deltaTime)
|
||||
{
|
||||
if (netClient.IsConnected && serverOnly)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user