コード例 #1
0
        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();
        }
コード例 #2
0
        public void RegisterFactory(ushort typeId, ReplicatedEntityFactory typeFactory)
        {
            factories[typeId] = typeFactory;

            FSLog.Info(($"RegisterFactory,typeId:{typeId},factories size:{factories.Count}"));
        }