public override IEnumerable <Gizmo> GetGizmos() { var armGizmo = new Command_Toggle { toggleAction = ArmGizmoAction, isActive = () => desiredArmState, icon = Resources.Textures.UIArm, defaultLabel = ArmButtonLabel, defaultDesc = ArmButtonDesc, hotKey = Resources.KeyBinging.RemoteExplosiveArm }; yield return(armGizmo); if (RemoteExplosivesUtility.ChannelsUnlocked()) { var channelGizmo = RemoteExplosivesUtility.MakeChannelGizmo(desiredChannel, currentChannel, ChannelGizmoAction); yield return(channelGizmo); } if (replaceComp != null) { yield return(replaceComp.MakeGizmo()); } if (DebugSettings.godMode) { yield return(new Command_Action { action = () => { if (isArmed) { Disarm(); } else { Arm(); } }, icon = Resources.Textures.UIArm, defaultLabel = "DEV: Toggle armed" }); yield return(new Command_Action { action = () => { Arm(); LightFuse(); }, icon = Resources.Textures.UIDetonate, defaultLabel = "DEV: Detonate now" }); } foreach (var g in base.GetGizmos()) { yield return(g); } }
public void DoDetonation() { wantDetonation = false; if (!GetComp <CompPowerTrader>().PowerOn) { PlayNeedPowerEffect(); return; } SoundDefOf.FlickSwitch.PlayOneShot(this); RemoteExplosivesUtility.LightArmedExplosivesInRange(Position, Map, SignalRange, currentChannel); }
protected override void Detonate() { var map = parentMap; var position = parentPosition; base.Detonate(); if (map == null) { return; } var explosiveProps = props as CompProperties_Explosive; if (explosiveProps == null) { return; } var canAffectThickRoof = RemoteExplosivesUtility.IsEffectiveRoofBreakerPlacement(explosiveProps.explosiveRadius, position, map); bool anyThickRoofAffected = false; foreach (var cell in GenRadial.RadialCellsAround(position, explosiveProps.explosiveRadius, true)) { if (!cell.InBounds(map)) { continue; } var roof = map.roofGrid.RoofAt(cell); if (roof == null || (roof.isThickRoof && !canAffectThickRoof)) { continue; } if (roof.filthLeaving != null) { for (int j = 0; j < RoofFilthAmount; j++) { FilthMaker.MakeFilth(cell, map, roof.filthLeaving); } } if (roof.isThickRoof) { anyThickRoofAffected = true; map.roofGrid.SetRoof(cell, null); var roofCell = cell; HugsLibController.Instance.CallbackScheduler.ScheduleCallback(() => { // delay collapse for more interesting visual effect CollapseRockOnCell(roofCell, map); SoundDefOf.RoofCollapse.PlayOneShot(new TargetInfo(roofCell, map)); }, CollapseDelay.RandomInRange); } } if (anyThickRoofAffected) { Resources.Sound.RemoteMiningCavein.PlayOneShot(new TargetInfo(position, map)); } }
// quick detonation option for drafted pawns public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn) { var opt = RemoteExplosivesUtility.TryMakeDetonatorFloatMenuOption(selPawn, this); if (opt != null) { yield return(opt); } foreach (var option in base.GetFloatMenuOptions(selPawn)) { yield return(option); } }
public override string GetInspectString() { var stringBuilder = new StringBuilder(); stringBuilder.Append(base.GetInspectString()); stringBuilder.AppendLine(); stringBuilder.Append("DetonatorTable_inrange".Translate()); stringBuilder.Append(": " + numViableExplosives); if (RemoteExplosivesUtility.ChannelsUnlocked()) { stringBuilder.AppendLine(); stringBuilder.Append(RemoteExplosivesUtility.GetCurrentChannelInspectString(currentChannel)); } return(stringBuilder.ToString()); }
private void OnGizmoActivation() { if (lastActivationTick + ActivationCooldownTicks >= Find.TickManager.TicksGame) { return; } lastActivationTick = Find.TickManager.TicksGame; SoundDefOf.FlickSwitch.PlayOneShot(Wearer); RemoteExplosivesUtility.LightArmedExplosivesInRange(Wearer.Position, Wearer.Map, SignalRange, RemoteExplosivesUtility.RemoteChannel.White); numUsesLeft--; if (numUsesLeft <= 0) { Destroy(DestroyMode.KillFinalize); Messages.Message(DetonatorBrokeMessage, new TargetInfo(Wearer), MessageSound.Negative); } }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot) { var effectiveRadius = RemoteExplosivesUtility.TryGetExplosiveRadius(def); if (effectiveRadius <= 0) { return; } var roofGrid = Map.roofGrid; effectiveRadiusCells.Clear(); overheadMountainCells.Clear(); var effectiveRadiusNumCells = GenRadial.NumCellsInRadius(effectiveRadius); var roofDisplayRadiusNumCells = GenRadial.NumCellsInRadius(effectiveRadius + AdditionalRoofDisplayRadius); // collect cells to display for (int i = 0; i < roofDisplayRadiusNumCells; i++) { var cell = center + GenRadial.RadialPattern[i]; if (!cell.InBounds(Map)) { continue; } var roof = roofGrid.RoofAt(cell); if (roof != null && roof.isThickRoof) { overheadMountainCells.Add(cell); } var cellInsideEffectiveRadius = i < effectiveRadiusNumCells; if (cellInsideEffectiveRadius) { effectiveRadiusCells.Add(cell); } } if (overheadMountainCells.Count > 0 && Find.Selector.NumSelected <= 1) // don't draw overlay when multple charges are selected { GenDraw.DrawFieldEdges(overheadMountainCells, Color.white); } var effectiveRadiusColor = RemoteExplosivesUtility.IsEffectiveRoofBreakerPlacement(effectiveRadius, center, Map) ? EffectivePlacementColor : IneffectivePlacementColor; GenDraw.DrawFieldEdges(effectiveRadiusCells, effectiveRadiusColor); }
public override string GetInspectString() { var stringBuilder = new StringBuilder(); stringBuilder.Append(base.GetInspectString()); if (IsArmed) { stringBuilder.Append("TrapArmed".Translate()); } else { stringBuilder.Append("TrapNotArmed".Translate()); } if (RemoteExplosivesUtility.ChannelsUnlocked()) { stringBuilder.AppendLine(); stringBuilder.Append(RemoteExplosivesUtility.GetCurrentChannelInspectString(currentChannel)); } return(stringBuilder.ToString()); }
public void DoSwitch() { if (isArmed != desiredArmState) { if (!isArmed) { Arm(); } else { Disarm(); } } if (desiredChannel != currentChannel) { currentChannel = desiredChannel; Resources.Sound.RemoteChannelChange.PlayOneShot(this); } RemoteExplosivesUtility.UpdateSwitchDesignation(this); }
public override IEnumerable <Gizmo> GetGizmos() { var detonateGizmo = new Command_Toggle { toggleAction = DetonateGizmoAction, isActive = () => wantDetonation, icon = Resources.Textures.UIDetonate, defaultLabel = DetonateButtonLabel, defaultDesc = DetonateButtonDesc, hotKey = Resources.KeyBinging.RemoteTableDetonate }; yield return(detonateGizmo); if (RemoteExplosivesUtility.ChannelsUnlocked()) { if (hasChannelsComponent) { var channelGizmo = RemoteExplosivesUtility.MakeChannelGizmo(currentChannel, currentChannel, ChannelGizmoAction); yield return(channelGizmo); } else { var componentGizmo = new Command_Toggle { toggleAction = ComponentGizmoAction, isActive = () => wantChannelsComponent, icon = Resources.Textures.UIChannelComponent, defaultLabel = InstallComponentButtonLabel, defaultDesc = InstallComponentButtonDesc }; yield return(componentGizmo); } } foreach (var g in base.GetGizmos()) { yield return(g); } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); Resources.Graphics.FlareOverlayStrong.drawSize = Resources.Graphics.FlareOverlayNormal.drawSize = def.graphicData.drawSize; RemoteExplosivesUtility.UpdateSwitchDesignation(this); explosiveComp = GetComp <CompCustomExplosive>(); replaceComp = GetComp <CompAutoReplaceable>(); if (replaceComp != null) { replaceComp.DisableGizmoAutoDisplay(); } if (justCreated) { if (CustomProps.startsArmed) { Arm(); } justCreated = false; } }
private void ChannelGizmoAction() { currentChannel = RemoteExplosivesUtility.GetNextChannel(currentChannel); UpdateNumArmedExplosivesInRange(); }
private void UpdateNumArmedExplosivesInRange() { numViableExplosives = RemoteExplosivesUtility.FindArmedExplosivesInRange(Position, Map, SignalRange, currentChannel).Count; }
private void ArmGizmoAction() { desiredArmState = !desiredArmState; RemoteExplosivesUtility.UpdateSwitchDesignation(this); }
private void ChannelGizmoAction() { desiredChannel = RemoteExplosivesUtility.GetNextChannel(desiredChannel); RemoteExplosivesUtility.UpdateSwitchDesignation(this); }