1
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
/// <summary>Entity接口,用于复杂实体</summary>
|
||||
@@ -14,27 +13,27 @@ namespace BITKit.Entities
|
||||
void AddService(object service);
|
||||
void AddService(Type type, object service);
|
||||
}
|
||||
public class IEntityReader : NetMessageReader<IUnityEntity>
|
||||
{
|
||||
public override IUnityEntity ReadBinary(BinaryReader reader)
|
||||
{
|
||||
var id = reader.ReadInt32();
|
||||
var path = reader.ReadString();
|
||||
var entity = DI.Get<IEntitiesService>().Entities[id];
|
||||
return (IUnityEntity)entity;
|
||||
}
|
||||
public override void WriteBinary(BinaryWriter writer, IUnityEntity value)
|
||||
{
|
||||
writer.Write(value.Id);
|
||||
writer.Write(value.Id);
|
||||
}
|
||||
private IUnityEntity Create(int id, string path)
|
||||
{
|
||||
var entity = Addressables
|
||||
.LoadAssetAsync<GameObject>(path)
|
||||
.WaitForCompletion()
|
||||
.GetComponent<IUnityEntity>();
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
// public class IEntityReader : NetMessageReader<IUnityEntity>
|
||||
// {
|
||||
// public override IUnityEntity ReadBinary(BinaryReader reader)
|
||||
// {
|
||||
// var id = reader.ReadInt32();
|
||||
// var path = reader.ReadString();
|
||||
// var entity = DI.Get<IEntitiesService>().Entities[id];
|
||||
// return (IUnityEntity)entity;
|
||||
// }
|
||||
// public override void WriteBinary(BinaryWriter writer, IUnityEntity value)
|
||||
// {
|
||||
// writer.Write(value.Id);
|
||||
// writer.Write(value.Id);
|
||||
// }
|
||||
// private IUnityEntity Create(int id, string path)
|
||||
// {
|
||||
// var entity = Addressables
|
||||
// .LoadAssetAsync<GameObject>(path)
|
||||
// .WaitForCompletion()
|
||||
// .GetComponent<IUnityEntity>();
|
||||
// return entity;
|
||||
// }
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user