private void OnGetState(EntityUid uid, FlyBySoundComponent component, ref ComponentGetState args) { args.State = new FlyBySoundComponentState() { Sound = component.Sound, Range = component.Range, }; }
private void OnShutdown(EntityUid uid, FlyBySoundComponent component, ComponentShutdown args) { if (!TryComp <PhysicsComponent>(uid, out var body)) { return; } _fixtures.DestroyFixture(body, FlyByFixture); }
private void OnHandleState(EntityUid uid, FlyBySoundComponent component, ref ComponentHandleState args) { if (args.Current is not FlyBySoundComponentState state) { return; } component.Sound = state.Sound; component.Range = state.Range; }
private void OnCollide(EntityUid uid, FlyBySoundComponent component, StartCollideEvent args) { var attachedEnt = _player.LocalPlayer?.ControlledEntity; // If it's not our ent or we shot it. if (attachedEnt == null || args.OtherFixture.Body.Owner != attachedEnt || TryComp <ProjectileComponent>(args.OurFixture.Body.Owner, out var projectile) && projectile.Shooter == attachedEnt) { return; } if (args.OurFixture.ID != FlyByFixture || !_random.Prob(component.Prob)) { return; } SoundSystem.Play(component.Sound.GetSound(), Filter.Local(), uid, component.Sound.Params); }
private void OnStartup(EntityUid uid, FlyBySoundComponent component, ComponentStartup args) { if (!TryComp <PhysicsComponent>(uid, out var body)) { return; } var shape = new PhysShapeCircle() { Radius = component.Range, }; var fixture = new Fixture(body, shape) { Hard = false, ID = FlyByFixture, CollisionLayer = (int)CollisionGroup.MobMask, }; _fixtures.TryCreateFixture(body, fixture); }