private void DrawFlareOverlay(bool useStrong)
        {
            ticksSinceFlare = 0;
            var overlay = useStrong ? Resources.Graphics.FlareOverlayStrong : Resources.Graphics.FlareOverlayNormal;

            RemoteTechUtility.DrawFlareOverlay(overlay, DrawPos, BlinkerData);
        }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            var armGizmo = new Command_Toggle {
                toggleAction = ArmGizmoAction,
                isActive     = () => desiredArmState,
                icon         = Resources.Textures.rxUIArm,
                defaultLabel = ArmButtonLabel,
                defaultDesc  = ArmButtonDesc,
                hotKey       = Resources.KeyBinging.rxArm
            };

            yield return(armGizmo);

            if (channelsComp != null)
            {
                channelsComp.Configure(true, false, false, RemoteTechUtility.GetChannelsUnlockLevel());
                var gz = channelsComp.GetChannelGizmo();
                if (gz != null)
                {
                    yield return(gz);
                }
            }

            if (replaceComp != null)
            {
                yield return(replaceComp.MakeGizmo());
            }

            if (DebugSettings.godMode)
            {
                yield return(new Command_Action {
                    action = () => {
                        if (isArmed)
                        {
                            Disarm();
                        }
                        else
                        {
                            Arm();
                        }
                    },
                    icon = Resources.Textures.rxUIArm,
                    defaultLabel = "DEV: Toggle armed"
                });

                yield return(new Command_Action {
                    action = () => {
                        Arm();
                        LightFuse();
                    },
                    icon = Resources.Textures.rxUIDetonate,
                    defaultLabel = "DEV: Detonate now"
                });
            }

            foreach (var g in base.GetGizmos())
            {
                yield return(g);
            }
        }
 protected override void ReceiveCompSignal(string signal)
 {
     base.ReceiveCompSignal(signal);
     if (signal == CompUpgrade.UpgradeCompleteSignal)
     {
         ConfigureChannelComp();
     }
     if (signal == CompChannelSelector.ChannelChangedSignal)
     {
         RemoteTechUtility.ReportPowerUse(this, 2f);
     }
 }
        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   = RemoteTechUtility.IsEffectiveRoofBreakerPlacement(explosiveProps.explosiveRadius, position, map, false);
            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.TryMakeFilth(cell, map, roof.filthLeaving);
                    }
                }
                if (roof.isThickRoof)
                {
                    anyThickRoofAffected = true;
                    var roofCell = cell;
                    HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(() => {                     // delay collapse for more interesting visual effect
                        CollapseRockOnCell(roofCell, map);
                        SoundDefOf.Roof_Collapse.PlayOneShot(new TargetInfo(roofCell, map));
                    }, CollapseDelay.RandomInRange);
                }
                map.roofGrid.SetRoof(cell, null);
            }
            if (anyThickRoofAffected)
            {
                Resources.Sound.rxMiningCavein.PlayOneShot(new TargetInfo(position, map));
            }
        }
 public void DoDetonation()
 {
     wantDetonation = false;
     if (!IsPowered)
     {
         PlayNeedPowerEffect();
         return;
     }
     RemoteTechUtility.ReportPowerUse(this, 20f);
     SoundDefOf.FlickSwitch.PlayOneShot(this);
     RemoteTechUtility.TriggerReceiversInNetworkRange(this, channels?.Channel ?? RemoteTechUtility.DefaultChannel);
 }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            var ownEffectiveRadius = RemoteTechUtility.TryGetExplosiveRadius(def);
            var map = Find.CurrentMap;

            if (map == null || ownEffectiveRadius <= 0)
            {
                return;
            }
            if (Find.Selector.NumSelected <= 1)
            {
                // highlight nearby thick mountain roof cells
                var fogGrid  = map.fogGrid;
                var roofGrid = map.roofGrid;
                GatherCellsInRadius(center, map, ownEffectiveRadius + AdditionalRoofDisplayRadius,
                                    cell => fogGrid.IsFogged(cell) || (roofGrid.RoofAt(cell)?.isThickRoof ?? false)
                                    );
                OverlayDrawer.DrawFieldEdges(cellBuffer, ThickRoofHighlightColor);

                void DrawMatchingEdgesAroundThing(Thing t)
                {
                    GatherCellsInRadius(t.Position, map, ownEffectiveRadius);
                    OverlayDrawer.DrawSolidField(cellBuffer, OtherEffectiveAreasColor);
                }

                // highlight effective areas of already built charges of same type
                var colonistBuildings = map.listerBuildings.allBuildingsColonist;
                for (var i = 0; i < colonistBuildings.Count; i++)
                {
                    if (colonistBuildings[i]?.def == def)
                    {
                        DrawMatchingEdgesAroundThing(colonistBuildings[i]);
                    }
                }
                // highlight effective areas of blueprints for charges of same type
                var blueprints = map.listerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.Blueprint));
                for (var i = 0; i < blueprints.Count; i++)
                {
                    if (blueprints[i]?.def?.entityDefToBuild == def)
                    {
                        DrawMatchingEdgesAroundThing(blueprints[i]);
                    }
                }
            }
            // highlight own effective radius with color-coded effectiveness
            var effectiveRadiusColor = RemoteTechUtility.IsEffectiveRoofBreakerPlacement(ownEffectiveRadius, center, map, true)
                                ? EffectivePlacementColor
                                : IneffectivePlacementColor;

            GatherCellsInRadius(center, map, ownEffectiveRadius);
            OverlayDrawer.DrawFieldEdges(cellBuffer, effectiveRadiusColor);
        }
예제 #7
0
        // quick detonation option for drafted pawns
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn)
        {
            var opt = RemoteTechUtility.TryMakeDetonatorFloatMenuOption(selPawn, this);

            if (opt != null)
            {
                yield return(opt);
            }

            foreach (var option in base.GetFloatMenuOptions(selPawn))
            {
                yield return(option);
            }
        }
 public CompChannelSelector()
 {
     gizmoCallback = c => {
         DesiredChannel = c;
         if (!manualSwitching)
         {
             DoSwitch();
         }
         parent.BroadcastCompSignal(DesiredChannelChangedSignal);
     };
     channelPopulation = new CachedValue <Dictionary <int, List <IWirelessDetonationReceiver> > >(
         () => readPopulation ? RemoteTechUtility.FindReceiversInNetworkRange(parent) : null
         );
 }
        public override void Draw()
        {
            base.Draw();
            if (compPower == null || !compPower.PowerOn)
            {
                return;
            }
            // limit the number of possible alpha levels to avoid leaking materials
            var props = BlinkerData;
            var alpha = Mathf.Round(Mathf.Max(0f, Mathf.Sin(((Find.TickManager.TicksGame + thingIDNumber * 1000) * Mathf.PI) / Mathf.Max(.1f, props.blinkerIntervalNormal))) * FlareAlphaLevels) / FlareAlphaLevels;

            if (alpha > 0)
            {
                RemoteTechUtility.DrawFlareOverlay(Resources.Graphics.FlareOverlayGreen, DrawPos, props, alpha);
            }
        }
 public void TriggerSensor(Pawn pawn)
 {
     lastTriggeredTick = GenTicks.TicksGame;
     trackedPawns.Add(pawn);
     if (settings.SendMessage)
     {
         NotifyPlayer(pawn);
     }
     if (settings.SendWired && wiredComp != null)
     {
         wiredComp.SendNewSignal();
     }
     if (settings.SendWireless && wirelessComp != null && wirelessComp.Enabled && channelsComp != null)
     {
         RemoteTechUtility.TriggerReceiversInNetworkRange(this, channelsComp.Channel);
     }
 }
        private void OnGizmoActivation()
        {
            if (lastActivationTick + ActivationCooldownTicks >= Find.TickManager.TicksGame)
            {
                return;
            }
            lastActivationTick = Find.TickManager.TicksGame;
            SoundDefOf.FlickSwitch.PlayOneShot(Wearer);

            RemoteTechUtility.TriggerReceiversInNetworkRange(this, channelsComp?.Channel ?? RemoteTechUtility.DefaultChannel);

            NumUsesLeft--;
            if (NumUsesLeft <= 0)
            {
                Destroy(DestroyMode.KillFinalize);
                Messages.Message("PortableDetonator_broke_msg".Translate(), new TargetInfo(Wearer), MessageTypeDefOf.NeutralEvent);
            }
        }
예제 #12
0
 private void PushGas()
 {
     if (FrontAndBackAreAccessble())
     {
         var sourceCloud = RemoteTechUtility.TryFindGasCloudAt(Map, sourceCell);
         if (sourceCloud != null)
         {
             RemoteTechUtility.ReportPowerUse(this);
             // move only whole units of concentration
             moveBuffer += Mathf.Min(sourceCloud.Concentration - MinSourceConcentration, statVentAmount / GenTicks.TicksPerRealSecond);
             if (moveBuffer > 1)
             {
                 var moveAmount = Mathf.FloorToInt(moveBuffer);
                 RemoteTechUtility.DeployGas(Map, targetCell, sourceCloud.def, moveAmount);
                 sourceCloud.ReceiveConcentration(-moveAmount);
                 moveBuffer -= moveAmount;
             }
         }
     }
 }
        public override string GetInspectString()
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append(base.GetInspectString());
            if (IsArmed)
            {
                stringBuilder.Append("RemoteExplosive_armed".Translate());
            }
            else
            {
                stringBuilder.Append("RemoteExplosive_notArmed".Translate());
            }
            if (channelsComp != null && RemoteTechUtility.GetChannelsUnlockLevel() > RemoteTechUtility.ChannelType.None)
            {
                stringBuilder.AppendLine();
                stringBuilder.Append(RemoteTechUtility.GetCurrentChannelInspectString(channelsComp.Channel));
            }
            return(stringBuilder.ToString());
        }
        public override string GetInspectString()
        {
            if (!Spawned)
            {
                return(string.Empty);
            }
            var stringBuilder = new StringBuilder(base.GetInspectString());

            if (channels != null)
            {
                channels.ChannelPopulation.TryGetValue(channels.Channel, out List <IWirelessDetonationReceiver> list);
                stringBuilder.AppendLine();
                stringBuilder.Append("DetonatorTable_inrange".Translate());
                stringBuilder.Append(": " + (list != null?list.Count:0));
                if (RemoteTechUtility.GetChannelsUnlockLevel() > RemoteTechUtility.ChannelType.None)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.Append(RemoteTechUtility.GetCurrentChannelInspectString(channels.Channel));
                }
            }
            return(stringBuilder.ToString());
        }
 public override void PostDraw()
 {
     base.PostDraw();
     if (blinker != null && Enabled)
     {
         var currentTick = GenTicks.TicksGame;
         RefreshCurrentTargetPosition(false);
         if (nextBlinkTick <= currentTick)
         {
             nextBlinkTick = currentTick + Mathf.Round(Rand.Range(BlinkMaxInterval / 2f, BlinkMaxInterval)).SecondsToTicks();
             blinkAnim.StartInterpolation(0f, BlinkAnimDuration / 2f, CurveType.CubicInOut);
             blinkAnim.SetFinishedCallback((interpolator, value, duration, curve) =>
                                           interpolator.StartInterpolation(1f, duration, curve).SetFinishedCallback(null)
                                           );
         }
         if (blinkSquintAnim.finished)
         {
             // squint if target is a dirty humanlike
             var isHumanlike  = currentTarget is Pawn p && p.RaceProps != null && p.RaceProps.Humanlike;
             var targetSquint = isHumanlike ? .5f : 1f;
             if (!blinkSquintAnim.value.ApproximatelyEquals(targetSquint))
             {
                 blinkSquintAnim.StartInterpolation(targetSquint, SquintAnimDuration, CurveType.CubicInOut);
             }
         }
         if (currentTarget != null && targetExpirationTick <= GenTicks.TicksGame)
         {
             SetLookTarget(null, false);
         }
         blinkAnim.UpdateIfUnpaused();
         blinkSquintAnim.UpdateIfUnpaused();
         offsetXAnim.UpdateIfUnpaused();
         offsetZAnim.UpdateIfUnpaused();
         RemoteTechUtility.DrawFlareOverlay(Resources.Graphics.FlareOverlayNormal,
                                            parent.DrawPos + new Vector3(offsetXAnim.value, 0, offsetZAnim.value) + Altitudes.AltIncVect, blinker, 1f, blinkAnim.value * blinkSquintAnim.value);
     }
 }
        public Gizmo GetChannelGizmo()
        {
            Dictionary <int, List <IWirelessDetonationReceiver> > population = gizmoMode == RemoteTechUtility.ChannelType.Advanced ? channelPopulation.Value : null;

            return(RemoteTechUtility.GetChannelGizmo(DesiredChannel, Channel, gizmoCallback, gizmoMode, population));
        }