private void OnInit(EntityUid uid, NukeComponent component, ComponentInit args) { component.RemainingTime = component.Timer; _itemSlots.AddItemSlot(uid, component.Name, component.DiskSlot); UpdateStatus(uid, component); UpdateUserInterface(uid, component); }
private void OnEjectButtonPressed(EntityUid uid, NukeComponent component, NukeEjectMessage args) { if (!component.DiskSlot.HasItem) { return; } _itemSlots.TryEjectToHands(uid, component.DiskSlot, args.Session.AttachedEntity); }
private void OnEnterButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadEnterMessage args) { if (component.Status != NukeStatus.AWAIT_CODE) { return; } UpdateStatus(uid, component); UpdateUserInterface(uid, component); }
private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args) { // cancel any anchor attempt if armed if (component.Status == NukeStatus.ARMED) { var msg = Loc.GetString("nuke-component-cant-anchor"); _popups.PopupEntity(msg, uid, Filter.Entities(args.User)); args.Cancel(); } }
private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args) { // cancel any anchor attempt without nuke disk if (!component.DiskSlot.HasItem) { var msg = Loc.GetString("nuke-component-cant-anchor"); _popups.PopupEntity(msg, uid, Filter.Entities(args.User)); args.Cancel(); } }
private void OnClearButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadClearMessage args) { PlaySound(uid, component.KeypadPressSound, 0f, component); if (component.Status != NukeStatus.AWAIT_CODE) { return; } component.EnteredCode = ""; UpdateUserInterface(uid, component); }
private void OnItemSlotChanged(EntityUid uid, NukeComponent component, ContainerModifiedMessage args) { if (!component.Initialized) { return; } if (args.Container.ID != component.DiskSlot.ID) { return; } UpdateStatus(uid, component); UpdateUserInterface(uid, component); }
private void OnArmButtonPressed(EntityUid uid, NukeComponent component, NukeArmedMessage args) { if (!component.DiskSlot.HasItem) { return; } if (component.Status == NukeStatus.AWAIT_ARM) { ArmBomb(uid, component); } else { DisarmBomb(uid, component); } }
private void OnKeypadButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadMessage args) { PlaySound(uid, component.KeypadPressSound, 0.125f, component); if (component.Status != NukeStatus.AWAIT_CODE) { return; } if (component.EnteredCode.Length >= _codes.Code.Length) { return; } component.EnteredCode += args.Value.ToString(); UpdateUserInterface(uid, component); }
private void DisarmBombDoafter(EntityUid uid, EntityUid user, NukeComponent nuke) { nuke.DisarmCancelToken = new(); var doafter = new DoAfterEventArgs(user, nuke.DisarmDoafterLength, nuke.DisarmCancelToken.Value, uid) { TargetCancelledEvent = new NukeDisarmCancelledEvent(), TargetFinishedEvent = new NukeDisarmSuccessEvent(), BreakOnDamage = true, BreakOnStun = true, BreakOnTargetMove = true, BreakOnUserMove = true, NeedHand = true, }; _doAfterSystem.DoAfter(doafter); _popups.PopupEntity(Loc.GetString("nuke-component-doafter-warning"), user, Filter.Entities(user), PopupType.LargeCaution); }
private async void OnAnchorButtonPressed(EntityUid uid, NukeComponent component, NukeAnchorMessage args) { if (!component.DiskSlot.HasItem) { return; } if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform)) { return; } // manually set transform anchor (bypassing anchorable) // todo: it will break pullable system transform.Coordinates = transform.Coordinates.SnapToGrid(); transform.Anchored = !transform.Anchored; UpdateUserInterface(uid, component); }
private void OnArmButtonPressed(EntityUid uid, NukeComponent component, NukeArmedMessage args) { if (!component.DiskSlot.HasItem) { return; } if (component.Status == NukeStatus.AWAIT_ARM && Transform(uid).Anchored) { ArmBomb(uid, component); } else { if (args.Session.AttachedEntity is not { } user) { return; } DisarmBombDoafter(uid, user, component); } }
private void OnAnchorAttempt(EntityUid uid, NukeComponent component, AnchorAttemptEvent args) { CheckAnchorAttempt(uid, component, args); }
private void OnRemove(EntityUid uid, NukeComponent component, ComponentRemove args) { _itemSlots.RemoveItemSlot(uid, component.DiskSlot); }
private void OnDisarmSuccess(EntityUid uid, NukeComponent component, NukeDisarmSuccessEvent args) { component.DisarmCancelToken = null; DisarmBomb(uid, component); }
private void OnDisarmCancelled(EntityUid uid, NukeComponent component, NukeDisarmCancelledEvent args) { component.DisarmCancelToken = null; }
private void OnAnchorChanged(EntityUid uid, NukeComponent component, ref AnchorStateChangedEvent args) { UpdateUserInterface(uid, component); }
private void NukeDisarmedAudio(NukeComponent component) { _soundSystem.PlayGlobalOnStation(component.Owner, component.DisarmSound.GetSound()); _soundSystem.StopStationEventMusic(component.Owner, StationEventMusicType.Nuke); }
private void NukeArmedAudio(NukeComponent component) { _soundSystem.PlayGlobalOnStation(component.Owner, component.ArmSound.GetSound()); }