using System.Collections; using System.Collections.Generic; using UnityEngine; using BITKit; namespace BITKit.Entities { public class EntityLocalPlayer : EntityComponent { public override void OnStart() { base.OnStart(); entity.Set(nameof(EntityComponent.isLocalPlayer), true); if (isSpawned is false) { foreach (var x in GetComponentsInChildren(true)) { x.OnSpawn(); } entity.Set(nameof(isSpawned), true); } IEntity.LocalPlayer = entity; IEntity.OnSpawnLocalPlayer.Invoke(entity); } public override void OnDestroyComponent() { base.OnDestroyComponent(); if (isSpawned) { foreach (var x in GetComponentsInChildren(true)) { x.OnDespawn(); } entity.Set(nameof(isSpawned), false); } IEntity.LocalPlayer = null; } public override void OnSpawn() { BIT4Log.Log("已创建本地玩家"); } } }