protected override void OnUpdate() { if (isInit) { return; } isInit = true; var query = GetEntityQuery(typeof(ReplicatedEntityData)); var entities = query.ToEntityArray(Allocator.TempJob); // FSLog.Info($"entities.Length:{entities.Length}"); var entityList = entities.ToList(); entityList.Sort((a, b) => { var sa = EntityManager.GetComponentData <ReplicatedEntityData>(a).NetId; var sb = EntityManager.GetComponentData <ReplicatedEntityData>(b).NetId; return(sa.CompareTo(sb)); }); for (var i = 0; i < entityList.Count; ++i) { var entity = entityList[i]; var replicatedEntityData = EntityManager.GetComponentData <ReplicatedEntityData>(entity); replicatedEntityData.Id = i; EntityManager.SetComponentData(entity, replicatedEntityData); var trans = EntityManager.GetComponentData <Translation>(entity); FSLog.Info($"SceneEntities,id:{i},netId:{replicatedEntityData.NetId},trans:{trans.Value}"); } SceneEntities.AddRange(entityList); FSLog.Info($"SceneEntities.count:{SceneEntities.Count}"); entities.Dispose(); }
public void RegisterFactory(ushort typeId, ReplicatedEntityFactory typeFactory) { factories[typeId] = typeFactory; FSLog.Info(($"RegisterFactory,typeId:{typeId},factories size:{factories.Count}")); }