private void OnSoundPlay(AudioClip clip, AudioCueConfiguration config, Vector2 position) { SoundEmitter emitter = _factory.Create(); emitter.PlayClip(clip, config, position); emitter.OnPlayingEnd += OnPlayingEnd; }
public void TurnOn() { if (!Activated) { doEffect(() => touchSfx.Play(hitSound)); Activated = true; // animation doEffect(() => { wiggler.Start(); for (int i = 0; i < 32; i++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); level.Particles.Emit(TouchSwitch.P_FireWhite, Position + Calc.AngleToVector(num, 6f), num); } }); icon.Rate = 4f; HandleCollectedFlagTouchSwitch(flag, inverted, persistent, level, id, allTouchSwitchesInRoom, allMovingFlagTouchSwitchesInRoom, () => doEffect(() => { SoundEmitter.Play(completeSoundFromScene); Add(new SoundSource(completeSoundFromSwitch)); })); } }
protected override void Begin() { base.Begin(); if (this.eCratePush == null || this.eCratePush.Dead) { this.eCratePush = SoundEffectExtensions.EmitAt(this.sCratePush, this.PlayerManager.PushedInstance.Center, true); } else { this.eCratePush.Cue.Resume(); } if (this.eGomezPush == null || this.eGomezPush.Dead) { this.eGomezPush = SoundEffectExtensions.EmitAt(this.sGomezPush, this.PlayerManager.Position, true); } else { this.eGomezPush.Cue.Resume(); } if (this.LevelManager.PickupGroups.TryGetValue(this.PlayerManager.PushedInstance, out this.pickupGroup)) { return; } this.pickupGroup = (TrileGroup)null; }
SoundEmitterOnPlay_string(On.Celeste.SoundEmitter.orig_Play_string orig, string sfx) { SoundEmitter soundEmitter = orig(sfx); soundEmitter.TrySetEntityId2(sfx); return(soundEmitter); }
private void TryInitialize() { this.Visible = this.Enabled = this.LevelManager.Name == "PYRAMID"; this.Clear(); if (!this.Enabled) { return; } this.MotherCubeAo = this.LevelManager.ArtObjects[217]; this.OriginalPosition = this.MotherCubeAo.Position; this.RaysMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/smooth_ray")), Blending = new BlendingMode?(BlendingMode.Additive), SamplerState = SamplerState.AnisotropicClamp, DepthWrites = false, AlwaysOnTop = true }; this.FlareMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/flare_alpha")), Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.AnisotropicClamp, DepthWrites = false, AlwaysOnTop = true }; this.FlareMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, true); this.sRotationDrone = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/Pyramid/MothercubeRotateDrone"); this.sWhiteOut = this.CMProvider.Global.Load <SoundEffect>("Sounds/Ending/Pyramid/WhiteOut"); this.eRotationDrone = SoundEffectExtensions.EmitAt(this.sRotationDrone, this.OriginalPosition, true); }
public void TurnOn() { if (!timed) { if (!Switch.Activated) { touchSfx.Play("event:/game/general/touchswitch_any", null, 0f); if (Switch.Activate()) { SoundEmitter.Play("event:/game/general/touchswitch_last_oneshot"); base.Add(new SoundSource("event:/game/general/touchswitch_last_cutoff")); } } } else { if (!TimedSwitch.Activated) { touchSfx.Play("event:/game/general/touchswitch_any", null, 0f); if (TimedSwitch.Activate()) { SoundEmitter.Play("event:/game/general/touchswitch_last_oneshot"); base.Add(new SoundSource("event:/game/general/touchswitch_last_cutoff")); } } } }
protected override bool Act(TimeSpan elapsed) { int frame = this.PlayerManager.Animation.Timing.Frame; if (this.lastFrame != frame) { if (frame == 0) { this.eLast = SoundEffectExtensions.EmitAt(this.sBegin, this.PlayerManager.Position); } else if (frame == 6) { this.eLast = SoundEffectExtensions.EmitAt(this.sMouthOpen, this.PlayerManager.Position); } else if (frame == 9) { this.eLast = SoundEffectExtensions.EmitAt(this.sMouthClose, this.PlayerManager.Position); } } this.lastFrame = frame; if (this.eLast != null && !this.eLast.Dead) { this.eLast.Position = this.PlayerManager.Position; } return(true); }
public override void Update(GameTime gameTime) { if (this.GameState.Loading) { return; } if (FezMath.AlmostEqual(this.PlayerManager.Velocity.Y, 0.0f)) { if (this.eFall != null && !this.eFall.Dead) { this.eFall.FadeOutAndDie(0.1f); this.eFall = (SoundEmitter)null; } } else { if (this.eFall == null || this.eFall.Dead) { this.eFall = SoundEffectExtensions.EmitAt(this.sFall, this.PlayerManager.Position, true, 0.0f, 0.0f); } this.eFall.Position = this.PlayerManager.Position; this.eFall.VolumeFactor = Easing.EaseIn((double)FezMath.Saturate((float)(-(double)this.PlayerManager.Velocity.Y / 0.400000005960464)), EasingType.Quadratic); } base.Update(gameTime); }
void ICmpInitializable.OnInit(Component.InitContext context) { if (context == InitContext.Activate && DualityApp.ExecContext != DualityApp.ExecutionContext.Editor) { AnimSpriteRenderer r = this.GameObj.Renderer as AnimSpriteRenderer; SoundEmitter s = this.GameObj.GetComponent <SoundEmitter>(); Transform t = this.GameObj.Transform; r.AnimDuration = MathF.RoundToInt(0.4f * r.AnimDuration * MathF.Rnd.NextFloat(0.8f, 1.25f) * MathF.Sqrt(intensity)); t.RelativeScale *= MathF.Sqrt(intensity); t.RelativeAngle = MathF.Rnd.NextFloat(MathF.RadAngle360); t.RelativeVel = new Vector3(MathF.Rnd.NextVector2(1.0f)); ContentRef <Sound> soundRes = ContentRef <Sound> .Null; switch (MathF.Rnd.Next(5)) { case 0: soundRes = GameRes.Data.Sound.Explo1_Sound; break; case 1: soundRes = GameRes.Data.Sound.Explo2_Sound; break; case 2: soundRes = GameRes.Data.Sound.Explo3_Sound; break; case 3: soundRes = GameRes.Data.Sound.Explo4_Sound; break; case 4: soundRes = GameRes.Data.Sound.Explo5_Sound; break; } SoundEmitter.Source source = new SoundEmitter.Source(soundRes, false); source.Volume = MathF.Rnd.NextFloat(0.9f, 1.15f) * MathF.Sqrt(intensity); source.Pitch = MathF.Rnd.NextFloat(0.8f, 1.25f) / MathF.Sqrt(intensity); source.Paused = false; s.Sources.Add(source); } }
private void TryInitialize() { this.TrackedStones.Clear(); this.GrabSound = (SoundEffect)null; this.TurnLeft = (SoundEffect)null; this.TurnRight = (SoundEffect)null; this.sRumble = (SoundEffect)null; this.eRumble = (SoundEmitter)null; foreach (ArtObjectInstance ao in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values) { if (ao.ArtObject.ActorType == ActorType.Tombstone) { this.TrackedStones.Add(new TombstonesHost.TombstoneState(this, ao)); } } this.SkullAo = Enumerable.SingleOrDefault <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObjectName == "GIANT_SKULLAO")); this.Enabled = this.Visible = this.TrackedStones.Count > 0 && this.SkullAo != null; if (!this.Enabled) { return; } int index = this.SkullAo.ActorSettings.AttachedGroup.Value; this.SkullTopLayer = Enumerable.ToArray <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Groups[index].Triles, (Func <TrileInstance, bool>)(x => x.Trile.Faces[FaceOrientation.Back] == CollisionType.TopOnly))); this.SkullAttachedTriles = Enumerable.ToArray <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Groups[index].Triles, (Func <TrileInstance, bool>)(x => x.Trile.Immaterial))); this.SkullAttachedTrilesOriginalStates = Enumerable.ToArray <Vector4>(Enumerable.Select <TrileInstance, Vector4>((IEnumerable <TrileInstance>) this.SkullAttachedTriles, (Func <TrileInstance, Vector4>)(x => new Vector4(x.Position, x.Phi)))); this.GrabSound = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/GrabLever"); this.TurnLeft = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Graveyard/TombRotateLeft"); this.TurnRight = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Graveyard/TombRotateRight"); this.sRumble = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/Rumble"); this.eRumble = SoundEffectExtensions.Emit(this.sRumble, true, true); this.SkullRotates = Enumerable.Count <TombstonesHost.TombstoneState>((IEnumerable <TombstonesHost.TombstoneState>) this.TrackedStones, (Func <TombstonesHost.TombstoneState, bool>)(x => x.LastViewpoint == this.TrackedStones[0].LastViewpoint)) < 4; this.OriginalRotation = this.SkullAo.Rotation * Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f); }
public override bool Convert(ConvertOperation convert) { List <Sound> availData = convert.Perform <Sound>().ToList(); // Generate objects foreach (Sound snd in availData) { if (convert.IsObjectHandled(snd)) { continue; } GameObject gameobj = convert.Result.OfType <GameObject>().FirstOrDefault(); SoundEmitter emitter = convert.Result.OfType <SoundEmitter>().FirstOrDefault(); if (emitter == null && gameobj != null) { emitter = gameobj.GetComponent <SoundEmitter>(); } if (emitter == null) { emitter = new SoundEmitter(); } convert.SuggestResultName(emitter, snd.Name); SoundEmitter.Source source = new SoundEmitter.Source(snd); emitter.Sources.Add(source); convert.AddResult(emitter); convert.MarkObjectHandled(snd); } return(false); }
private void InitSuckBlocks() { this.HostingVolumes.Clear(); this.TrackedSuckBlocks.Clear(); this.highlightPlanes = (List <BackgroundPlane>)null; this.eCratePush = this.eSuck = (SoundEmitter)null; foreach (TrileGroup group in (IEnumerable <TrileGroup>) this.LevelManager.Groups.Values) { if (group.ActorType == ActorType.SuckBlock) { TrileInstance instance = Enumerable.First <TrileInstance>((IEnumerable <TrileInstance>)group.Triles); if (instance.ActorSettings.HostVolume.HasValue) { this.TrackedSuckBlocks.Add(new SuckBlocksHost.SuckBlockState(instance, group)); SuckBlocksHost.EnableTrile(instance); this.HostingVolumes.Add(this.LevelManager.Volumes[instance.ActorSettings.HostVolume.Value]); } } } if (this.TrackedSuckBlocks.Count <= 0) { return; } this.eCratePush = SoundEffectExtensions.EmitAt(this.CMProvider.Global.Load <SoundEffect>("Sounds/Gomez/PushPickup"), Vector3.Zero, true, true); this.highlightPlanes = new List <BackgroundPlane>(); }
void StartEmitter(SoundEmitter emitter) { var soundDef = emitter.soundDef; var source = emitter.source; StartSource(source, soundDef); }
protected override void Begin() { base.Begin(); if (this.panicEmitter != null) { this.panicEmitter.FadeOutAndDie(0.0f); this.panicEmitter = (SoundEmitter)null; } (this.panicEmitter = SoundEffectExtensions.EmitAt(this.panicSound, this.PlayerManager.Position)).NoAttenuation = true; if (this.PlayerManager.CarriedInstance != null) { this.PlayerManager.CarriedInstance.PhysicsState.Velocity = this.PlayerManager.Velocity * 0.95f; this.PlayerManager.CarriedInstance = (TrileInstance)null; } this.WasConstrained = this.CameraManager.Constrained; if (this.WasConstrained) { this.OldConstrainedCenter = this.CameraManager.Center; } this.CameraManager.Constrained = true; int num; if (FreeFall.EndCaps.TryGetValue(this.LevelManager.Name, out num)) { this.CapEnd = new int?(num); } else { this.CapEnd = new int?(); } }
protected override void Begin() { this.sinceStarted = TimeSpan.Zero; this.eTurnAway = SoundEffectExtensions.EmitAt(this.sTurnAway, this.PlayerManager.Position); this.reverse = false; this.lastFrame = -1; }
public void End() { if (!this.iPolytron.Dead) { this.iPolytron.FadeOutAndDie(0.1f); } this.iPolytron = (SoundEmitter)null; }
public MCSE(byte[] chunkBytes, MCNK parentChunk) : base(chunkBytes) { for (int i = 0; i < parentChunk.NumberSoundEmitters; i++) { SoundEmitters[i] = new SoundEmitter(this); } Close(); }
/* ----------------------- DelayedSyncTo() have to wait until the end of frame to do proper sync'ing ----------------------- */ IEnumerator DelayedSyncTo( SoundEmitter other, float fadeTime, float toVolume ) { yield return new WaitForEndOfFrame(): //audio.timeSamples = other.GetSampleTime(): //audio.time = Mathf.Min( Mathf.Max( 0.0f, other.time - other.length ), other.time ): audioSource.time = other.time: audioSource.Play(): FadeTo( fadeTime, toVolume ): }
public SoundEmitter AddEmitter(SoundEmitter emitter) { if (!SoundManager.NoMoreSounds) { this.Emitters.Add(emitter); } return(emitter); }
public void End() { if (!iPolytron.Dead) { iPolytron.FadeOutAndDie(0.1f); } iPolytron = null; }
protected override void End() { if (this.eLast != null && !this.eLast.Dead) { this.eLast.Cue.Stop(false); this.eLast = (SoundEmitter)null; } base.End(); }
public ValveState(ValvesBoltsTimeswitchesHost host, ArtObjectInstance ao) { ServiceHelper.InjectServices((object)this); this.Host = host; this.ArtObject = ao; this.IsBolt = this.ArtObject.ArtObject.ActorType == ActorType.BoltHandle; this.IsTimeswitch = this.ArtObject.ArtObject.ActorType == ActorType.Timeswitch; BoundingBox boundingBox = new BoundingBox(this.ArtObject.Position - this.ArtObject.ArtObject.Size / 2f, this.ArtObject.Position + this.ArtObject.ArtObject.Size / 2f); if (this.ArtObject.ActorSettings.AttachedGroup.HasValue) { this.AttachedGroup = this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value]; } if (this.IsTimeswitch) { this.eTimeswitchWindBack = SoundEffectExtensions.EmitAt(this.Host.TimeswitchWindBackSound, ao.Position, true, true); foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values) { if (artObjectInstance != ao && artObjectInstance.ArtObject.ActorType == ActorType.TimeswitchMovingPart) { BoundingBox box = new BoundingBox(artObjectInstance.Position - artObjectInstance.ArtObject.Size / 2f, artObjectInstance.Position + artObjectInstance.ArtObject.Size / 2f); if (boundingBox.Intersects(box)) { this.TimeswitchScrewAo = artObjectInstance; break; } } } } int num1; if (!this.IsBolt && !this.IsTimeswitch && (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0)) { int num2 = Math.Abs(num1); int num3 = Math.Sign(num1); for (int index = 0; index < num2; ++index) { this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)num3); } } if (this.IsBolt) { foreach (TrileInstance instance in this.AttachedGroup.Triles) { instance.PhysicsState = new InstancePhysicsState(instance); } } foreach (Volume volume in (IEnumerable <Volume>) this.LevelManager.Volumes.Values) { Vector3 vector3 = FezMath.Abs(volume.To - volume.From); if ((double)vector3.X == 3.0 && (double)vector3.Z == 3.0 && ((double)vector3.Y == 1.0 && boundingBox.Contains(volume.BoundingBox) == ContainmentType.Contains)) { this.CenterOffset = (volume.From + volume.To) / 2f - this.ArtObject.Position; break; } } }
private static SoundEmitter SoundEmitterOnPlay_string_Entity_Nullable1( On.Celeste.SoundEmitter.orig_Play_string_Entity_Nullable1 orig, string sfx, Entity follow, Vector2?offset) { SoundEmitter soundEmitter = orig(sfx, follow, offset); soundEmitter.TrySetEntityId2(sfx); return(soundEmitter); }
private void turnOn() { if (!activated) { touchSfx.Play("event:/game/general/touchswitch_any"); activated = true; // animation wiggler.Start(); for (int i = 0; i < 32; i++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); level.Particles.Emit(TouchSwitch.P_FireWhite, Position + Calc.AngleToVector(num, 6f), num); } icon.Rate = 4f; if (persistent) { // this switch is persistent. save its activation in the session. level.Session.SetFlag(flag + "_switch" + id, true); } if ((SpringCollab2020MapDataProcessor.FlagTouchSwitches.Count <= level.Session.Area.ID || SpringCollab2020MapDataProcessor.FlagTouchSwitches[level.Session.Area.ID][(int)level.Session.Area.Mode][flag] .All(touchSwitchID => touchSwitchID.Level == level.Session.Level || level.Session.GetFlag(flag + "_switch" + touchSwitchID.ID))) && allTouchSwitchesInRoom.All(touchSwitch => touchSwitch.activated)) { // all switches in the room are enabled, and all session flags for switches outside the room are enabled. // so, the group is complete. foreach (FlagTouchSwitch touchSwitch in allTouchSwitchesInRoom) { touchSwitch.finish(); } SoundEmitter.Play("event:/game/general/touchswitch_last_oneshot"); Add(new SoundSource("event:/game/general/touchswitch_last_cutoff")); // trigger associated switch gate(s). foreach (FlagSwitchGate switchGate in Scene.Tracker.GetEntities <FlagSwitchGate>().OfType <FlagSwitchGate>()) { if (switchGate.Flag == flag) { switchGate.Trigger(); } } // if all the switches are persistent, the flag it's setting is persistent. if (allTouchSwitchesInRoom.All(touchSwitch => touchSwitch.persistent)) { level.Session.SetFlag(flag, true); } } } }
SoundEmitter AllocEmitter() { // Look for unused emitter foreach (var e in m_Emitters) { if (!e.playing) { e.seqId = m_SequenceId++; return(e); } } // Hunt down one emitter to kill SoundEmitter emitter = null; float distance = float.MinValue; var listenerPos = m_CurrentListener != null ? m_CurrentListener.transform.position : Vector3.zero; foreach (var e in m_Emitters) { var s = e.source; // Skip looping if (s.loop) { continue; } // Pick closest; assuming 2d sounds very close! var dist = 0.0f; if (s.spatialBlend > 0.0f) { dist = (s.transform.position - listenerPos).magnitude; // if tracking another object assume closer var t = s.transform; if (t.parent != m_SourceHolder.transform) { dist *= 0.5f; } } if (dist > distance) { distance = dist; emitter = e; } } if (emitter != null) { emitter.Kill(); emitter.seqId = m_SequenceId++; return(emitter); } GameDebug.Log("Unable to allocate sound emitter!"); return(null); }
protected override void End() { base.End(); if (this.lastSpecialIdleSound == null || this.lastSpecialIdleSound.Dead) { return; } this.lastSpecialIdleSound.FadeOutAndDie(0.1f); this.lastSpecialIdleSound = (SoundEmitter)null; }
private void StopAndCleanEmitter(SoundEmitter soundEmitter) { if (!soundEmitter.IsLooping()) { soundEmitter.OnSoundFinishedPlaying -= OnSoundEmitterFinishedPlaying; } soundEmitter.Stop(); _pool.Return(soundEmitter); }
public SoundEmitter PlaySound(AudioClip clip, SoundEmitterSettings settings, Vector3 position = default) { SoundEmitter soundEmitter = GetSoundEmitter(); if (soundEmitter != null) { soundEmitter.PlaySound(clip, settings, position); } return(soundEmitter); }
void ICmpUpdatable.OnUpdate() { AnimSpriteRenderer r = this.GameObj.Renderer as AnimSpriteRenderer; SoundEmitter s = this.GameObj.GetComponent <SoundEmitter>(); if (!r.IsAnimationRunning && s.Sources.All(src => src.Instance == null || src.Instance.Disposed)) { this.GameObj.DisposeLater(); } }
public static void CreateEmitter(Vector3 pos, float SoundPower = 10, bool isChild = false) { Location l = TerrainBoard.transformPositionToGrid(pos); SoundEmitter e = new SoundEmitter(l, SoundPower); e.ChildCount = 0; //Emitters[l] = e; toBeCreated.Enqueue(e); }
// Use this for initialization void Start() { playedSound = false; soundEmitter = GetComponent<SoundEmitter>(); buttonAnimator = GetComponent<Animator>(); buttonLight = GetComponent<Light>(); trigger = GetComponent<Trigger>(); particleSystem = GetComponent<ParticleSystem>(); ////Was moved here since the sM made it not work! //Set the color of the interactable button both background light and particles to the correct user. setButtonColor( new bool[3]{ trigger.bluePlayerRequired, trigger.redPlayerRequired, trigger.greenPlayerRequired }); //particleSystem.Play(); }