public void Flash(EntityUid target, EntityUid?user, EntityUid?used, float flashDuration, float slowTo, bool displayPopup = true) { var attempt = new FlashAttemptEvent(target, user, used); RaiseLocalEvent(target, attempt); if (attempt.Cancelled) { return; } if (EntityManager.TryGetComponent <FlashableComponent>(target, out var flashable)) { flashable.LastFlash = _gameTiming.CurTime; flashable.Duration = flashDuration / 1000f; // TODO: Make this sane... flashable.Dirty(); } _stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration / 1000f), true, slowTo, slowTo); if (displayPopup && user != null && target != user) { // TODO Resolving the EntityUidhere bad. if (EntityManager.EntityExists(user.Value) && EntityManager.EntityExists(target)) { user.Value.PopupMessage(target, Loc.GetString("flash-component-user-blinds-you", ("user", user.Value))); } } }
public void Flash(EntityUid target, EntityUid?user, EntityUid?used, float flashDuration, float slowTo, bool displayPopup = true, FlashableComponent?flashable = null) { if (!Resolve(target, ref flashable, false)) { return; } var attempt = new FlashAttemptEvent(target, user, used); RaiseLocalEvent(target, attempt, true); if (attempt.Cancelled) { return; } flashable.LastFlash = _gameTiming.CurTime; flashable.Duration = flashDuration / 1000f; // TODO: Make this sane... Dirty(flashable); _stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration / 1000f), true, slowTo, slowTo); if (displayPopup && user != null && target != user && EntityManager.EntityExists(user.Value)) { user.Value.PopupMessage(target, Loc.GetString("flash-component-user-blinds-you", ("user", Identity.Entity(user.Value, EntityManager)))); } }
/// <summary> /// Make an entity vomit, if they have a stomach. /// </summary> public void Vomit(EntityUid uid, float thirstAdded = -40f, float hungerAdded = -40f) { /// Main requirement: You have a stomach var stomachList = _bodySystem.GetComponentsOnMechanisms <StomachComponent>(uid); if (stomachList.Count == 0) { return; } /// Vomiting makes you hungrier and thirstier if (TryComp <HungerComponent>(uid, out var hunger)) { hunger.UpdateFood(hungerAdded); } if (TryComp <ThirstComponent>(uid, out var thirst)) { _thirstSystem.UpdateThirst(thirst, thirstAdded); } // It fully empties the stomach, this amount from the chem stream is relatively small float solutionSize = (Math.Abs(thirstAdded) + Math.Abs(hungerAdded)) / 6; // Apply a bit of slowdown if (TryComp <StatusEffectsComponent>(uid, out var status)) { _stunSystem.TrySlowdown(uid, TimeSpan.FromSeconds(solutionSize), true, 0.5f, 0.5f, status); } var puddle = EntityManager.SpawnEntity("PuddleVomit", Transform(uid).Coordinates); var puddleComp = Comp <PuddleComponent>(puddle); SoundSystem.Play("/Audio/Effects/Diseases/vomiting.ogg", Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.2f).WithVolume(-4f)); _popupSystem.PopupEntity(Loc.GetString("disease-vomit", ("person", uid)), uid, Filter.Pvs(uid)); // Get the solution of the puddle we spawned if (!_solutionSystem.TryGetSolution(puddle, puddleComp.SolutionName, out var puddleSolution)) { return; } // Empty the stomach out into it foreach (var stomach in stomachList) { if (_solutionSystem.TryGetSolution(stomach.Comp.Owner, StomachSystem.DefaultSolutionName, out var sol)) { _solutionSystem.TryAddSolution(puddle, puddleSolution, sol); } } // And the small bit of the chem stream from earlier if (TryComp <BloodstreamComponent>(uid, out var bloodStream)) { var temp = bloodStream.ChemicalSolution.SplitSolution(solutionSize); _solutionSystem.TryAddSolution(puddle, puddleSolution, temp); } }