mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-11-11 08:38:45 +00:00
提交新概念 Tile从服务器
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Entitas;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame.Entity.Component.Components;
|
||||
@@ -13,6 +14,9 @@ namespace JNGame.Sync.Frame.Entity
|
||||
public JNSyncService Sync { get; private set; }
|
||||
|
||||
public JNEntityLookup CLookup;
|
||||
|
||||
//方便查抄的实体Map
|
||||
public Dictionary<ulong, T> Entities = new ();
|
||||
|
||||
public JNContext(): base((new T()).NewCLookup().Count, () => new T())
|
||||
{
|
||||
@@ -36,7 +40,23 @@ namespace JNGame.Sync.Frame.Entity
|
||||
{
|
||||
Sync = data;
|
||||
}
|
||||
|
||||
|
||||
public T Query(ulong id)
|
||||
{
|
||||
Entities.TryGetValue(id, out var entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void AddEntity(ulong id, JNEntity entity)
|
||||
{
|
||||
Entities.Add(id,entity as T);
|
||||
}
|
||||
|
||||
public void RemoveEntity(ulong id)
|
||||
{
|
||||
Entities.Remove(id);
|
||||
}
|
||||
|
||||
public T GetService<T>() where T : SLogicSystem
|
||||
{
|
||||
return Sync.GetSystem<T>();
|
||||
@@ -100,7 +120,9 @@ namespace JNGame.Sync.Frame.Entity
|
||||
{
|
||||
public abstract JNSyncService GetSync();
|
||||
public abstract void InitReference(JNSyncService data);
|
||||
|
||||
public void AddEntity(ulong id,JNEntity entity);
|
||||
public void RemoveEntity(ulong id);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,6 +58,7 @@ namespace JNGame.Sync.Entity
|
||||
{
|
||||
_id = GetSystem<JNRandomSystem>().NextId();
|
||||
}
|
||||
Context.AddEntity(Id,this);
|
||||
}
|
||||
|
||||
public abstract JNEntityLookup NewCLookup();
|
||||
@@ -126,6 +127,7 @@ namespace JNGame.Sync.Entity
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
Context.RemoveEntity(Id);
|
||||
OnSyncDestroy();
|
||||
RemoveAllComponents();
|
||||
base.Destroy();
|
||||
|
||||
Reference in New Issue
Block a user