1
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Entities.Player
|
||||
{
|
||||
/// <summary>
|
||||
/// Unity玩家服务
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class UnityPlayerServiceService : IPlayerService
|
||||
{
|
||||
public static event Action<Entity> OnPlayerInitialized;
|
||||
public static event Action<Entity> OnPlayerDisposed;
|
||||
public static Entity LocalPlayer { get;private set; }
|
||||
public static void Register(Entity entity)
|
||||
{
|
||||
OnPlayerInitialized?.Invoke(entity);
|
||||
LocalPlayer = entity;
|
||||
}
|
||||
public static void UnRegister(Entity entity)
|
||||
{
|
||||
OnPlayerDisposed?.Invoke(entity);
|
||||
LocalPlayer = null;
|
||||
}
|
||||
Entity IPlayerService.LocalPlayer=>LocalPlayer;
|
||||
event Action<Entity> IPlayerService.OnPlayerInitialized
|
||||
{
|
||||
add => OnPlayerInitialized += value;
|
||||
remove => OnPlayerInitialized -= value;
|
||||
}
|
||||
event Action<Entity> IPlayerService.OnPlayerDisposed
|
||||
{
|
||||
add => OnPlayerDisposed += value;
|
||||
remove => OnPlayerDisposed -= value;
|
||||
}
|
||||
void IPlayerService.Register(Entity entity)=>Register(entity);
|
||||
void IPlayerService.UnRegister(Entity entity)=>UnRegister(entity);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user