private void OnStepTrigger(EntityUid uid, MousetrapComponent component, ref StepTriggeredEvent args) { component.IsActive = false; _triggerSystem.Trigger(uid); UpdateVisuals(uid); }
private void HandleTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredEvent args) { // This doesn't use TriggerOnStepTrigger since we don't want to display the popup if nothing happens // and I didn't feel like making an `AfterTrigger` event if (_trigger.Trigger(uid, args.Tripper)) { _popupSystem.PopupCoordinates( Loc.GetString("land-mine-triggered", ("mine", uid)), Transform(uid).Coordinates, Filter.Entities(args.Tripper), PopupType.LargeCaution); } }
private void OnClugUse(EntityUid uid, ClusterGrenadeComponent component, UseInHandEvent args) { if (component.CountDown || (component.GrenadesContainer.ContainedEntities.Count + component.UnspawnedCount) <= 0) { return; } // TODO: Should be an Update loop uid.SpawnTimer((int)(component.Delay * 1000), () => { if (Deleted(component.Owner)) { return; } component.CountDown = true; var delay = 20; var grenadesInserted = component.GrenadesContainer.ContainedEntities.Count + component.UnspawnedCount; var thrownCount = 0; var segmentAngle = 360 / grenadesInserted; while (TryGetGrenade(component, out var grenade)) { var angleMin = segmentAngle * thrownCount; var angleMax = segmentAngle * (thrownCount + 1); var angle = Angle.FromDegrees(_random.Next(angleMin, angleMax)); // var distance = random.NextFloat() * _throwDistance; delay += _random.Next(550, 900); thrownCount++; // TODO: Suss out throw strength grenade.TryThrow(angle.ToVec().Normalized *component.ThrowDistance); grenade.SpawnTimer(delay, () => { if ((!EntityManager.EntityExists(grenade) ? EntityLifeStage.Deleted : MetaData(grenade).EntityLifeStage) >= EntityLifeStage.Deleted) { return; } _trigger.Trigger(grenade, args.User); }); } EntityManager.DeleteEntity(uid); }); args.Handled = true; }
private void HandleTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredEvent args) { if (_trigger.Trigger(uid, args.Tripper)) { _popupSystem.PopupCoordinates( Loc.GetString("land-mine-triggered", ("mine", uid)), Transform(uid).Coordinates, Filter.Entities(args.Tripper)); } if (component.DeleteOnActivate) { QueueDel(uid); } }
/// <summary> /// Immediately transfer all reagents from this entity, to the other entity. /// The source entity will then be acted on by TriggerSystem. /// </summary> /// <param name="source">Source of the solution.</param> /// <param name="target">Target to spike with the solution from source.</param> /// <param name="user">User spiking the target solution.</param> private void TrySpike(EntityUid source, EntityUid target, EntityUid user, RefillableSolutionComponent?spikableTarget = null, SolutionSpikerComponent?spikableSource = null, SolutionContainerManagerComponent?managerSource = null, SolutionContainerManagerComponent?managerTarget = null) { if (!Resolve(source, ref spikableSource, ref managerSource, false) || !Resolve(target, ref spikableTarget, ref managerTarget, false) || !_solutionSystem.TryGetRefillableSolution(target, out var targetSolution, managerTarget, spikableTarget) || !managerSource.Solutions.TryGetValue(spikableSource.SourceSolution, out var sourceSolution)) { return; } if (targetSolution.CurrentVolume == 0 && !spikableSource.IgnoreEmpty) { _popupSystem.PopupEntity(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, Filter.Entities(user)); return; } if (_solutionSystem.TryMixAndOverflow(target, targetSolution, sourceSolution, targetSolution.MaxVolume, out var overflow)) { if (overflow.TotalVolume > 0) { RaiseLocalEvent(target, new SolutionSpikeOverflowEvent(overflow)); } _popupSystem.PopupEntity(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, Filter.Entities(user)); sourceSolution.RemoveAllSolution(); _triggerSystem.Trigger(source); } }
private void OnSignalReceived(EntityUid uid, TriggerOnSignalReceivedComponent component, SignalReceivedEvent args) { _trigger.Trigger(uid); }