コード例 #1
0
        private void DoOpenTunnels(List <IntVec3> group, Map map)
        {
            int a = GenMath.RoundRandom((float)group.Count * Rand.Range(0.9f, 1.1f) * 5.8f / 10000f);

            a = Mathf.Min(a, 3);
            if (a > 0)
            {
                a = Rand.RangeInclusive(1, a);
            }
            float num = TunnelsWidthPerRockCount.Evaluate(group.Count);

            for (int i = 0; i < a; i++)
            {
                IntVec3 start = IntVec3.Invalid;
                float   num2  = -1f;
                float   dir   = -1f;
                float   num3  = -1f;
                for (int j = 0; j < 10; j++)
                {
                    IntVec3 intVec     = FindRandomEdgeCellForTunnel(group, map);
                    float   distToCave = GetDistToCave(intVec, group, map, 40f, treatOpenSpaceAsCave: false);
                    float   dist;
                    float   num4 = FindBestInitialDir(intVec, group, out dist);
                    if (!start.IsValid || distToCave > num2 || (distToCave == num2 && dist > num3))
                    {
                        start = intVec;
                        num2  = distToCave;
                        dir   = num4;
                        num3  = dist;
                    }
                }
                float width = Rand.Range(num * 0.8f, num);
                Dig(start, dir, width, group, map, closed: false);
            }
        }
コード例 #2
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     if (req.HasThing && AppliesTo(req))
     {
         val *= curve.Evaluate(CurveXGetter(req));
     }
 }
コード例 #3
0
        public void WigglerTick()
        {
            if (!Controller.settings.MakeThemBlink)
            {
                return;
            }

            int tickManagerTicksGame = Find.TickManager.TicksGame;

            float x          = Mathf.InverseLerp(this._lastBlinkended, this._nextBlink, tickManagerTicksGame);
            float movePixel  = 0f;
            float movePixelY = 0f;

            if (this._moveX || this._moveY)
            {
                if (this._moveX)
                {
                    if (this._halfAnimX)
                    {
                        movePixel = EyeMotionHalfCurve.Evaluate(x) * this._factorX;
                    }
                    else
                    {
                        movePixel = EyeMotionFullCurve.Evaluate(x) * this._factorX;
                    }
                }

                if (this._moveY)
                {
                    if (this._halfAnimY)
                    {
                        movePixelY = EyeMotionHalfCurve.Evaluate(x) * this._factorY;
                    }
                    else
                    {
                        movePixelY = EyeMotionFullCurve.Evaluate(x) * this._factorY;
                    }
                }

                if (this._compFace.BodyStat.EyeRight == PartStatus.Natural)
                {
                    this.EyeMoveR = new Vector3(movePixel * this._flippedX, 0, movePixelY * this._flippedY);
                }

                if (this._compFace.BodyStat.EyeLeft == PartStatus.Natural)
                {
                    this.EyeMoveL = new Vector3(movePixel * this._flippedX, 0, movePixelY * this._flippedY);
                }
            }

            if (tickManagerTicksGame > this.NextBlinkEnd)
            {
                // Set upnext blinking cycle
                this.SetNextBlink(tickManagerTicksGame);

                // Make them smile.
            }
        }
コード例 #4
0
        public static float FoodOptimality(Pawn eater, Thing foodSource, ThingDef foodDef, float dist, bool takingToInventory = false)
        {
            float num = 300f;

            num -= dist;
            switch (foodDef.ingestible.preferability)
            {
            case FoodPreferability.NeverForNutrition:
                return(-9999999f);

            case FoodPreferability.DesperateOnly:
                num -= 150f;
                break;

            case FoodPreferability.DesperateOnlyForHumanlikes:
                if (eater.RaceProps.Humanlike)
                {
                    num -= 150f;
                }
                break;
            }
            CompRottable compRottable = foodSource.TryGetComp <CompRottable>();

            if (compRottable != null)
            {
                if (compRottable.Stage == RotStage.Dessicated)
                {
                    return(-9999999f);
                }
                if (!takingToInventory && compRottable.Stage == RotStage.Fresh && compRottable.TicksUntilRotAtCurrentTemp < 30000)
                {
                    num += 12f;
                }
            }
            if (eater.needs != null && eater.needs.mood != null)
            {
                List <ThoughtDef> list = ThoughtsFromIngesting(eater, foodSource, foodDef);
                for (int i = 0; i < list.Count; i++)
                {
                    num += FoodOptimalityEffectFromMoodCurve.Evaluate(list[i].stages[0].baseMoodEffect);
                }
            }
            if (foodDef.ingestible != null)
            {
                if (eater.RaceProps.Humanlike)
                {
                    num += foodDef.ingestible.optimalityOffsetHumanlikes;
                }
                else if (eater.RaceProps.Animal)
                {
                    num += foodDef.ingestible.optimalityOffsetFeedingAnimals;
                }
            }
            return(num);
        }
コード例 #5
0
        public static void ResolveSketch(ResolveParams parms)
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Mech clusters are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 673321);
                return;
            }
            bool  canBeDormant = !parms.mechClusterDormant.HasValue || parms.mechClusterDormant.Value;
            float num;

            if (parms.points.HasValue)
            {
                num = parms.points.Value;
            }
            else
            {
                num = 2000f;
                Log.Error("No points given for mech cluster generation. Default to " + num);
            }
            float   value = parms.totalPoints.HasValue ? parms.totalPoints.Value : num;
            IntVec2 intVec;

            if (parms.mechClusterSize.HasValue)
            {
                intVec = parms.mechClusterSize.Value;
            }
            else
            {
                int num2 = GenMath.RoundRandom(PointsToSizeCurve.Evaluate(num) * SizeRandomFactorRange.RandomInRange);
                int num3 = GenMath.RoundRandom(PointsToSizeCurve.Evaluate(num) * SizeRandomFactorRange.RandomInRange);
                if (parms.mechClusterForMap != null)
                {
                    CellRect cellRect = LargestAreaFinder.FindLargestRect(parms.mechClusterForMap, (IntVec3 x) => !x.Impassable(parms.mechClusterForMap) && x.GetTerrain(parms.mechClusterForMap).affordances.Contains(TerrainAffordanceDefOf.Heavy), Mathf.Max(num2, num3));
                    num2 = Mathf.Min(num2, cellRect.Width);
                    num3 = Mathf.Min(num3, cellRect.Height);
                }
                intVec = new IntVec2(num2, num3);
            }
            Sketch sketch = new Sketch();

            if (Rand.Chance(WallsChanceCurve.Evaluate(num)))
            {
                ResolveParams parms2 = parms;
                parms2.sketch          = sketch;
                parms2.mechClusterSize = intVec;
                SketchResolverDefOf.MechClusterWalls.Resolve(parms2);
            }
            List <ThingDef> buildingDefsForCluster_NewTemp = GetBuildingDefsForCluster_NewTemp(num, intVec, canBeDormant, value);

            AddBuildingsToSketch(sketch, intVec, buildingDefsForCluster_NewTemp);
            parms.sketch.MergeAt(sketch, default(IntVec3), Sketch.SpawnPosType.OccupiedCenter);
        }
コード例 #6
0
        public static float FoodSourceOptimality(Pawn eater, Thing t, float dist, bool takingToInventory = false)
        {
            var num = 300f;

            num -= dist;
            var thingDef      = !(t is Building_NutrientPasteDispenser) ? t.def : ThingDefOf.MealNutrientPaste;
            var preferability = thingDef.ingestible.preferability;

            if (preferability != FoodPreferability.NeverForNutrition)
            {
                if (preferability == FoodPreferability.DesperateOnly)
                {
                    num -= 150f;
                }
                var compRottable = t.TryGetComp <CompRottable>();
                if (compRottable != null)
                {
                    if (compRottable.Stage == RotStage.Dessicated)
                    {
                        return(-9999999f);
                    }
                    if (!takingToInventory && compRottable.Stage == RotStage.Fresh &&
                        compRottable.TicksUntilRotAtCurrentTemp < 30000)
                    {
                        num += 12f;
                    }
                }
                if (eater.needs != null && eater.needs.mood != null)
                {
                    var list = ThoughtsFromIngesting(eater, t);
                    for (var i = 0; i < list.Count; i++)
                    {
                        num += FoodOptimalityEffectFromMoodCurve.Evaluate(list[i].stages[0].baseMoodEffect);
                    }
                }
                if (thingDef.ingestible != null)
                {
                    if (eater.RaceProps.Humanlike)
                    {
                        num += thingDef.ingestible.optimalityOffsetHumanlikes;
                    }
                    else if (eater.RaceProps.Animal)
                    {
                        num += thingDef.ingestible.optimalityOffsetFeedingAnimals;
                    }
                }
                return(num);
            }
            return(-9999999f);
        }
コード例 #7
0
        private static int FinalLevelOfSkill(Pawn pawn, SkillDef sk)
        {
            //Rand.PopState();
            //Rand.PushState(RJW_Multiplayer.PredictableSeed());
            float num = (!sk.usuallyDefinedInBackstories) ? Rand.ByCurve(LevelRandomCurve) : ((float)Rand.RangeInclusive(0, 4));

            foreach (Backstory item in from bs in pawn.story.AllBackstories
                     where bs != null
                     select bs)
            {
                foreach (KeyValuePair <SkillDef, int> item2 in item.skillGainsResolved)
                {
                    if (item2.Key == sk)
                    {
                        num += (float)item2.Value * Rand.Range(1f, 1.4f);
                    }
                }
            }
            for (int i = 0; i < pawn.story.traits.allTraits.Count; i++)
            {
                int value = 0;
                if (pawn.story.traits.allTraits[i].CurrentData.skillGains.TryGetValue(sk, out value))
                {
                    num += (float)value;
                }
            }
            float num2 = Rand.Range(1f, AgeSkillMaxFactorCurve.Evaluate((float)pawn.ageTracker.AgeBiologicalYears));

            num *= num2;
            num  = LevelFinalAdjustmentCurve.Evaluate(num);
            return(Mathf.Clamp(Mathf.RoundToInt(num), 0, 20));
        }
コード例 #8
0
        public static float EffectiveCombatPower(this Thing t)
        {
            // Pawn
            if (t is Pawn p)
            {
                float combatPower;

                // If the pawn is a colonist, return the maximum of the kindDef's combatPower rating or the points per colonist based on the wealth of the player's wealthiest settlement
                if (p.IsColonist)
                {
                    var pawnIncidentTarget = Current.Game.World.worldObjects.Settlements.Where(s => s.HasMap && s.Map.IsPlayerHome).MaxBy(s => s.Map.PlayerWealthForStoryteller).Map;
                    combatPower = Mathf.Max(PointsPerColonistByWealthCurve.Evaluate(pawnIncidentTarget.PlayerWealthForStoryteller), p.kindDef.combatPower);
                }

                else
                {
                    combatPower = p.kindDef.combatPower;
                }

                return(combatPower * p.health.summaryHealth.SummaryHealthPercent * p.ageTracker.CurLifeStage.bodySizeFactor);
            }

            // Turret
            if (t is Building_Turret turret)
            {
                // Return 1/6th of its base market value
                return(turret.def.GetStatValueAbstract(StatDefOf.MarketValue, null) / 6);
            }

            throw new NotImplementedException($"Unaccounted effective combat power calculation for {t} (Type={t.GetType().Name})");
        }
コード例 #9
0
        protected override void ResolveInt(ResolveParams parms)
        {
            IntVec2 value = parms.mechClusterSize.Value;
            int     val   = GenMath.RoundRandom((float)GenMath.RoundRandom(WidthToMaxWallsCountCurve.Evaluate(Mathf.Min(value.x, value.z))) * WallCountRandomFactorRange.RandomInRange);

            val = Math.Max(1, val);
            for (int i = 0; i < val; i++)
            {
                TryAddWall(parms.sketch, value);
            }
            if (Rand.Bool)
            {
                ResolveParams parms2 = parms;
                parms2.symmetryVertical       = false;
                parms2.symmetryOrigin         = value.x / 2;
                parms2.symmetryOriginIncluded = (value.x % 2 == 1);
                SketchResolverDefOf.Symmetry.Resolve(parms2);
            }
            else if (Rand.Bool)
            {
                ResolveParams parms3 = parms;
                parms3.symmetryVertical       = true;
                parms3.symmetryOrigin         = value.z / 2;
                parms3.symmetryOriginIncluded = (value.z % 2 == 1);
                SketchResolverDefOf.Symmetry.Resolve(parms3);
            }
        }
        public static float windSpeed(this Map map, WindSpeedUnit unit = WindSpeedUnit.KilometersPerHour)
        {
            // on the basis that map.windManager returns a value that is normally somewhere between 0-2,
            // and can go over 2 in extreme cases. Translated to a 1-12 scale, that's a factor of 6ish.
            var beaufort = map.windManager.WindSpeed * 5.6f;

            if (unit == WindSpeedUnit.Beaufort)
            {
                return(beaufort);
            }

            var kph = WindSpeedCurve.Evaluate(Mathf.Clamp(beaufort, 0, 13));

            if (unit == WindSpeedUnit.KilometersPerHour)
            {
                return(kph);
            }

            return(unit switch
            {
                WindSpeedUnit.MetersPerSecond => kph / 3.6f,
                WindSpeedUnit.MilesPerHour => kph / 1.609f,
                WindSpeedUnit.Knots => kph / 1.852f,
                WindSpeedUnit.FeetPerSecond => kph / 1.097f,
                _ => throw new ArgumentOutOfRangeException(nameof(unit), unit, null)
            });
コード例 #11
0
        public override float GetScore(Room room)
        {
            float num  = 0f;
            int   num2 = 0;

            countedThings.Clear();
            foreach (IntVec3 cell in room.Cells)
            {
                num += BeautyUtility.CellBeauty(cell, room.Map, countedThings);
                num2++;
            }
            countedAdjCells.Clear();
            List <Thing> containedAndAdjacentThings = room.ContainedAndAdjacentThings;

            for (int i = 0; i < containedAndAdjacentThings.Count; i++)
            {
                Thing thing = containedAndAdjacentThings[i];
                if (thing.GetRoom() != room && !countedAdjCells.Contains(thing.Position))
                {
                    num += BeautyUtility.CellBeauty(thing.Position, room.Map, countedThings);
                    countedAdjCells.Add(thing.Position);
                }
            }
            countedThings.Clear();
            if (num2 == 0)
            {
                return(0f);
            }
            return(num / CellCountCurve.Evaluate((float)num2));
        }
コード例 #12
0
        // Token: 0x06001380 RID: 4992 RVA: 0x000956A0 File Offset: 0x00093AA0
        private static void DoubleVertices(SimpleCurve Width)
        {
            List <Vector2> list   = LightningLaserBoltMeshMaker.verts2D.ListFullCopy <Vector2>();
            Vector3        vector = default(Vector3);
            Vector2        a      = default(Vector2);

            LightningLaserBoltMeshMaker.verts2D.Clear();
            //    Log.Message("DoubleVertices Points: " + Width.PointsCount +"  "+ Width.Points.ToString());
            for (int i = 0; i < list.Count; i++)
            {
                if (i <= list.Count - 2)
                {
                    vector = Quaternion.AngleAxis(90f, Vector3.up) * (list[i] - list[i + 1]);
                    a      = new Vector2(vector.y, vector.z);
                    a.Normalize();
                }
                float f     = Mathf.InverseLerp(0, list.Count, i);
                float width = Width.Evaluate(f);
                //    Log.Message("width " + width + " @ " + f);
                Vector2 item  = list[i] - width * a;
                Vector2 item2 = list[i] + width * a;
                LightningLaserBoltMeshMaker.verts2D.Add(item);
                LightningLaserBoltMeshMaker.verts2D.Add(item2);
            }
        }
コード例 #13
0
        private static IntVec3 GenerateShrapnelLocation(IntVec3 center, float angleOffset, float distanceFactor)
        {
            float num = ShrapnelAngleDistribution.Evaluate(Rand.Value);
            float d   = ShrapnelDistanceFromAngle.Evaluate(num) * Rand.Value * distanceFactor;

            return((Vector3Utility.HorizontalVectorFromAngle(num + angleOffset) * d).ToIntVec3() + center);
        }
コード例 #14
0
        private bool DoWork(Slate slate)
        {
            Map map = slate.Get <Map>("map");

            if (map == null)
            {
                return(false);
            }
            float x2 = slate.Get("points", 0f);
            float animalDifficultyFromPoints = pointsToAnimalDifficultyCurve.GetValue(slate).Evaluate(x2);

            if (!map.Biome.AllWildAnimals.Where((PawnKindDef x) => map.mapTemperature.SeasonAndOutdoorTemperatureAcceptableFor(x.race) && map.listerThings.ThingsOfDef(x.race).Any((Thing p) => p.Faction == null)).TryRandomElementByWeight((PawnKindDef x) => AnimalCommonalityByDifficulty(x, animalDifficultyFromPoints), out PawnKindDef result))
            {
                return(false);
            }
            int num = 0;

            for (int i = 0; i < map.mapPawns.AllPawnsSpawned.Count; i++)
            {
                Pawn pawn = map.mapPawns.AllPawnsSpawned[i];
                if (pawn.def == result.race && !pawn.IsQuestLodger() && pawn.Faction == null)
                {
                    num++;
                }
            }
            SimpleCurve value         = pointsToAnimalsToHuntCountCurve.GetValue(slate);
            float       randomInRange = (animalsToHuntCountRandomFactorRange.GetValue(slate) ?? FloatRange.One).RandomInRange;
            int         a             = Mathf.RoundToInt(value.Evaluate(x2) * randomInRange);

            a = Mathf.Min(a, num);
            a = Mathf.Max(a, 1);
            slate.Set(storeAnimalToHuntAs.GetValue(slate), result.race);
            slate.Set(storeCountToHuntAs.GetValue(slate), a);
            return(true);
        }
コード例 #15
0
        private void DoPoseCycleOffsets(ref Vector3 rightHand,
                                        ref List <float> shoulderAngle,
                                        ref List <float> handSwingAngle, PoseCycleDef pose)
        {
            if (!this.CompAnimator.AnimatorPoseOpen)
            {
                return;
            }

            SimpleCurve cycleHandsSwingAngle = pose.HandsSwingAngle;
            SimpleCurve rHandX = pose.HandPositionX;
            SimpleCurve rHandZ = pose.HandPositionZ;

            Rot4 rot = this.BodyFacing;

            // Basic values if pawn is carrying stuff
            float x = 0;
            float y = Offsets.YOffset_Behind;
            float z;

            float        percent   = this._animatedPercent;
            PoseCycleDef poseCycle = this.CompAnimator.PoseCycle;
            float        lookie    = rot == Rot4.West ? -1f : 1f;

            shoulderAngle[1] = lookie * poseCycle?.shoulderAngle ?? 0f;

            handSwingAngle[1] = (rot == Rot4.West ? -1 : 1) * cycleHandsSwingAngle.Evaluate(percent);

            x = rHandX.Evaluate(percent) * lookie;
            z = rHandZ.Evaluate(percent);

            rightHand += new Vector3(x, 0, z);
        }
コード例 #16
0
        public void traitIfStatsMatch(TraitDef trait, RecordDef record, float recordCount, int degree, int age, SimpleCurve ageOverTime, bool changeDegree)
        {
            Pawn  pawn       = this.parent.pawn;
            float x          = (float)age / pawn.RaceProps.lifeExpectancy;
            float daysPassed = (float)(((double)pawn.ageTracker.AgeBiologicalYearsFloat));

            if ((double)daysPassed < 0.0)
            {
                Log.Error("daysPassed < 0, pawn=" + (object)pawn, false);
                return;
            }
            if ((double)Rand.Value < (double)ageOverTime.Evaluate(x))
            {
                if (!(trait.degreeDatas.Count > 1) || changeDegree == false)
                {
                    if (pawn.records.GetValue(record) >= recordCount & !(pawn.story.traits.HasTrait(trait)) & !(pawn.story.traits.HasTrait(trait)))
                    {
                        pawn.story.traits.GainTrait(new Trait(trait, degree, false));
                    }
                }
                else
                {
                    if (pawn.story.traits.HasTrait(trait))
                    {
                        if (!(degree + 1 >= trait.degreeDatas.Count - 1))
                        {
                            pawn.story.traits.GainTrait(new Trait(trait, degree + 1, false));
                        }
                    }
                }
            }
        }
コード例 #17
0
        private float GenerateRequestItems(Quest_ThingsHelp quest, Map map)
        {
            int   totalCount  = 0;
            int   maxCount    = (int)(Rand.Range(2f, 7f) * ValueFactorFromWealthCurve.Evaluate(map.wealthWatcher.WealthTotal));
            float marketValue = 0;

            do
            {
                ThingDef thingDef = RandomRequiredDef();
                int      num      = Rand.Range(20, 150);
                if (num > thingDef.stackLimit)
                {
                    num = thingDef.stackLimit;
                }

                if (quest.RequestItems.ContainsKey(thingDef))
                {
                    quest.RequestItems[thingDef] += num;
                }
                else
                {
                    quest.RequestItems.Add(thingDef, num);
                }

                totalCount++;

                marketValue += num * thingDef.BaseMarketValue;
            }while (totalCount < maxCount);

            return(marketValue);
        }
コード例 #18
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map   map = (Map)parms.target;
            float num = RadiusFactorPerPointsCurve.Evaluate(parms.points);

            if (!TryFindRandomBlightablePlant(map, out Plant plant))
            {
                return(false);
            }
            Room room = plant.GetRoom();
            int  i    = 0;

            for (int num2 = GenRadial.NumCellsInRadius(11f * num); i < num2; i++)
            {
                IntVec3 intVec = plant.Position + GenRadial.RadialPattern[i];
                if (intVec.InBounds(map) && intVec.GetRoom(map) == room)
                {
                    Plant firstBlightableNowPlant = BlightUtility.GetFirstBlightableNowPlant(intVec, map);
                    if (firstBlightableNowPlant != null && firstBlightableNowPlant.def == plant.def && Rand.Chance(BlightChance(firstBlightableNowPlant.Position, plant.Position, num)))
                    {
                        firstBlightableNowPlant.CropBlighted();
                    }
                }
            }
            SendStandardLetter("LetterLabelCropBlight".Translate(new NamedArgument(plant.def, "PLANTDEF")), "LetterCropBlight".Translate(new NamedArgument(plant.def, "PLANTDEF")), LetterDefOf.NegativeEvent, parms, new TargetInfo(plant.Position, map));
            return(true);
        }
コード例 #19
0
        private void StartWithTunnel(List <IntVec3> group, Map map)
        {
            int tunnelSystemCount = GenMath.RoundRandom((float)group.Count * extCaves.startTunnelsPer10k / 10000f);

            tunnelSystemCount = Mathf.Min(tunnelSystemCount, extCaves.maxStartTunnelsPerRockGroup);
            float startWidth = TunnelsWidthPerRockCount.Evaluate((float)group.Count);

            for (int i = 0; i < tunnelSystemCount; i++)
            {
                IntVec3 mostDistantStartingCell = IntVec3.Invalid;
                float   distanceToCave          = -1f;
                float   dir = -1f;
                float   distAtDirToNextEnd = -1f;
                for (int j = 0; j < 10; j++)
                {
                    IntVec3 edgeCell     = FindRandomEdgeCellForTunnel(group, map);
                    float   currDistance = GetDistToCave(edgeCell, group, map, 40f, false);
                    float   currDir8MaxDist;
                    float   currAngle = FindBestInitialDir(edgeCell, group, out currDir8MaxDist);
                    if (!mostDistantStartingCell.IsValid || currDistance > distanceToCave || (currDistance == distanceToCave && currDir8MaxDist > distAtDirToNextEnd))
                    {
                        mostDistantStartingCell = edgeCell;
                        distanceToCave          = currDistance;
                        dir = currAngle;
                        distAtDirToNextEnd = currDir8MaxDist;
                    }
                }
                float width = startWidth * Rand.Range(extCaves.tunnelStartWidthFactorMin, extCaves.tunnelStartWidthFactorMax);
                this.Dig(mostDistantStartingCell, dir, width, group, map, BranchType.Normal, 1);
            }
        }
コード例 #20
0
        // Token: 0x0600137F RID: 4991 RVA: 0x000955F0 File Offset: 0x000939F0
        private static void PeturbVerticesRandomly(SimpleCurve strDist, SimpleCurve strTime = null)
        {
            float          dmod   = 1f;
            Perlin         perlin = new Perlin(0.0070000002160668373, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);
            List <Vector2> list   = LightningLaserBoltMeshMaker.verts2D.ListFullCopy <Vector2>();

            LightningLaserBoltMeshMaker.verts2D.Clear();
            int threshold = (list.Count / 4) * 3;

            //    Log.Message("PeturbVerticesRandomly Points: " + strDist.PointsCount + "  " + strDist.Points.ToString());
            for (int i = 0; i < list.Count; i++)
            {
                float f = Mathf.InverseLerp(0, list.Count, i);
                float d = strDist.Evaluate(f) * (float)perlin.GetValue((double)i, 0.0, 0.0);
                //    Log.Message("str " + d +" @ "+ f);
                if (i > threshold)
                {
                    dmod = 1 - (1 * ((float)(i - threshold) / (list.Count - threshold)));
                    //    Log.Message(string.Format("dmod now: {0}", dmod));
                }
                d = d * dmod;
                //    Log.Message(string.Format("d: {0}", d));
                Vector2 item = list[i] + d * Vector2.right;
                LightningLaserBoltMeshMaker.verts2D.Add(item);
            }
        }
        public static bool Prefix(Faction faction, float totalPoints, RaidStrategyDef raidStrategy, PawnGroupKindDef groupKind, ref float __result)
        {
            HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>();
            HiveFactionExtension        hive             = faction.def.GetModExtension <HiveFactionExtension>();

            if (faction != null)
            {
                if (evolutionTracker != null && hive != null)
                {
                    if (evolutionTracker.HiveFactionStages.TryGetValue(faction.ToString(), out int stage))
                    {
                        SimpleCurve curves = hive.CurStage.maxPawnCostPerTotalPointsCurve ?? faction.def.maxPawnCostPerTotalPointsCurve;
                        float       num    = curves.Evaluate(totalPoints);
                        if (raidStrategy != null)
                        {
                            num = Mathf.Min(num, totalPoints / raidStrategy.minPawns);
                        }
                        num = Mathf.Max(num, faction.def.MinPointsToGeneratePawnGroup(groupKind) * 1.2f);
                        if (raidStrategy != null)
                        {
                            num = Mathf.Max(num, raidStrategy.Worker.MinMaxAllowedPawnGenOptionCost(faction, groupKind) * 1.2f);
                        }
                        __result = num;
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #22
0
        private void CreateRandomExplosion()
        {
            IntVec3 intVec = (from x in GenRadial.RadialCellsAround(base.Position, 15f, useCenter: true)
                              where x.InBounds(base.Map)
                              select x).RandomElementByWeight((IntVec3 x) => DistanceChanceFactor.Evaluate(x.DistanceTo(base.Position)));
            float     num        = (float)Rand.Range(6, 8);
            IntVec3   center     = intVec;
            Map       map        = base.Map;
            float     radius     = num;
            DamageDef bomb       = DamageDefOf.Bomb;
            Thing     instigator = base.instigator;
            ThingDef  def        = base.def;
            ThingDef  weaponDef  = base.weaponDef;

            GenExplosion.DoExplosion(center, map, radius, bomb, instigator, -1, -1f, null, weaponDef, def);
        }
コード例 #23
0
        private static int RandomRequestCount(ThingDef thingDef, Map map)
        {
            float num = (float)BaseValueWantedRange.RandomInRange;

            num *= ValueWantedFactorFromWealthCurve.Evaluate(map.wealthWatcher.WealthTotal);
            return(ThingUtility.RoundedResourceStackCount(Mathf.Max(1, Mathf.RoundToInt(num / thingDef.BaseMarketValue))));
        }
コード例 #24
0
 public void SetGuestStatus(Faction newHost, bool prisoner = false)
 {
     if (newHost != null)
     {
         Released = false;
     }
     if (newHost != HostFaction || prisoner != IsPrisoner)
     {
         if (!prisoner && pawn.Faction.HostileTo(newHost))
         {
             Log.Error("Tried to make " + pawn + " a guest of " + newHost + " but their faction " + pawn.Faction + " is hostile to " + newHost);
         }
         else if (newHost != null && newHost == pawn.Faction && !prisoner)
         {
             Log.Error("Tried to make " + pawn + " a guest of their own faction " + pawn.Faction);
         }
         else
         {
             bool flag = prisoner && (!IsPrisoner || HostFaction != newHost);
             isPrisonerInt  = prisoner;
             hostFactionInt = newHost;
             pawn.ClearMind();
             if (flag)
             {
                 pawn.DropAndForbidEverything();
                 pawn.GetLord()?.Notify_PawnLost(pawn, PawnLostCondition.MadePrisoner);
                 if (newHost == Faction.OfPlayer)
                 {
                     Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(pawn, PopAdaptationEvent.GainedPrisoner);
                 }
                 if (pawn.Drafted)
                 {
                     pawn.drafter.Drafted = false;
                 }
                 float x = pawn.RecruitDifficulty(Faction.OfPlayer);
                 resistance  = StartingResistancePerRecruitDifficultyCurve.Evaluate(x);
                 resistance *= StartingResistanceFactorFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent);
                 resistance *= StartingResistanceRandomFactorRange.RandomInRange;
                 resistance  = (float)GenMath.RoundRandom(resistance);
             }
             PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn);
             pawn.health.surgeryBills.Clear();
             if (pawn.ownership != null)
             {
                 pawn.ownership.Notify_ChangedGuestStatus();
             }
             ReachabilityUtility.ClearCacheFor(pawn);
             if (pawn.Spawned)
             {
                 pawn.Map.mapPawns.UpdateRegistryForPawn(pawn);
                 pawn.Map.attackTargetsCache.UpdateTarget(pawn);
             }
             AddictionUtility.CheckDrugAddictionTeachOpportunity(pawn);
             if (prisoner && pawn.playerSettings != null)
             {
                 pawn.playerSettings.Notify_MadePrisoner();
             }
         }
     }
 }
コード例 #25
0
        public static float AllyIncidentFraction(bool fullAlliesOnly)
        {
            List <Faction> allFactionsListForReading = Find.FactionManager.AllFactionsListForReading;
            int            num  = 0;
            int            num2 = 0;

            for (int i = 0; i < allFactionsListForReading.Count; i++)
            {
                if (!allFactionsListForReading[i].def.hidden && !allFactionsListForReading[i].IsPlayer)
                {
                    if (allFactionsListForReading[i].def.CanEverBeNonHostile)
                    {
                        num2++;
                    }
                    if (allFactionsListForReading[i].PlayerRelationKind == FactionRelationKind.Ally || (!fullAlliesOnly && !allFactionsListForReading[i].HostileTo(Faction.OfPlayer)))
                    {
                        num++;
                    }
                }
            }
            if (num == 0)
            {
                return(-1f);
            }
            float x = (float)num / Mathf.Max(num2, 1f);

            return(AllyIncidentFractionFromAllyFraction.Evaluate(x));
        }
コード例 #26
0
        private static float GetAgeFactor(Pawn f****r, Pawn f****d, int p_age)
        {
            float age_factor;

            //The human age curve needs work. Currently pawns refuse to have sex with anyone over age of ~50 no matter what the other factors are, which is just silly...
            age_factor = f****d.gender == Gender.Male ? attractiveness_from_age_male.Evaluate(SexUtility.ScaleToHumanAge(f****d)) : attractiveness_from_age_female.Evaluate(SexUtility.ScaleToHumanAge(f****d));
            //--Log.Message("would_fuck() - age_factor = " + age_factor.ToString());

            if (xxx.is_animal(f****r))
            {
                age_factor = 1.0f;                  //using flat factors, since human age is not comparable to animal ages
            }
            else if (xxx.is_animal(f****d))
            {
                if (p_age <= 1 && f****d.RaceProps.lifeExpectancy > 8)
                {
                    age_factor = 0.5f;
                }
                else
                {
                    age_factor = 1.0f;
                }
                //--Log.Message("would_fuck() - animal age_factor = " + age_factor.ToString());
            }
            if (Quirk.Gerontophile.IsSatisfiedBy(f****r, f****d))
            {
                age_factor = 1.0f;
            }

            return(age_factor);
        }
コード例 #27
0
        public static float InitiatePrisonBreakMtbDays(Pawn pawn)
        {
            if (!pawn.Awake())
            {
                return(-1f);
            }
            if (!CanParticipateInPrisonBreak(pawn))
            {
                return(-1f);
            }
            Room room = pawn.GetRoom();

            if (room == null || !room.isPrisonCell)
            {
                return(-1f);
            }
            float num = 60f;

            num /= Mathf.Clamp(pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving), 0.01f, 1f);
            if (pawn.guest.everParticipatedInPrisonBreak)
            {
                float x = (float)(Find.TickManager.TicksGame - pawn.guest.lastPrisonBreakTicks) / 60000f;
                num *= PrisonBreakMTBFactorForDaysSincePrisonBreak.Evaluate(x);
            }
            return(num);
        }
コード例 #28
0
        public override float ExtraSelectionWeightFactor(ThingSetMakerParams parms)
        {
            int  num  = 0;
            bool flag = false;

            foreach (ResearchProjectDef allDef in DefDatabase <ResearchProjectDef> .AllDefs)
            {
                if (!allDef.IsFinished && allDef.PrerequisitesCompleted)
                {
                    if (!allDef.TechprintRequirementMet && !PlayerItemAccessibilityUtility.PlayerOrQuestRewardHas(allDef.Techprint, allDef.techprintCount - allDef.TechprintsApplied))
                    {
                        flag = true;
                    }
                    else
                    {
                        num++;
                    }
                }
            }
            if (!flag)
            {
                return(1f);
            }
            return(Mathf.RoundToInt(ResearchableProjectsCountToSelectionWeightCurve.Evaluate(num)));
        }
コード例 #29
0
        private static List <Thing> GenerateRewardsFor(ThingDef thingDef, int quantity, Faction faction, Map map)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = RewardValueFactorRange * RewardValueFactorFromWealthCurve.Evaluate(map.wealthWatcher.WealthTotal) * thingDef.BaseMarketValue * (float)quantity;
            parms.validator             = ((ThingDef td) => td != thingDef);
            List <Thing> list = null;

            for (int i = 0; i < 10; i++)
            {
                if (list != null)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        list[j].Destroy();
                    }
                    list = null;
                }
                list = ThingSetMakerDefOf.Reward_TradeRequest.root.Generate(parms);
                float num = 0f;
                for (int k = 0; k < list.Count; k++)
                {
                    num += list[k].MarketValue * (float)list[k].stackCount;
                }
                if (num > thingDef.BaseMarketValue * (float)quantity)
                {
                    break;
                }
            }
            return(list);
        }
コード例 #30
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!TryFindSettlement(out Faction ally, out Settlement Set))
            {
                return(false);
            }

            // Balance
            List <Thing> rewards = ThingSetMakerDefOf.Reward_StandardByDropPod.root.Generate(new ThingSetMakerParams()
            {
                totalMarketValueRange = new FloatRange?(SiteTuning.BanditCampQuestRewardMarketValueRange * SiteTuning.QuestRewardMarketValueThreatPointsFactor.Evaluate(StorytellerUtility.DefaultSiteThreatPointsNow() + 500f))
            });

            Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);

            silver.stackCount = (int)SilverBonusRewardCurve.Evaluate(ally.PlayerGoodwill);
            int random = new IntRange(Global.DayInTicks * 15, Global.DayInTicks * 25).RandomInRange;

            Set.GetComponent <WorldComp_JointRaid>().StartComp(random, ally, rewards, silver);
            string text = def.letterText.Formatted(ally.leader.LabelShort, ally.def.leaderTitle, ally.Name, GenLabel.ThingsLabel(rewards, string.Empty), random.ToStringTicksToPeriod(), GenThing.GetMarketValue(rewards).ToStringMoney(null), silver.stackCount.ToString()).CapitalizeFirst();

            GenThing.TryAppendSingleRewardInfo(ref text, rewards);
            Find.LetterStack.ReceiveLetter(def.letterLabel, text, def.letterDef, Set, ally, null);
            return(true);
        }