protected override JobHandle OnUpdate(JobHandle inputDeps) { handle_ = inputDeps; { var job = new PlayerBulletJob { time_ = Time.GetCurrent(), position_list_ = player_bullet_group_.position_list_, player_bullet_collision_info_list_ = player_bullet_group_.player_bullet_collision_info_list_, destroyable_list_ = player_bullet_group_.destroyable_list_, spark_spawner_ = ECSSparkManager.GetSparkSpawnDataQueue().ToConcurrent(), }; handle_ = job.Schedule(player_bullet_group_.position_list_.Length, 16, handle_); } { var job = new EnemyBulletJob { time_ = Time.GetCurrent(), position_list_ = enemy_bullet_group_.position_list_, enemy_bullet_collision_info_list_ = enemy_bullet_group_.enemy_bullet_collision_info_list_, destroyable_list_ = enemy_bullet_group_.destroyable_list_, spark_spawner_ = ECSSparkManager.GetSparkSpawnDataQueue().ToConcurrent(), }; handle_ = job.Schedule(enemy_bullet_group_.position_list_.Length, 16, handle_); } return(handle_); }
public void Execute(int i) { var random = random_list_[i]; var pos = random.onCube(10f); ECSSparkManager.spawnSpark(command_buffer_, time_, ref pos); random_list_[i] = random; }
void OnEnable() { spark_spawn_data_queue_ = new NativeQueue <SparkSpawnData>(Allocator.Persistent); var entity_manager = World.Active.GetOrCreateManager <EntityManager>(); arche_type_ = entity_manager.CreateArchetype(typeof(Destroyable) , typeof(Position) , typeof(Rotation) , typeof(LocalToWorld) , typeof(Frozen) , typeof(AlivePeriod) , typeof(StartTime) , typeof(Spark) , typeof(MeshInstanceRenderer) ); material_spark_ = new Material(material_.shader); material_spark_.enableInstancing = true; material_spark_.SetColor("_Color", new UnityEngine.Color(0.25f, 1f, 0.5f)); material_enemy_spark_ = new Material(material_.shader); material_enemy_spark_.enableInstancing = true; material_enemy_spark_.SetColor("_Color", new UnityEngine.Color(1f, 0.5f, 0.25f)); const int PARTICLE_NUM = 64; Vector3[] vertices = new Vector3[PARTICLE_NUM * 2]; for (var i = 0; i < PARTICLE_NUM; ++i) { float x = UnityEngine.Random.Range(-1f, 1f); float y = UnityEngine.Random.Range(-1f, 1f); float z = UnityEngine.Random.Range(-1f, 1f); float len2 = x * x + y * y + z * z; float len = Mathf.Sqrt(len2); float rlen = 1.0f / len; var point = new Vector3(x * rlen, y * rlen, z * rlen); vertices[i * 2 + 0] = point; vertices[i * 2 + 1] = point; } var indices = new int[PARTICLE_NUM * 2]; for (var i = 0; i < PARTICLE_NUM * 2; ++i) { indices[i] = i; } mesh_ = new Mesh(); mesh_.vertices = vertices; mesh_.SetIndices(indices, MeshTopology.Lines, 0 /* submesh */); mesh_.bounds = new Bounds(Vector3.zero, Vector3.one * 99999999); instance_ = GameObject.Find("spark_manager").GetComponent <ECSSparkManager>(); }
#pragma warning restore 0169 protected override void OnUpdate() { BulletSystem.Sync(); var spawner = ECSSparkManager.GetSparkSpawnDataQueue(); SparkSpawnData data; while (spawner.TryDequeue(out data)) { ECSSparkManager.spawn(PostUpdateCommands, Time.GetCurrent(), ref data); } }
protected override void OnUpdate() { var time = Time.GetCurrent(); for (var i = 0; i < group_.random_list_.Length; ++i) { var random = group_.random_list_[i]; var pos = random.onCube(10f); var dat0 = new SparkSpawnData { position_ = pos, type_ = 0, }; ECSSparkManager.spawn(PostUpdateCommands, time, ref dat0); group_.random_list_[i] = random; } }