Example #1
0
 public void WeatherManagerTick()
 {
     eventHandler.WeatherEventHandlerTick();
     curWeatherAge++;
     curWeather.Worker.WeatherTick(map, TransitionLerpFactor);
     lastWeather.Worker.WeatherTick(map, 1f - TransitionLerpFactor);
     growthSeasonMemory.GrowthSeasonMemoryTick();
     for (int i = 0; i < curWeather.ambientSounds.Count; i++)
     {
         bool flag = false;
         for (int num = ambienceSustainers.Count - 1; num >= 0; num--)
         {
             if (ambienceSustainers[num].def == curWeather.ambientSounds[i])
             {
                 flag = true;
                 break;
             }
         }
         if (!flag && VolumeOfAmbientSound(curWeather.ambientSounds[i]) > 0.0001f)
         {
             SoundInfo info      = SoundInfo.OnCamera();
             Sustainer sustainer = curWeather.ambientSounds[i].TrySpawnSustainer(info);
             if (sustainer != null)
             {
                 ambienceSustainers.Add(sustainer);
             }
         }
     }
 }
Example #2
0
        public static bool EnsureWorldAmbientSoundCreated()
        {
            SoundRoot soundRoot = Find.SoundRoot;

            if (null != soundRoot)
            {
                SustainerManager sManager = soundRoot.sustainerManager;
                if (null != sManager)
                {
                    SoundDef aSpace = SoundDefOf.Ambient_Space;
                    if (null != aSpace)
                    {
                        lock (sManager.AllSustainers)
                        {
                            if (sManager.SustainerExists(aSpace))
                            {
                                return(false);
                            }
                            else
                            {
                                aSpace.TrySpawnSustainer(SoundInfo.OnCamera());
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #3
0
 public static void EnsureWorldAmbientSoundCreated()
 {
     if (!AmbientSoundManager.WorldAmbientSoundCreated)
     {
         SoundDefOf.Ambient_Space.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
     }
 }
 public void WeatherManagerTick()
 {
     this.eventHandler.WeatherEventHandlerTick();
     this.curWeatherAge++;
     this.curWeather.Worker.WeatherTick(this.map, this.TransitionLerpFactor);
     this.lastWeather.Worker.WeatherTick(this.map, 1f - this.TransitionLerpFactor);
     this.growthSeasonMemory.GrowthSeasonMemoryTick();
     for (int i = 0; i < this.curWeather.ambientSounds.Count; i++)
     {
         bool flag = false;
         for (int j = this.ambienceSustainers.Count - 1; j >= 0; j--)
         {
             if (this.ambienceSustainers[j].def == this.curWeather.ambientSounds[i])
             {
                 flag = true;
                 break;
             }
         }
         if (!flag && this.VolumeOfAmbientSound(this.curWeather.ambientSounds[i]) > 0.0001f)
         {
             SoundInfo info      = SoundInfo.OnCamera(MaintenanceType.None);
             Sustainer sustainer = this.curWeather.ambientSounds[i].TrySpawnSustainer(info);
             if (sustainer != null)
             {
                 this.ambienceSustainers.Add(sustainer);
             }
         }
     }
 }
Example #5
0
 public void WeatherManagerTick()
 {
     this.eventHandler.WeatherEventHandlerTick();
     this.curWeatherAge++;
     this.curWeather.Worker.WeatherTick(this.map, this.TransitionLerpFactor);
     this.lastWeather.Worker.WeatherTick(this.map, (float)(1.0 - this.TransitionLerpFactor));
     this.growthSeasonMemory.GrowthSeasonMemoryTick();
     for (int i = 0; i < this.curWeather.ambientSounds.Count; i++)
     {
         bool flag = false;
         int  num  = this.ambienceSustainers.Count - 1;
         while (num >= 0)
         {
             if (this.ambienceSustainers[num].def != this.curWeather.ambientSounds[i])
             {
                 num--;
                 continue;
             }
             flag = true;
             break;
         }
         if (!flag && this.VolumeOfAmbientSound(this.curWeather.ambientSounds[i]) > 9.9999997473787516E-05)
         {
             SoundInfo info      = SoundInfo.OnCamera(MaintenanceType.None);
             Sustainer sustainer = this.curWeather.ambientSounds[i].TrySpawnSustainer(info);
             if (sustainer != null)
             {
                 this.ambienceSustainers.Add(sustainer);
             }
         }
     }
 }
Example #6
0
 public static void EnsureWorldAmbientSoundCreated()
 {
     if (!WorldAmbientSoundCreated)
     {
         SoundDefOf.Ambient_Space.TrySpawnSustainer(SoundInfo.OnCamera());
     }
 }
Example #7
0
        public void DraggerUpdate()
        {
            if (!dragging)
            {
                return;
            }
            List <IntVec3> list = DragCells;

            SelDes.RenderHighlight(list);
            if (list.Count != lastFrameDragCellsDrawn)
            {
                lastDragRealTime        = Time.realtimeSinceStartup;
                lastFrameDragCellsDrawn = list.Count;
                if (SelDes.soundDragChanged != null)
                {
                    SelDes.soundDragChanged.PlayOneShotOnCamera();
                }
            }
            if (sustainer == null || sustainer.Ended)
            {
                if (SelDes.soundDragSustain != null)
                {
                    sustainer = SelDes.soundDragSustain.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame));
                }
            }
            else
            {
                sustainer.externalParams["TimeSinceDrag"] = Time.realtimeSinceStartup - lastDragRealTime;
                sustainer.Maintain();
            }
        }
Example #8
0
        private static void RecreateMapSustainers()
        {
            if (!AltitudeWindSoundCreated)
            {
                SoundDefOf.Ambient_AltitudeWind.TrySpawnSustainer(SoundInfo.OnCamera());
            }
            SustainerManager sustainerManager = Find.SoundRoot.sustainerManager;

            for (int i = 0; i < biomeAmbientSustainers.Count; i++)
            {
                Sustainer sustainer = biomeAmbientSustainers[i];
                if (sustainerManager.AllSustainers.Contains(sustainer) && !sustainer.Ended)
                {
                    sustainer.End();
                }
            }
            biomeAmbientSustainers.Clear();
            if (Find.CurrentMap != null)
            {
                List <SoundDef> soundsAmbient = Find.CurrentMap.Biome.soundsAmbient;
                for (int j = 0; j < soundsAmbient.Count; j++)
                {
                    Sustainer item = soundsAmbient[j].TrySpawnSustainer(SoundInfo.OnCamera());
                    biomeAmbientSustainers.Add(item);
                }
            }
        }
        public void OpenCommsWith(Pawn negotiator, Faction faction)
        {
            Dialog_Negotiation dialog_Negotiation = new Dialog_Negotiation(negotiator, faction, ReinforcementDialogMakerRC.FactionDialogFor(negotiator, faction), true);

            //dialog_Negotiation.soundAmbient = RCDefsOf.AmbientRequisitionRelayRH;
            SoundStarter.PlayOneShot(RCDefsOf.PickUpRequisitionRelayRH, SoundInfo.OnCamera());
            Find.WindowStack.Add(dialog_Negotiation);
        }
Example #10
0
 public virtual void PostOpen()
 {
     if (soundAppear != null)
     {
         soundAppear.PlayOneShotOnCamera();
     }
     if (soundAmbient != null)
     {
         sustainerAmbient = soundAmbient.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame));
     }
 }
Example #11
0
        protected override void FillTab()
        {
            Rect             rect    = new Rect(0f, 0f, size.x, size.y).ContractedBy(10f);
            Listing_Standard listing = new Listing_Standard(GameFont.Small);

            listing.Begin(rect);
            listing.Label(SelThing.LabelCapNoCount);
            listing.LabelDouble("AtomicReconstructionTab_NowProducing".Translate(), (SelBuilding.ThingToGenerate?.LabelCap ?? "NoneBrackets".Translate()));
            listing.LabelDouble("AtomicReconstructionTab_PaperclipCost".Translate(), SelBuilding.ItemBaseCost.ToStringDecimalIfSmall());
            listing.LabelDouble("AtomicReconstructionTab_ConsumptionPerSecond".Translate(), (SelBuilding.FuelConsumptionPerTick * 60f).ToStringDecimalIfSmall());
            listing.LabelDouble("AtomicReconstructionTab_Progress".Translate(), SelBuilding.ProgressToStringPercent + $" ({SelBuilding.EstimatedProductionTimeLeftPeriod})");
            listing.Label("AtomicReconstructionTab_Speed".Translate(SelBuilding.speedFactor, SelBuilding.PaperclipConsumptionFactor));
            SelBuilding.speedFactor = (int)listing.Slider(SelBuilding.speedFactor, 1f, 20f);
            searchQuery             = listing.TextEntry(searchQuery);
            Rect rect2    = new Rect(0, listing.CurHeight, rect.width, rect.height - listing.CurHeight);
            Rect viewRect = new Rect(0f, 0f, rect2.width - 16f, scrollViewHeight);

            Widgets.BeginScrollView(rect2, ref scrollPos, viewRect);
            float curY = 0;
            // Draw reset button
            Rect resetRect = new Rect(0f, curY, viewRect.width, 28f);

            Widgets.Label(new Rect(36f, resetRect.y, resetRect.width - 36f, resetRect.height), "NoneBrackets".Translate());
            Widgets.DrawHighlightIfMouseover(resetRect);
            if (GUI.Button(resetRect, "", Widgets.EmptyStyle))
            {
                if (SelBuilding.ThingToGenerate != null)
                {
                    SelBuilding.ThingToGenerate = null;
                }
                SoundDefOf.Click.PlayOneShot(SoundInfo.OnCamera());
            }
            curY += 28f;
            foreach (ThingDef tDef in AllAllowedThingDefsColonyCanProduce().OrderBy(d => d.LabelCap))
            {
                if (searchQuery == null || tDef.label.ToLower().Contains(searchQuery))
                {
                    try
                    {
                        DrawThingDefRow(ref curY, viewRect.width, tDef);
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Project RimFactory :: Exception displaying row for {tDef}:{e}");
                    }
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                scrollViewHeight = curY + 30f;
            }
            Widgets.EndScrollView();
            listing.End();
        }
Example #12
0
        public override void PostOpen()
        {
            // Taken from Window.PostOpen, overriden to remove effects of Dialog_SplitCaravan.PostOpen

            if (soundAppear != null)
            {
                soundAppear.PlayOneShotOnCamera(null);
            }

            if (soundAmbient != null)
            {
                sustainerAmbient = soundAmbient.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame));
            }
        }
Example #13
0
 public void DoEditWidgets(WidgetRow widgetRow)
 {
     if (testSustainer == null)
     {
         if (!widgetRow.ButtonIcon(TexButton.Play))
         {
             return;
         }
         ResolveReferences();
         SoundInfo info;
         if (HasSubSoundsInWorld)
         {
             IntVec3 mapPosition = Find.CameraDriver.MapPosition;
             info = SoundInfo.InMap(new TargetInfo(mapPosition, Find.CurrentMap), MaintenanceType.PerFrame);
             for (int i = 0; i < 5; i++)
             {
                 MoteMaker.ThrowDustPuff(mapPosition, Find.CurrentMap, 1.5f);
             }
         }
         else
         {
             info = SoundInfo.OnCamera(MaintenanceType.PerFrame);
         }
         info.testPlay = true;
         if (sustain)
         {
             testSustainer = this.TrySpawnSustainer(info);
         }
         else
         {
             this.PlayOneShot(info);
         }
     }
     else
     {
         testSustainer.Maintain();
         if (widgetRow.ButtonIcon(TexButton.Stop))
         {
             testSustainer.End();
             testSustainer = null;
         }
     }
 }
        public static bool RecreateMapSustainers()
        {
            if (!(bool)altitudeWindSoundCreatedPI.GetValue(null))
            {
                SoundDefOf.Ambient_AltitudeWind.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
            }
            SustainerManager sustainerManager = Find.SoundRoot.sustainerManager;
            List <Sustainer> sustainers       = (biomeAmbientSustainersFI.GetValue(null) as List <Sustainer>);

            //lock (sustainerManager.AllSustainers)
            //{
            foreach (Sustainer s in sustainers)
            {
                if (sustainerManager.AllSustainers.Contains(s) && !s.Ended)
                {
                    s.End();
                }
            }
            sustainers.Clear();
            if (Find.CurrentMap != null)
            {
                List <SoundDef> soundsAmbient = Find.CurrentMap.Biome.soundsAmbient;
                for (int j = 0; j < soundsAmbient.Count; j++)
                {
                    Sustainer item = soundsAmbient[j].TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
                    try
                    {
                        lock (sustainerManager.AllSustainers)
                        {
                            sustainerManager.AllSustainers.Add(item);
                        }
                    }
                    catch (Exception)
                    {
                        item.End();
                    }
                }
            }
            //}
            return(false);
        }
Example #15
0
        private void DrawThingDefRow(ref float y, float width, ThingDef thingDef)
        {
            Rect rect = new Rect(0f, y, width, 28f);

            if (Mouse.IsOver(rect))
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1f);
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            if (thingDef.DrawMatSingle != null && thingDef.DrawMatSingle.mainTexture != null)
            {
                if (thingDef.graphicData != null && GenUI.IconDrawScale(thingDef) <= 1.5f)
                {
                    Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thingDef);
                }
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = new Color(0.9f, 0.9f, 0.9f, 1f);
            Rect rect5 = new Rect(36f, y, rect.width - 36f, rect.height);

            Text.WordWrap = false;
            Widgets.Label(rect5, thingDef.LabelCap.Truncate(rect5.width, null));
            Text.WordWrap = true;
            string text2 = thingDef.description;

            if (y > -28f)
            {
                TooltipHandler.TipRegion(rect, string.IsNullOrEmpty(text2) ? "PRFNoDesc".Translate().RawText : text2);
            }
            if (GUI.Button(rect, "", Widgets.EmptyStyle))
            {
                if (SelBuilding.ThingToGenerate != thingDef)
                {
                    SelBuilding.ThingToGenerate = thingDef;
                }
                SoundDefOf.Click.PlayOneShot(SoundInfo.OnCamera());
            }
            Text.Anchor = TextAnchor.UpperLeft;
            y          += 28f;
        }
Example #16
0
 public static bool Cleanup(Sustainer __instance)
 {
     if (__instance.def.subSounds.Count > 0)
     {
         Find.SoundRoot.sustainerManager.DeregisterSustainer(__instance);
         lock (subSustainers(__instance))
         {
             for (int index = 0; index < subSustainers(__instance).Count; ++index)
             {
                 subSustainers(__instance)[index].Cleanup();
             }
         }
     }
     if (__instance.def.sustainStopSound != null)
     {
         lock (worldRootObject(__instance))
         {
             if (worldRootObject(__instance) != null)
             {
                 Map map = __instance.info.Maker.Map;
                 if (map != null)
                 {
                     __instance.def.sustainStopSound.PlayOneShot(SoundInfo.InMap(new TargetInfo(worldRootObject(__instance).transform.position.ToIntVec3(), map, false), MaintenanceType.None));
                 }
             }
             else
             {
                 __instance.def.sustainStopSound.PlayOneShot(SoundInfo.OnCamera(MaintenanceType.None));
             }
         }
         if (worldRootObject(__instance) != null)
         {
             UnityEngine.Object.Destroy(worldRootObject(__instance));
         }
     }
     DebugSoundEventsLog.Notify_SustainerEnded(__instance, __instance.info);
     return(false);
 }
Example #17
0
 public void DraggingStart(float mouseOffX, float rateFactor)
 {
     SoundStarter.PlayOneShot(DragStartSound, SoundInfo.OnCamera(MaintenanceType.None));
 }
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn)
        {
            foreach (var option in base.GetFloatMenuOptions(selPawn))
            {
                yield return(option);
            }

            //Start targeter
            yield return(new FloatMenuOption("QE_BrainScanningApplyTemplate".Translate(),
                                             delegate()
            {
                string failReason = "";
                TargetingParameters targetParams =
                    new TargetingParameters()
                {
                    canTargetPawns = true,

                    //initial target is valid as long as it's a pawn, it's not the one selected
                    //other checks are less obvious to the player, so inform them with a message in IsValidBrainTemplatingTarget()
                    validator = (target) => target.HasThing && target.Thing is Pawn pawn && pawn != selPawn
                };

                //do all validation here instead of the validator predicate above, because here we
                //can write messages to the player if they select an invalid pawn, telling them *why*
                //it's the wrong target
                Find.Targeter.BeginTargeting(targetParams,
                                             delegate(LocalTargetInfo target)
                {
                    Pawn targetPawn = target.Thing as Pawn;
                    if (targetPawn != null)
                    {
                        //begin validation
                        if (targetPawn.IsValidBrainTemplatingTarget(ref failReason, this))
                        {
                            //valid target established, time to find a bed.
                            //Healthy pawns will get up from medical beds immediately, so skip med beds in search
                            Building_Bed validBed = targetPawn.FindAvailMedicalBed(selPawn);

                            string whyFailed = "";
                            if (validBed == null)
                            {
                                if (targetPawn.RaceProps.Animal)
                                {
                                    whyFailed = "No animal beds are available";
                                }
                                else
                                {
                                    whyFailed = "No medical beds are available";
                                }
                            }
                            else if (!selPawn.CanReserveAndReach(targetPawn, PathEndMode.OnCell, Danger.Deadly))
                            {
                                whyFailed = selPawn.LabelShort + " can't reach/reserve " + targetPawn.LabelShort;
                            }
                            else if (!selPawn.CanReserveAndReach(this, PathEndMode.OnCell, Danger.Deadly))
                            {
                                whyFailed = selPawn.LabelShort + " can't reach/reserve the brain template";
                            }
                            //check if bed can be reserved, if patient is not already there
                            else if (targetPawn.CurrentBed() != validBed &&
                                     !selPawn.CanReserveAndReach(validBed, PathEndMode.OnCell, Danger.Deadly))
                            {
                                whyFailed = selPawn.LabelShort + " can't reach/reserve the " + validBed.def.defName;
                            }

                            if (!String.IsNullOrEmpty(whyFailed))
                            {
                                Messages.Message(whyFailed, MessageTypeDefOf.RejectInput, false);
                                SoundDefOf.ClickReject.PlayOneShot(SoundInfo.OnCamera());
                            }
                            else
                            {
                                selPawn.jobs.TryTakeOrderedJob(new Job(QEJobDefOf.QE_ApplyBrainScanTemplate, targetPawn, this, validBed)
                                {
                                    count = 1
                                });
                            }
                        }
                        else
                        {
                            Messages.Message(failReason, MessageTypeDefOf.RejectInput, false);
                            SoundDefOf.ClickReject.PlayOneShot(SoundInfo.OnCamera());
                        }
                    }
                },
                                             caster: selPawn);
            }));
        }
Example #19
0
 public void DraggingCompleted(float mouseOffX, float rateFactor)
 {
     SoundStarter.PlayOneShot(DragEndSound, SoundInfo.OnCamera(MaintenanceType.None));
     valueUpdateCallback = null;
 }
Example #20
0
        IEnumerator TickTasks()
        {
            var sw = new Stopwatch();

            sw.Start();
            RepositionColonists();
            yield return(null);

            HandleIncidents();
            yield return(null);

            FetchAvoidGrid();
            yield return(null);

            RecalculateVisibleMap();
            yield return(null);

            IncreaseZombiePopulation();
            yield return(null);

            UpdateZombieAvoider();
            yield return(null);

            ExecuteExplosions();
            yield return(null);

            var volume = 0f;

            if (allZombiesCached.Any())
            {
                var hour = GenLocalDate.HourFloat(Find.CurrentMap);
                if (hour < 12f)
                {
                    hour += 24f;
                }
                if (hour > Constants.HOUR_START_OF_NIGHT && hour < Constants.HOUR_END_OF_NIGHT)
                {
                    volume = 1f;
                }
                else if (hour >= Constants.HOUR_START_OF_DUSK && hour <= Constants.HOUR_START_OF_NIGHT)
                {
                    volume = GenMath.LerpDouble(Constants.HOUR_START_OF_DUSK, Constants.HOUR_START_OF_NIGHT, 0f, 1f, hour);
                }
                else if (hour >= Constants.HOUR_END_OF_NIGHT && hour <= Constants.HOUR_START_OF_DAWN)
                {
                    volume = GenMath.LerpDouble(Constants.HOUR_END_OF_NIGHT, Constants.HOUR_START_OF_DAWN, 1f, 0f, hour);
                }
            }
            yield return(null);

            if (Constants.USE_SOUND && ZombieSettings.Values.playCreepyAmbientSound)
            {
                if (zombiesAmbientSound == null)
                {
                    zombiesAmbientSound = CustomDefs.ZombiesClosingIn.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
                }

                if (volume < zombiesAmbientSoundVolume)
                {
                    zombiesAmbientSoundVolume -= 0.0001f;
                }
                else if (volume > zombiesAmbientSoundVolume)
                {
                    zombiesAmbientSoundVolume += 0.0001f;
                }
                zombiesAmbientSound.info.volumeFactor = zombiesAmbientSoundVolume;
            }
            else
            {
                if (zombiesAmbientSound != null)
                {
                    zombiesAmbientSound.End();
                    zombiesAmbientSound = null;
                }
            }
            yield return(null);

            if (colonistsConverter.Count > 0)
            {
                var pawn = colonistsConverter.Dequeue();
                Tools.ConvertToZombie(pawn);
            }
            yield return(null);
        }
Example #21
0
        public void DraggingUpdate(float mouseOffX, float rateFactor)
        {
            Update();

            int amount    = 0;
            int direction = 1;

            if (mouseOffX != 0)
            {
                float delta = Math.Abs(mouseOffX);
                if (delta > maxDelta)
                {
                    delta = maxDelta;
                }
                delta = delta * stretch;
                delta = scale / (delta * delta);
                if (lastUpdateTime > delta)
                {
                    amount = 0;
                    while (lastUpdateTime > delta)
                    {
                        lastUpdateTime -= delta;
                        amount++;
                    }
                }
            }

            if (mouseOffX < 0)
            {
                direction = -1;
            }

            AcceptanceReport acceptanceReport = null;

            if (amount != 0)
            {
                if (Event.current.shift)
                {
                    amount = amount * multiplier;
                }
                if (direction > 0)
                {
                    if (value < maxValue)
                    {
                        if (maxValue - value < amount)
                        {
                            value = maxValue;
                        }
                        else
                        {
                            value += amount;
                        }
                        acceptanceReport = true;
                    }
                    else
                    {
                        acceptanceReport = false;
                    }
                }
                else
                {
                    if (value > minValue)
                    {
                        if (minValue + amount > value)
                        {
                            value = minValue;
                        }
                        else
                        {
                            value -= amount;
                        }
                        acceptanceReport = true;
                    }
                    else
                    {
                        acceptanceReport = false;
                    }
                }
                if (acceptanceReport.Accepted)
                {
                    SoundStarter.PlayOneShot(DragAmountChangedSound, SoundInfo.OnCamera(MaintenanceType.None));
                    lastDragRealTime = Time.realtimeSinceStartup;
                }
            }
            if (valueUpdateCallback != null)
            {
                valueUpdateCallback(value);
            }
        }
Example #22
0
        public void OnGUI(Rect rect)
        {
            float curY            = 0f;
            float repeatModeButX  = 0f;
            float adjustButHeight = 30f;

            try
            {
                GUI.BeginGroup(rect);
                //Do the top buttons. If the parent is not null, then do the suspend button.
                if (!setupStage)
                {
                    float suspendButRightEdge = rect.width / 2f - 5f;
                    Rect  suspendButRect      = new Rect(0f, 0f, suspendButRightEdge, buttonSize.y);
                    if (Suspended)
                    {
                        if (Widgets.TextButton(suspendButRect, "Suspended".Translate()))
                        {
                            Suspended = false;
                        }
                    }
                    else
                    {
                        if (Widgets.TextButton(suspendButRect, "NotSuspended".Translate()))
                        {
                            Suspended = true;
                        }
                    }
                    repeatModeButX = rect.width / 2f + 5f;
                }
                string label = "But";
                if (repeatMode == BillRepeatMode.RepeatCount)
                {
                    label = "DoXTimes".Translate();
                }
                if (repeatMode == BillRepeatMode.TargetCount)
                {
                    label = "DoUntilYouHaveX".Translate();
                }
                if (repeatMode == BillRepeatMode.Forever)
                {
                    label = "DoForever".Translate();
                }
                Vector2 repeatButSize = new Vector2(rect.width - repeatModeButX, buttonSize.y);
                Rect    repeatButRect = new Rect(repeatModeButX, curY, repeatButSize.x, repeatButSize.y);
                if (Widgets.TextButton(repeatButRect, label))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    list.Add(new FloatMenuOption("DoXTimes".Translate(), delegate
                    {
                        this.repeatMode = BillRepeatMode.RepeatCount;
                    }));
                    list.Add(new FloatMenuOption("DoUntilYouHaveX".Translate(), delegate
                    {
                        this.repeatMode = BillRepeatMode.TargetCount;
                    }));
                    list.Add(new FloatMenuOption("DoForever".Translate(), delegate
                    {
                        this.repeatMode = BillRepeatMode.Forever;
                    }));
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                curY += repeatButSize.y + margin;

                //Do the target count label
                Rect countRect = new Rect(0, curY, rect.width, 30f);
                curY += countRect.height + margin;
                string text = string.Empty;
                if (this.repeatMode == BillRepeatMode.RepeatCount)
                {
                    text = "RepeatCount".Translate(new object[] {
                        Cycles.ToString()
                    });
                    float butPadding = 2f;
                    float butWidth   = (rect.width - 8 * butPadding) / 5f;
                    float xPos       = 0f;
                    Rect  but1Rect   = new Rect(xPos, curY, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but1Rect, "-25"))
                    {
                        if (Cycles == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            Cycles -= 25;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but2Rect, "-1"))
                    {
                        if (Cycles == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            Cycles -= 1;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but3Rect, "1"))
                    {
                        Cycles = 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but4Rect, "+1"))
                    {
                        Cycles += 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but5Rect, "+25"))
                    {
                        Cycles += 25;
                    }
                }
                else if (repeatMode == BillRepeatMode.TargetCount)
                {
                    text = "TargetCount".Translate(new object[] {
                        (TargetCount >= 999999)?"Infinite".Translate() : TargetCount.ToString()
                    });
                    float butPadding = 2f;
                    float butWidth   = (rect.width - 12 * butPadding) / 7f;
                    float xPos       = 0f;
                    Rect  but1Rect   = new Rect(xPos, curY, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but1Rect, "-250"))
                    {
                        if (TargetCount == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            TargetCount -= 250;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but2Rect, "-25"))
                    {
                        if (TargetCount == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            TargetCount -= 25;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but3Rect, "-1"))
                    {
                        if (TargetCount == 0)
                        {
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        }
                        else
                        {
                            TargetCount -= 1;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but4Rect, "1"))
                    {
                        TargetCount = 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but5Rect, "+1"))
                    {
                        TargetCount += 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but6Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but6Rect, "+25"))
                    {
                        TargetCount += 25;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but7Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but7Rect, "+250"))
                    {
                        TargetCount += 250;
                    }
                }
                else if (repeatMode == BillRepeatMode.Forever)
                {
                    text = "Do Forever";
                }
                else
                {
                    throw new InvalidOperationException();
                }
                curY += adjustButHeight + margin + 6f;

                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(countRect, text);
                //Now for the ThingFilter box (shiver)
                Rect thingFilterLabelRect = new Rect(0f, curY, rect.width, 20f);
                curY += thingFilterLabelRect.height + margin;
                Widgets.Label(thingFilterLabelRect, "PermittedIngredients".Translate());
                Text.Anchor = TextAnchor.UpperLeft;

                float tfheight        = rect.height - curY - adjustButHeight - margin;
                Rect  thingFilterRect = new Rect(0f, curY, rect.width, tfheight);
                curY += tfheight + margin;
                ThingFilterUI.DoThingFilterConfigWindow(thingFilterRect, ref this.scrollPosition, this.ingredientsFilter, this.recipe.fixedIngredientFilter);
                //Well that wasn't so hard after all
                float checkWidth = rect.width / 2 - 30f;
                float checkXPos  = rect.width / 2 - (checkWidth / 2);
                Rect  checkRect  = new Rect(checkXPos, curY, checkWidth, adjustButHeight);
                Widgets.LabelCheckbox(checkRect, "Complete all", ref this.completeAll);
                string s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 15 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick.";
                if (RepeatMode == BillRepeatMode.TargetCount)
                {
                    s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 5 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick.";
                }
                TipSignal tip = new TipSignal(s);
                TooltipHandler.TipRegion(checkRect, tip);
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }
        }
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn)
        {
            foreach (var option in base.GetFloatMenuOptions(selPawn))
            {
                yield return(option);
            }

            //Start targeter
            yield return(new FloatMenuOption("QE_BrainScanningApplyTemplate".Translate(),
                                             delegate()
            {
                TargetingParameters targetParams =
                    new TargetingParameters()
                {
                    canTargetPawns = true,
                    validator = (target) => target.HasThing && target.Thing is Pawn pawn && pawn != selPawn && pawn.IsValidBrainTemplatingTarget()
                };

                Find.Targeter.BeginTargeting(targetParams,
                                             delegate(LocalTargetInfo target)
                {
                    Pawn pawn = target.Thing as Pawn;
                    if (pawn != null)
                    {
                        Building_Bed validBed = pawn.FindSuitableSurgeryBed(selPawn);
                        if (validBed != null && selPawn.CanReserveAndReach(pawn, PathEndMode.OnCell, Danger.Deadly) && selPawn.CanReserveAndReach(this, PathEndMode.OnCell, Danger.Deadly) && selPawn.CanReserveAndReach(validBed, PathEndMode.OnCell, Danger.Deadly))
                        {
                            selPawn.jobs.TryTakeOrderedJob(new Job(QEJobDefOf.QE_ApplyBrainScanTemplate, pawn, this, validBed)
                            {
                                count = 1
                            });
                        }
                        else
                        {
                            Messages.Message("QE_BrainScanningRejectInput".Translate(pawn.Name), MessageTypeDefOf.RejectInput, false);
                            SoundDefOf.ClickReject.PlayOneShot(SoundInfo.OnCamera());
                        }
                    }
                },
                                             caster: selPawn);
            }));

            //Find valid brain scanning target and medical bed on the map.

            /*var eligibleTargets = Map.mapPawns.FreeColonistsAndPrisonersSpawned.Where(pawn => pawn.IsValidBrainTemplatingTarget());
             * if(eligibleTargets != null)
             * {
             *  foreach(Pawn pawn in eligibleTargets)
             *  {
             *      Building_Bed validBed = RestUtility.FindPatientBedFor(pawn);
             *
             *      bool disabled = validBed == null;
             *      string label = null;
             *      if(disabled)
             *      {
             *          label = "QE_BrainScanningFloatMenuLabelDisabled".Translate(pawn.LabelCap);
             *      }
             *      else
             *      {
             *          label = "QE_BrainScanningFloatMenuLabel".Translate(pawn.LabelCap);
             *      }
             *
             *      FloatMenuOption option = new FloatMenuOption(label, delegate()
             *      {
             *
             *      });
             *      option.Disabled = disabled;
             *
             *      yield return option;
             *  }
             * }*/
        }
Example #24
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Log.Message("Shia TryExecuteWorker Launched");
            parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
            parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
            parms.points          = 50;
            if (!TryResolveRaidFaction(parms))
            {
                Log.Error("Failed to resolve shia raid faction");
                return(false);
            }

            Find.TickManager.slower.SignalForceNormalSpeedShort();
            Find.StoryWatcher.statsRecord.numRaidsEnemy++;

            var list = new List <Pawn>();

            Log.Message("Trying to make a shia");
            var shia = GenerateShia(parms);

            list.Add(shia);
            Log.Message("Made a shia");

            if (list.Count == 0)
            {
                Log.Error("Got no pawns spawning raid from parms " + parms);
                return(false);
            }

            if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms))
            {
                Log.Error("Failed to resolve raid spawn center");
                return(false);
            }

            TargetInfo target = shia;

            //TargetInfo targetTest = new TargetInfo(parms.spawnCenter,map,false);
            parms.raidArrivalMode.Worker.Arrive(list, parms);

            PawnComponentsUtility.AddComponentsForSpawn(shia);
            //Is the below lines even needed?
            //DropPodUtility.DropThingsNear(parms.spawnCenter, map, list.Cast<Thing>(), parms.raidPodOpenDelay, false, true, true);
            //target = new TargetInfo(parms.spawnCenter, map, false);

            //message player
            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Points = " + parms.points.ToString("F0"));
            foreach (var current2 in list)
            {
                var str = current2.equipment?.Primary == null
                    ? "unarmed"
                    : current2.equipment.Primary.LabelCap;
                stringBuilder.AppendLine(current2.KindLabel + " - " + str);
            }

            PawnRelationUtility.Notify_PawnsSeenByPlayer(list, out _);
            Find.LetterStack.ReceiveLetter(Consts_ShiaSurprise.letterLabel, Consts_ShiaSurprise.letterText,
                                           DefOfs_ShiaSurprise.ThreatSmall, target, parms.faction, null, null, stringBuilder.ToString());
            TaleRecorder.RecordTale(DefOfs_ShiaSurprise.Raid);
            parms.raidStrategy.Worker.MakeLords(parms, list);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical);
            //Lord lord = LordMaker.MakeNewLord(parms.faction, new LordJob_AssaultColony(parms.faction, false, false, false, true, false), map, list);
            //Does not seem to be a 1.0 counterpart to the below line
            //AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction, map);


            SoundDef.Named("Shia").PlayOneShot(SoundInfo.OnCamera());
            return(true);
        }
Example #25
0
 public void DraggerUpdate()
 {
     if (this.dragging)
     {
         List <IntVec3> list = this.DragCells;
         for (int i = 0; i < list.Count; i++)
         {
             Graphics.DrawMesh(MeshPool.plane10, list[i].ToVector3Shifted() + 10f * Vector3.up, Quaternion.identity, DesignationDragger.DragHighlightCellMat, 0);
         }
         if (list.Count != this.lastFrameDragCellsDrawn)
         {
             this.lastDragRealTime        = Time.realtimeSinceStartup;
             this.lastFrameDragCellsDrawn = list.Count;
             if (this.SelDes.soundDragChanged != null)
             {
                 this.SelDes.soundDragChanged.PlayOneShotOnCamera(null);
             }
         }
         if (this.sustainer == null || this.sustainer.Ended)
         {
             if (this.SelDes.soundDragSustain != null)
             {
                 this.sustainer = this.SelDes.soundDragSustain.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame));
             }
         }
         else
         {
             this.sustainer.externalParams["TimeSinceDrag"] = Time.realtimeSinceStartup - this.lastDragRealTime;
             this.sustainer.Maintain();
         }
     }
 }
Example #26
0
        public override void DoWindowContents(Rect inRect)
        {
            base.DoWindowContents(inRect);

            //First we draw the header
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperCenter;
            Widgets.Label(new Rect(0f, 0f, 300f, 300f), "ManufacturingPlant".Translate());
            Text.Anchor = TextAnchor.UpperLeft;

            //This float is used to set the padding at the bottom of the window.
            float bottomPaddingHeight = 50f;

            //The mainRect is the rectangle which contains the listbox
            Rect mainRect = new Rect(0f, bottomPaddingHeight, inRect.width, inRect.height - bottomPaddingHeight - 50f);

            //We initialise the entry and button sizes according to the main rect, which is sized depending on the window size. This lets the window be resized easily without (hoepfully) creating too many problems.
            this.lineEntrySize      = new Vector2(mainRect.width - 16f, 100f);
            this.interactButtonSize = new Vector2(100f, this.lineEntrySize.y / 2 - 14f);

            //We begin the group to tell the system that the following elements are grouped together.
            GUI.BeginGroup(mainRect);

            //This float is the height of the entry with a small margin added to it.
            float entryHeightWithMargin = this.lineEntrySize.y + 8f;

            //This float is the height of the entire list with all included entries and margins. This is used for the rect which houses all the entries, even though we wont see all of them at once.
            float height = (float)assemblyLines.Count * entryHeightWithMargin;

            //This rect is used inside the scroll view, and is moved up and down to show the entries.
            Rect viewRect = new Rect(0f, 0f, mainRect.width - 16f, height);

            //This is the rect on the screen to be used for the ScrollView
            Rect outRect = new Rect(mainRect.AtZero());

            //This function starts the scrolling view, and uses the scrollPosition variable to record where in the scrollview we are looking
            Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);

            //This float is the current y position in the scrollview, we use this for drawing each entry under each other.
            float currentY = 0f;

            //We first check to see if there are any entries. If no, then give a small message
            if (assemblyLines.Count == 0)
            {
                Rect rect2 = new Rect(0f, currentY, this.lineEntrySize.x, this.lineEntrySize.y);
                Text.Font = GameFont.Small;
                Widgets.Label(rect2, "NoAssemblyLines".Translate());
            }

            //If there are entries, then we draw the entry for each element in the list, calling our Draw...() function.
            else
            {
                foreach (AssemblyLine line in assemblyLines)
                {
                    line.OnGUI(currentY, this.lineEntrySize, this.interactButtonSize, this);
                    //Increment the current y position for the next entry to be drawn
                    currentY += entryHeightWithMargin;
                }
            }
            //Must remember to end the view once it has been drawn.
            Widgets.EndScrollView();
            //Likewise, remember to end the group
            GUI.EndGroup();

            //This draws the button in the bottom right corner of the window. It uses the same size as the Close button
            Rect lineManagerButRect = new Rect(inRect.width - this.lineManagerButtonSize.x, inRect.height - this.lineManagerButtonSize.y, this.lineManagerButtonSize.x, this.lineManagerButtonSize.y);

            if (Widgets.TextButton(lineManagerButRect, "ConstructNewAssemblyLine".Translate()))
            {
                if (MPmanager.manager.CanAddAssemblyLine)
                {
                    string costString = "";
                    if (Game.GodMode && AssemblyLine.Settings.instaBuild)
                    {
                        costString = "Nothing".Translate();
                    }
                    else
                    {
                        foreach (var item in AssemblyLine.Settings.BuildingCost)
                        {
                            costString += string.Format("{1} {0}\n", item.thing.label, item.amount);
                        }
                    }
                    Find.WindowStack.Add(new Dialog_Confirm("BuildNewAssemblyLineDialog".Translate(costString, TicksToTime.GetTime((float)AssemblyLine.ConstructionTicksRequired)), delegate
                    {
                        MPmanager.manager.AddNewAssemblyLine((Game.GodMode && AssemblyLine.Settings.instaBuild));
                    }));
                }
                else
                {
                    Dialog_Message m = new Dialog_Message("MaximumAssemblyLines".Translate());
                    Find.WindowStack.Add(m);
                    SoundDefOf.ClickReject.PlayOneShot(SoundInfo.OnCamera());
                }
            }
        }
Example #27
0
 public void DraggerUpdate()
 {
     if (this.dragging)
     {
         List <IntVec3> list = this.DragCells;
         this.SelDes.RenderHighlight(list);
         if (list.Count != this.lastFrameDragCellsDrawn)
         {
             this.lastDragRealTime        = Time.realtimeSinceStartup;
             this.lastFrameDragCellsDrawn = list.Count;
             if (this.SelDes.soundDragChanged != null)
             {
                 this.SelDes.soundDragChanged.PlayOneShotOnCamera(null);
             }
         }
         if (this.sustainer == null || this.sustainer.Ended)
         {
             if (this.SelDes.soundDragSustain != null)
             {
                 this.sustainer = this.SelDes.soundDragSustain.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame));
             }
         }
         else
         {
             this.sustainer.externalParams["TimeSinceDrag"] = Time.realtimeSinceStartup - this.lastDragRealTime;
             this.sustainer.Maintain();
         }
     }
 }