void OnEnable() { m_TrafficFieldSystem = World.Active.GetOrCreateManager <TrafficAudioFieldSystem>(); m_FlyBySystem = World.Active.GetOrCreateManager <FlyBySystem>(); m_FlyBySounds = m_FlyBySystem.CreateCollection(); foreach (var clip in audioClips) { m_TrafficFieldSystem.AddDistributedSamplePlayback(clip); } foreach (var clip in vehicleLowIntensities) { if (clip != null) { m_FlyBySystem.AddLowFlyBySound(m_FlyBySounds, clip); } } foreach (var clip in vehicleHighIntensities) { if (clip != null) { m_FlyBySystem.AddHighFlyBySound(m_FlyBySounds, clip); } } m_TrafficFieldSystem.SetFlyBySoundGroup(m_FlyBySounds); }
protected override void OnCreateManager() { m_FlyByBarrier = World.GetOrCreateManager <FlyByInputBarrier>(); m_Barrier = World.GetOrCreateManager <TrafficAudioBarrier>(); m_AudioManager = World.GetOrCreateManager <AudioManagerSystem>(); m_FlyBySystem = World.GetOrCreateManager <FlyBySystem>(); m_FlyByArchetype = EntityManager.CreateArchetype(typeof(FlyBy), typeof(FlyByState), typeof(PositionalFlyByData)); m_SampleEntities = new NativeList <Entity>(Allocator.Persistent); m_FlyByCandidates = new NativeQueue <Entity>(Allocator.Persistent); m_FlyByEntityBuffer = new NativeList <Entity>(Allocator.Persistent); m_Randoms = new NativeArray <Random>(JobsUtility.MaxJobThreadCount, Allocator.Persistent); var seedRandom = new Random((uint)(2 + Time.time * 0xFFFF)); for (int i = 0; i < m_Randoms.Length; ++i) { m_Randoms[i] = new Random(seedRandom.NextUInt()); } m_NewVehiclesGroup = GetComponentGroup( new EntityArchetypeQuery { All = new ComponentType[] { typeof(VehiclePathing), typeof(Translation) }, None = new ComponentType[] { typeof(VehicleEmitter), typeof(PositionalFlyByData) }, Any = Array.Empty <ComponentType>(), }); m_AliveVehiclesGroup = GetComponentGroup( new EntityArchetypeQuery { All = new ComponentType[] { typeof(VehiclePathing), typeof(Translation), typeof(VehicleEmitter), typeof(PositionalFlyByData) }, None = Array.Empty <ComponentType>(), Any = Array.Empty <ComponentType>(), }); m_SamplesGroup = GetComponentGroup(typeof(SamplePlayback), typeof(AdditiveState)); m_DeadVehiclesGroup = GetComponentGroup(typeof(VehicleEmitter), ComponentType.Exclude <VehiclePathing>()); m_FlyByGroup = GetComponentGroup( new EntityArchetypeQuery { All = new ComponentType[] { typeof(FlyBy), typeof(FlyByState) }, None = Array.Empty <ComponentType>(), Any = Array.Empty <ComponentType>(), }); }