private void HandleDown(EntityUid uid, SharedBuckleComponent component, DownAttemptEvent args) { if (component.Buckled) { args.Cancel(); } }
public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true, StandingStateComponent?standingState = null, SharedAppearanceComponent?appearance = null, SharedHandsComponent?hands = null) { // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) { return(false); } // Optional component. Resolve(uid, ref appearance, ref hands, false); if (!standingState.Standing) { return(true); } // This is just to avoid most callers doing this manually saving boilerplate // 99% of the time you'll want to drop items but in some scenarios (e.g. buckling) you don't want to. // We do this BEFORE downing because something like buckle may be blocking downing but we want to drop hand items anyway // and ultimately this is just to avoid boilerplate in Down callers + keep their behavior consistent. if (dropHeldItems && hands != null) { _sharedHandsSystem.DropHandItems(uid, false, hands); } var msg = new DownAttemptEvent(); RaiseLocalEvent(uid, msg, false); if (msg.Cancelled) { return(false); } standingState.Standing = false; standingState.Dirty(); RaiseLocalEvent(uid, new DownedEvent(), false); // Seemed like the best place to put it appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal); // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client if (playSound) { SoundSystem.Play(Filter.Pvs(uid), standingState.DownSoundCollection.GetSound(), uid, AudioHelpers.WithVariation(0.25f)); } return(true); }
public void Down(StandingStateComponent component, bool playSound = true, bool dropHeldItems = true) { if (!component.Standing) { return; } var entity = component.Owner; var uid = entity.Uid; // This is just to avoid most callers doing this manually saving boilerplate // 99% of the time you'll want to drop items but in some scenarios (e.g. buckling) you don't want to. // We do this BEFORE downing because something like buckle may be blocking downing but we want to drop hand items anyway // and ultimately this is just to avoid boilerplate in Down callers + keep their behavior consistent. if (dropHeldItems) { Get <SharedHandsSystem>().DropHandItems(entity, false); } var msg = new DownAttemptEvent(); EntityManager.EventBus.RaiseLocalEvent(uid, msg); if (msg.Cancelled) { return; } component.Standing = false; component.Dirty(); EntityManager.EventBus.RaiseLocalEvent(uid, new DownedEvent()); // Seemed like the best place to put it if (entity.TryGetComponent(out SharedAppearanceComponent? appearance)) { appearance.SetData(RotationVisuals.RotationState, RotationState.Horizontal); } // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client var sound = component.DownSoundCollection; if (playSound && !string.IsNullOrEmpty(sound)) { var file = AudioHelpers.GetRandomFileFromSoundCollection(sound); SoundSystem.Play(Filter.Pvs(entity), file, entity, AudioHelpers.WithVariation(0.25f)); } }
public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true, StandingStateComponent?standingState = null, AppearanceComponent?appearance = null, SharedHandsComponent?hands = null) { // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) { return(false); } // Optional component. Resolve(uid, ref appearance, ref hands, false); if (!standingState.Standing) { return(true); } // This is just to avoid most callers doing this manually saving boilerplate // 99% of the time you'll want to drop items but in some scenarios (e.g. buckling) you don't want to. // We do this BEFORE downing because something like buckle may be blocking downing but we want to drop hand items anyway // and ultimately this is just to avoid boilerplate in Down callers + keep their behavior consistent. if (dropHeldItems && hands != null) { RaiseLocalEvent(uid, new DropHandItemsEvent(), false); } var msg = new DownAttemptEvent(); RaiseLocalEvent(uid, msg, false); if (msg.Cancelled) { return(false); } standingState.Standing = false; Dirty(standingState); RaiseLocalEvent(uid, new DownedEvent(), false); if (!_gameTiming.IsFirstTimePredicted) { return(true); } // Seemed like the best place to put it appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal); // Change collision masks to allow going under certain entities like flaps and tables if (TryComp(uid, out FixturesComponent? fixtureComponent)) { foreach (var(key, fixture) in fixtureComponent.Fixtures) { if ((fixture.CollisionMask & StandingCollisionLayer) == 0) { continue; } standingState.ChangedFixtures.Add(key); fixture.CollisionMask &= ~StandingCollisionLayer; } } // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client // > no longer true with door crushing. There just needs to be a better way to handle audio prediction. if (playSound) { SoundSystem.Play(standingState.DownSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.25f)); } return(true); }