public int MinAgeForPawn(Pawn pawn)
 {
     if (!minAgeLookup.TryGetValue(pawn.def, out int age))
     {
         SimpleCurve simpleCurve = pawn.def.race.ageGenerationCurve;
         if (simpleCurve == null)
         {
             Log.Warning("Prepare Carefully :: No age generation curve defined for " + pawn.def.defName + ". Using default age generation curve to determine minimum age.");
             simpleCurve = DefaultAgeGenerationCurve;
             if (simpleCurve == null)
             {
                 Log.Warning("Prepare Carefully :: Failed to get default age generation curve. Using default minimum age of " + DEFAULT_MIN_AGE);
                 age = DEFAULT_MIN_AGE;
             }
             else
             {
                 age = Mathf.CeilToInt(pawn.def.race.lifeExpectancy * simpleCurve.First().x);
             }
         }
         else
         {
             CurvePoint point = simpleCurve.First();
             age = (int)point.x;
         }
         minAgeLookup.Add(pawn.def, age);
     }
     return(age);
 }
Exemple #2
0
 public VTOLTakeoff(VTOLTakeoff reference, VehiclePawn vehicle) : base(reference, vehicle)
 {
     ticksVertical        = reference.ticksVertical;
     verticalLaunchCurve  = reference.verticalLaunchCurve;
     verticalLandingCurve = reference.verticalLandingCurve;
     ticksPassedVertical  = 0;
 }
 public int MaxAgeForPawn(Pawn pawn)
 {
     if (!maxAgeLookup.TryGetValue(pawn.def, out int age))
     {
         SimpleCurve simpleCurve = pawn.def.race.ageGenerationCurve;
         if (simpleCurve == null)
         {
             Logger.Warning("No age generation curve defined for " + pawn.def.defName + ". Using default age generation curve to determine maximum age.");
             simpleCurve = DefaultAgeGenerationCurve;
             if (simpleCurve == null)
             {
                 Logger.Warning("Failed to get default age generation curve. Using default maximum age of " + DEFAULT_MAX_AGE);
                 age = DEFAULT_MAX_AGE;
             }
             else
             {
                 age = Mathf.CeilToInt(pawn.def.race.lifeExpectancy * simpleCurve.Last().x);
             }
         }
         else
         {
             CurvePoint point = simpleCurve.Last();
             age = (int)(point.x * 1.2f);
         }
         maxAgeLookup.Add(pawn.def, age);
     }
     return(age);
 }
        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);
        }
Exemple #5
0
 private void OnLoseLeader()
 {
     if (!_collected && ReturnHomeWhenLost)
     {
         Alarm.Set(this, 0.15f, delegate
         {
             RustBerry strawberry = this;
             Vector2 vector       = (_start - Position).SafeNormalize();
             float num            = Vector2.Distance(Position, _start);
             float scaleFactor    = Calc.ClampedMap(num, 16f, 120f, 16f, 96f);
             Vector2 control      = _start + vector * 16f + vector.Perpendicular() * scaleFactor * Calc.Random.Choose(1, -1);
             SimpleCurve curve    = new SimpleCurve(Position, _start, control);
             Tween tween          = Tween.Create(Tween.TweenMode.Oneshot, Ease.SineOut, MathHelper.Max(num / 100f, 0.4f), start: true);
             tween.OnUpdate       = delegate(Tween f)
             {
                 strawberry.Position = curve.GetPoint(f.Eased);
             };
             tween.OnComplete = delegate
             {
                 Depth = 0;
             };
             Add(tween);
         });
     }
 }
Exemple #6
0
        public IEnumerator UseRoutine(Vector2 target)
        {
            Turning = true;
            follower.MoveTowardsLeader = false;
            wiggler.Start();
            wobbleActive = false;
            sprite.Y     = 0f;
            Vector2     from  = Position;
            SimpleCurve curve = new SimpleCurve(from, target, (target + from) / 2f + new Vector2(0f, -48f));

            tween          = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeOut, 1f, start: true);
            tween.OnUpdate = delegate(Tween t)
            {
                Position    = curve.GetPoint(t.Eased);
                sprite.Rate = 1f + t.Eased * 2f;
            };
            Add(tween);
            yield return(tween.Wait());

            tween = null;
            while (sprite.CurrentAnimationFrame != 0)
            {
                yield return(null);
            }
            shimmerParticles.Active = false;
            Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
            for (int j = 0; j < 16; j++)
            {
                SceneAs <Level>().ParticlesFG.Emit(P_Insert, Center, (float)Math.PI / 8f * (float)j);
            }
            sprite.Visible = false;
            light.Visible  = false;
            Turning        = false;
        }
Exemple #7
0
        public void UpdatePacks()
        {
            if (enableDebug && multiThreaded)
            {
                //Log.Message("Thread started.");
            }
            IEnumerable <Pawn> pawnsOnMap = RimValiUtility.AllPawnsOfRaceInWorld(AvaliDefs.RimVali).Where <Pawn>(x => RimValiUtility.GetPackSize(x) < maxSize);

            foreach (Pawn pawn in pawnsOnMap)
            {
//Log.Message(pawn.Faction.Name);
                //Log.Message(pawn.Name.ToString() + " updatePacks()");
                PackComp comp = pawn.TryGetComp <PackComp>();
                if (!(comp == null))
                {
                    //Pull the comp info from the pawn
                    SimpleCurve ageCurve = comp.Props.packGenChanceOverAge;
                    //Tells us that this pawn has had a pack
                    if (enableDebug)
                    {
                        //Log.Message("Attempting to make pack.. [Base pack]");
                    }
                    //Makes the pack.
                    //Log.Message("EiPackHandlerFromPackDriverMapComp started.");
                    packs = RimValiUtility.EiPackHandler(packs, pawn, racesInPacks, maxSize);
                }
            }
        }
Exemple #8
0
        //private SimpleCurve MinIncidentCountMultiplier = new SimpleCurve
        //{
        //    {0f,   1f}
        //};
        //private SimpleCurve MaxIncidentCountMultiplier = new SimpleCurve
        //{
        //    {0f,   1f}
        //};
        //private SimpleCurve IncidentCycleAcceleration = new SimpleCurve
        //{
        //    {0f,   1f}
        //};

        public override void ExposeData()
        {
            base.ExposeData();

            var points1 = MTBEventOccurs_Multiplier.ToList();

            //List<CurvePoint> points2 = MinIncidentCountMultiplier.ToList();
            //List<CurvePoint> points3 = MaxIncidentCountMultiplier.ToList();
            //List<CurvePoint> points4 = IncidentCycleAcceleration.ToList();

            Scribe_Collections.Look(ref points1, "MTBEventOccurs_Multiplier");
            //Scribe_Collections.Look<CurvePoint>(ref points2, "MinIncidentCountMultiplier");
            //Scribe_Collections.Look<CurvePoint>(ref points3, "MaxIncidentCountMultiplier");
            //Scribe_Collections.Look<CurvePoint>(ref points4, "IncidentCycleAcceleration");

            if (points1 != null)
            {
                MTBEventOccurs_Multiplier = ListToSimpleCurve(points1);
            }

            //if (points2 != null)
            //{
            //    MinIncidentCountMultiplier = ListToSimpleCurve(points2);
            //}
            //if (points3 != null)
            //{
            //    MaxIncidentCountMultiplier = ListToSimpleCurve(points3);
            //}
            //if (points4 != null)
            //{
            //    IncidentCycleAcceleration = ListToSimpleCurve(points4);
            //}
        }
Exemple #9
0
        public void UpdatePacks()
        {
            IEnumerable <Pawn> pawnsOnMap = RimValiUtility.AllPawnsOfRaceOnMap(AvaliDefs.RimVali, map).Where(x => (RimValiUtility.GetPackSize(x, x.TryGetComp <PackComp>().Props.relation) < maxSize) & racesInPacks.Contains(x.def));

            foreach (Pawn pawn in pawnsOnMap)
            {
                PackComp comp = pawn.TryGetComp <PackComp>();
                if (!(comp == null))
                {
                    //Pull the comp info from the pawn
                    PawnRelationDef relationDef = comp.Props.relation;
                    SimpleCurve     ageCurve    = comp.Props.packGenChanceOverAge;
                    if (RimValiUtility.GetPackSize(pawn, relationDef) == 1)
                    {
                        //Tells us that this pawn has had a pack
                        if (enableDebug)
                        {
                            Log.Message("Attempting to make pack.. [Base pack]");
                        }
                        //Makes the pack.
                        RimValiUtility.KeoBuildMakePack(pawn, relationDef, racesInPacks, maxSize);
                    }
                }
            }
        }
Exemple #10
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);
        }
        // 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);
            }
        }
        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);
        }
        // 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);
            }
        }
 public virtual void ResolveReferences(VehicleDef def)
 {
     if (efficiency is null)
     {
         efficiency = new SimpleCurve()
         {
             new CurvePoint(0.25f, 0),
             new CurvePoint(0.35f, 0.35f),
             new CurvePoint(0.75f, 0.75f),
             new CurvePoint(0.85f, 1),
             new CurvePoint(1, 1)
         };
     }
     if (categories is null)
     {
         categories = new List <VehicleStatCategoryDef>();
     }
     if (compClass is null)
     {
         compClass = typeof(VehicleComponent);
     }
     if (!explosionProperties.Empty)
     {
         explosionProperties.Def = DefDatabase <DamageDef> .GetNamed(explosionProperties.damageDef);
     }
     hitbox.Initialize(def);
 }
 public void ApplyStats(SimpleCurve to)
 {
     if (to != null)
     {
         Util.Populate(out List <CurvePoint> l, this.points, v => new CurvePoint(v.ToVector2()));
         to.SetPoints(l);
     }
 }
 public static void NewFormula(ref float __result, Pawn initiator, Pawn recipient)
 {
     if (PsycheHelper.PsychologyEnabled(initiator))
     {
         SimpleCurve opinionCurve = Traverse.Create(typeof(NegativeInteractionUtility)).Field("CompatibilityFactorCurve").GetValue <SimpleCurve>();
         __result /= opinionCurve.Evaluate(initiator.relations.CompatibilityWith(recipient));
         __result *= 2f * PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive);
     }
 }
Exemple #17
0
        public override void ResolveProperties(LaunchProtocol reference)
        {
            base.ResolveProperties(reference);
            VTOLTakeoff vtolReference = reference as VTOLTakeoff;

            verticalLaunchCurve  = vtolReference.verticalLaunchCurve;
            verticalLandingCurve = vtolReference.verticalLandingCurve;
            ticksVertical        = vtolReference.ticksVertical;
        }
Exemple #18
0
        static bool Prefix(ref float __result, JobGiver_OptimizeApparel __instance, Pawn pawn, Apparel ap)
        {
            Log.Message("1 pawn is " + ((pawn == null) ? "null" : "not null"));

            if (pawn != null)
            {
                return(true);
            }
            Log.Message("2");

            if (HitPointsPercentScoreFactorCurve == null)
            {
                HitPointsPercentScoreFactorCurve        = typeof(JobGiver_OptimizeApparel).GetField("HitPointsPercentScoreFactorCurve", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as SimpleCurve;
                InsulationColdScoreFactorCurve_NeedWarm = typeof(JobGiver_OptimizeApparel).GetField("InsulationColdScoreFactorCurve_NeedWarm", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as SimpleCurve;
                NeedWarmthFI = typeof(JobGiver_OptimizeApparel).GetField("neededWarmth", BindingFlags.Static | BindingFlags.NonPublic);
            }
            Log.Message("HitPointsPercentScoreFactorCurve is " + ((HitPointsPercentScoreFactorCurve == null) ? "null" : "not null"));
            Log.Message("InsulationColdScoreFactorCurve_NeedWarm is " + ((InsulationColdScoreFactorCurve_NeedWarm == null) ? "null" : "not null"));
            Log.Message("NeedWarmthFI is " + ((NeedWarmthFI == null) ? "null" : "not null"));
            Log.Message("NeedWarmth is " + NeedWarmthFI.GetValue(null));

            float result = 0.1f + ap.GetStatValue(StatDefOf.ArmorRating_Sharp) + ap.GetStatValue(StatDefOf.ArmorRating_Blunt);

            if (ap.def.useHitPoints)
            {
                float x = (float)ap.HitPoints / (float)ap.MaxHitPoints;
                result *= HitPointsPercentScoreFactorCurve.Evaluate(x);
            }
            result += ap.GetSpecialApparelScoreOffset();
            float num3 = 1f;

            if ((NeededWarmth)NeedWarmthFI.GetValue(null) == NeededWarmth.Warm)
            {
                float statValue = ap.GetStatValue(StatDefOf.Insulation_Cold);
                num3 *= InsulationColdScoreFactorCurve_NeedWarm.Evaluate(statValue);
            }
            result *= num3;
            if (ap.WornByCorpse)
            {
                result -= 0.5f;
                if (result > 0f)
                {
                    result *= 0.1f;
                }
            }
            if (ap.Stuff == ThingDefOf.Human.race.leatherDef)
            {
                result -= 0.5f;
                if (result > 0f)
                {
                    result *= 0.1f;
                }
            }
            __result = result;
            return(false);
        }
Exemple #19
0
        private void SetupRainfallNoise()
        {
            float      freqMultiplier = WorldGenStep_Terrain.FreqMultiplier;
            ModuleBase input          = new Perlin(0.014999999664723873 * freqMultiplier, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StorePlanetNoise(input, "basePerlin");
            SimpleCurve simpleCurve = new SimpleCurve();

            simpleCurve.Add(0f, 1.12f, true);
            simpleCurve.Add(25f, 0.94f, true);
            simpleCurve.Add(45f, 0.7f, true);
            simpleCurve.Add(70f, 0.3f, true);
            simpleCurve.Add(80f, 0.05f, true);
            simpleCurve.Add(90f, 0.05f, true);
            ModuleBase moduleBase = new AbsLatitudeCurve(simpleCurve, 100f);

            NoiseDebugUI.StorePlanetNoise(moduleBase, "latCurve");
            this.noiseRainfall = new Multiply(input, moduleBase);
            float      num    = 0.000222222225f;
            float      num2   = (float)(-500.0 * num);
            ModuleBase input2 = new ScaleBias((double)num, (double)num2, this.noiseElevation);

            input2 = new ScaleBias(-1.0, 1.0, input2);
            input2 = new Clamp(0.0, 1.0, input2);
            NoiseDebugUI.StorePlanetNoise(input2, "elevationRainfallEffect");
            this.noiseRainfall = new Multiply(this.noiseRainfall, input2);
            Func <double, double> processor = delegate(double val)
            {
                if (val < 0.0)
                {
                    val = 0.0;
                }
                if (val < 0.12)
                {
                    val = (val + 0.12) / 2.0;
                    if (val < 0.03)
                    {
                        val = (val + 0.03) / 2.0;
                    }
                }
                return(val);
            };

            this.noiseRainfall = new Arbitrary(this.noiseRainfall, processor);
            this.noiseRainfall = new Power(this.noiseRainfall, new Const(1.5));
            this.noiseRainfall = new Clamp(0.0, 999.0, this.noiseRainfall);
            NoiseDebugUI.StorePlanetNoise(this.noiseRainfall, "noiseRainfall before mm");
            this.noiseRainfall = new ScaleBias(4000.0, 0.0, this.noiseRainfall);
            SimpleCurve rainfallCurve = Find.World.info.overallRainfall.GetRainfallCurve();

            if (rainfallCurve != null)
            {
                this.noiseRainfall = new CurveSimple(this.noiseRainfall, rainfallCurve);
            }
        }
        public static void CurveEditor(this Listing_Standard instance, ref SimpleCurve curve)
        {
            var rect = instance.GetRect(100f);

            Widgets.DrawBoxSolid(rect, Color.black);
            var innerRect = rect.ContractedBy(2f);

            //SimpleCurveDrawer.DrawCurve(innerRect, curve);
            Widgets.ButtonInvisibleDraggable(innerRect);
        }
Exemple #21
0
        public static SimpleCurve CreateCurveFrom(List <Vector2> curvePoints)
        {
            SimpleCurve curve = new SimpleCurve();

            for (int i = 0; i < curvePoints.Count(); i++)
            {
                curve.Add(new CurvePoint(curvePoints[i]));
            }
            return(curve);
        }
        public static void ChangeStageAgesCurve(List <ThingDef_AlienRace> CurrentAliensdef)
        {
            foreach (ThingDef_AlienRace ar in CurrentAliensdef)
            {
                if (ar.defName != "Ratkin")
                {
                    // change life stage
                    List <LifeStageAge> lifeStageAges = ar.race.lifeStageAges;
                    lifeStageAges[1].minAge *= 0.75f;
                    lifeStageAges[2].minAge *= 0.75f;

                    SimpleCurve newAgeCurve = new SimpleCurve
                    {
                        {
                            new CurvePoint(ar.race.lifeStageAges[2].minAge, 0f),              //3
                            true
                        },
                        {
                            new CurvePoint(ar.race.lifeStageAges[2].minAge + 2f, 10f),              //5
                            true
                        },
                        {
                            new CurvePoint((ar.race.lifeStageAges[2].minAge + ar.race.lifeStageAges[3].minAge) / 2f, 40f),              //6
                            true
                        },
                        {
                            new CurvePoint(ar.race.lifeStageAges[3].minAge, 75f),          //14
                            true
                        },
                        {
                            new CurvePoint(ar.race.lifeStageAges[4].minAge + 3f, 95f),            //23
                            true
                        },
                        {
                            new CurvePoint(ar.race.lifeStageAges[3].minAge + 10f, 85f),           //30
                            true
                        },
                        {
                            new CurvePoint((ar.race.lifeStageAges[3].minAge + ar.race.lifeExpectancy) / 2f, 30f),            //60
                            true
                        },
                        {
                            new CurvePoint(ar.race.lifeExpectancy, 9f),             //80
                            true
                        },
                        {
                            new CurvePoint(ar.race.lifeExpectancy * 100f / 80f, 0f),             //100
                            true
                        }
                    };
                    // change curve
                    ar.race.ageGenerationCurve = newAgeCurve;
                }
            }
        }
Exemple #23
0
        private SimpleCurve ListToSimpleCurve(List <CurvePoint> list)
        {
            var curves = new SimpleCurve();

            foreach (var curvePoint in list)
            {
                curves.Add(curvePoint);
            }

            return(curves);
        }
Exemple #24
0
        public override float Calculate(Pawn observer, Pawn assessed)
        {
            SimpleCurve curve = GradualRomanceMod.GetAttractivenessCurveFor(assessed);

            if (curve == null)
            {
                ThingDef assessedRace = assessed.def;
                Log.Error("NoAttractivenessCurve_error".Translate(assessedRace.defName));
                return(0f);
            }
            return(curve.Evaluate(assessed.ageTracker.AgeBiologicalYearsFloat));
        }
 public static void SetSeasonalCurve()
 {
     if (Planets_GameComponent.axialTilt == AxialTilt.VeryLow)
     {
         SimpleCurve veryLowTilt = new SimpleCurve()
         {
             { new CurvePoint(0f, 0.75f), true },
             { new CurvePoint(0.1f, 1f), true },
             { new CurvePoint(1f, 7f), true }
         };
         Planets_TemperatureTuning.SeasonalTempVariationCurve = veryLowTilt;
     }
     else if (Planets_GameComponent.axialTilt == AxialTilt.Low)
     {
         SimpleCurve lowTilt = new SimpleCurve()
         {
             { new CurvePoint(0f, 1.5f), true },
             { new CurvePoint(0.1f, 2f), true },
             { new CurvePoint(1f, 14f), true }
         };
         Planets_TemperatureTuning.SeasonalTempVariationCurve = lowTilt;
     }
     else if (Planets_GameComponent.axialTilt == AxialTilt.Normal)
     {
         SimpleCurve normalTilt = new SimpleCurve()
         {
             { new CurvePoint(0f, 3f), true },
             { new CurvePoint(0.1f, 4f), true },
             { new CurvePoint(1f, 28f), true }
         };
         Planets_TemperatureTuning.SeasonalTempVariationCurve = normalTilt;
     }
     else if (Planets_GameComponent.axialTilt == AxialTilt.High)
     {
         SimpleCurve highTilt = new SimpleCurve()
         {
             { new CurvePoint(0f, 4.5f), true },
             { new CurvePoint(0.1f, 6f), true },
             { new CurvePoint(1f, 42f), true }
         };
         Planets_TemperatureTuning.SeasonalTempVariationCurve = highTilt;
     }
     else
     {
         SimpleCurve veryHighTilt = new SimpleCurve()
         {
             { new CurvePoint(0f, 6f), true },
             { new CurvePoint(0.1f, 8f), true },
             { new CurvePoint(1f, 56f), true }
         };
         Planets_TemperatureTuning.SeasonalTempVariationCurve = veryHighTilt;
     }
 }
Exemple #26
0
        public void makeTraits(int item)
        {
            Pawn        pawn         = this.parent.pawn;
            float       recordCounts = traitsOverTimes[item].recordCount;
            TraitDef    traitDef     = traitsOverTimes[item].traitDef;
            SimpleCurve ageOverTime  = traitsOverTimes[item].ageFractionCurve;
            RecordDef   records      = traitsOverTimes[item].recordDef;
            int         degree       = traitsOverTimes[item].degree;
            bool        changeDegree = traitsOverTimes[item].changeDegree;

            traitIfStatsMatch(traitDef, records, recordCounts, degree, pawn.ageTracker.AgeBiologicalYears, ageOverTime, changeDegree);
        }
        /// <summary>
        ///     Recalculates the seasonal temperature curve in this biome
        /// </summary>
        /// <param name="value">The maximal shift</param>
        private void RecalculateSeasonalCurve(float value)
        {
            value = value / 2;
            var shift = value / 28;

            seasonalTempVariationCurve = new SimpleCurve
            {
                new CurvePoint(0.0f, 3f * shift),
                new CurvePoint(0.1f, 4f * shift),
                new CurvePoint(1f, value)
            };
        }
        public override void DoSettingsWindowContents(Rect inRect)
        {
            int ransomRaidDelay    = Mathf.RoundToInt(this.settings.ransomRaidDelay / (float)GenDate.TicksPerHour);
            int ransomFailCooldown = Mathf.RoundToInt(this.settings.ransomFailCooldown / (float)GenDate.TicksPerHour);

            Rect sliderSection = inRect.TopPart(0.7f);

            this.settings.ransomFactor = (int)Widgets.HorizontalSlider(rect: sliderSection.TopHalf().TopHalf().BottomHalf(), value: this.settings.ransomFactor, leftValue: 1f, rightValue: 5f, middleAlignment: true, label: "SettingsRansomFactor".Translate(this.settings.ransomFactor), leftAlignedLabel: "1", rightAlignedLabel: "5");
            ransomRaidDelay            = (int)Widgets.HorizontalSlider(rect: sliderSection.TopHalf().BottomHalf().TopHalf(), value: ransomRaidDelay, leftValue: 1f, rightValue: 168f, middleAlignment: true, label: "SettingsRansomRaidDelay".Translate(this.settings.ransomRaidDelay.ToStringTicksToPeriod()), leftAlignedLabel: "1", rightAlignedLabel: "168");
            ransomFailCooldown         = (int)Widgets.HorizontalSlider(rect: sliderSection.BottomHalf().TopHalf().TopHalf(), value: ransomFailCooldown, leftValue: ransomRaidDelay, rightValue: 336f, middleAlignment: true, label: "SettingsRansomFailCooldown".Translate(this.settings.ransomFailCooldown.ToStringTicksToPeriod()), leftAlignedLabel: ransomRaidDelay.ToString(), rightAlignedLabel: "336");
            this.settings.adjustment   = (int)Widgets.HorizontalSlider(rect: sliderSection.BottomHalf().BottomHalf().TopHalf(), value: this.settings.adjustment, leftValue: 40f, rightValue: 95f, middleAlignment: true, label: "SettingsRansomAdjustment".Translate(this.settings.adjustment), leftAlignedLabel: "40", rightAlignedLabel: "95");

            this.settings.ransomRaidDelay    = ransomRaidDelay * GenDate.TicksPerHour;
            this.settings.ransomFailCooldown = ransomFailCooldown * GenDate.TicksPerHour;

            SimpleCurve curve = new SimpleCurve();

            for (int i = -50; i <= 50; i++)
            {
                curve.Add(i, RansomSettings.RansomChanceRaw(-75, 10, i) * 100);
            }

            SimpleCurveDrawInfo drawInfo = new SimpleCurveDrawInfo()
            {
                curve  = curve,
                color  = Color.cyan,
                label  = "LABEL",
                labelY = "Prob"
            };

            SimpleCurveDrawer.DrawCurve(inRect.BottomPart(0.3f), drawInfo, new SimpleCurveDrawerStyle
            {
                DrawBackground      = false,
                DrawBackgroundLines = false,
                DrawCurveMousePoint = true,
                DrawLegend          = true,
                DrawMeasures        = true,
                DrawPoints          = false,
                FixedScale          = new Vector2(0, 100),
                FixedSection        = new FloatRange(-50, 50),
                LabelX = "Adj",
                MeasureLabelsXCount      = 10,
                MeasureLabelsYCount      = 10,
                OnlyPositiveValues       = false,
                PointsRemoveOptimization = false,
                UseAntiAliasedLines      = true,
                UseFixedScale            = true,
                UseFixedSection          = true,
                XIntegersOnly            = true,
                YIntegersOnly            = true
            });
        }
Exemple #29
0
        private IEnumerator MoveNumberCoroutine(Vector2 start, Vector2 end)
        {
            yield return(.4f);

            SimpleCurve curve = new SimpleCurve(start, end, (start + end) / 2f + new Vector2(0f, 48f));

            for (float t = 0f; t < 1f; t += Engine.DeltaTime)
            {
                yield return(null);

                Position = curve.GetPoint(Ease.CubeInOut(t));
            }
        }
        public static Mesh NewBoltMesh(Vector2 vector, SimpleCurve strDist = null, SimpleCurve widthDist = null, SimpleCurve strTime = null, SimpleCurve widthTime = null, float originVariance = 0.0f, float capSize = 1.0f, float vertexInterval = 0.25f)
        {
            LightningLaserBoltMeshMaker.lightningOrigin = vector;

            /*
             * lightningOrigin.x += Rand.Range(-originVariance, originVariance);
             * lightningOrigin.y += Rand.Range(-originVariance, originVariance);
             */
            LightningLaserBoltMeshMaker.MakeVerticesBase(vertexInterval, originVariance);
            LightningLaserBoltMeshMaker.PeturbVerticesRandomly(strDist);
            LightningLaserBoltMeshMaker.DoubleVertices(widthDist);
            return(LightningLaserBoltMeshMaker.MeshFromVerts());
        }
        public PawnCalcForApparel(Saveable_Pawn saveablePawn, Month month, float temperatureAjust)
        {
            this.saveablePawn = saveablePawn;
            this.pawn = saveablePawn.pawn;
            this.outfit = pawn.outfits.CurrentOutfit;
            this.stats = saveablePawn.NormalizeCalculedStatDef().ToArray();

            float targetTemperature = GenTemperature.AverageTemperatureAtWorldCoordsForMonth(Find.Map.WorldCoords, month) + temperatureAjust;

            #region [  needWarmCurve  ]

            float stat = this.pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null);

            stat = targetTemperature - stat;

            Log.Message("Target: " + targetTemperature + "     Stat: " + this.pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) + "    Value: " + stat);

            if (stat > 10f)
                this.needWarmCurve = new SimpleCurve { new CurvePoint(0f, 1f) };
            else
                if (stat > 3f)
                    this.needWarmCurve = new SimpleCurve
                        {
                            new CurvePoint(+10f, -1.00f),
                            new CurvePoint(+03f, +0.00f),
                            new CurvePoint(+00f, +1.00f),
                            new CurvePoint(-03f, +1.10f)
                        };
                else
                    if (stat > 0)
                        this.needWarmCurve = new SimpleCurve
                            {
                                new CurvePoint(+03f, -1.00f),
                                new CurvePoint(+01f, -1.00f),
                                new CurvePoint(+00f, +1.00f),
                                new CurvePoint(-03f, +1.20f),
                                new CurvePoint(-10f, +1.50f)
                            };
                    else
                        if (stat > -3)
                            this.needWarmCurve = new SimpleCurve
                            {
                                new CurvePoint(+03f, -1.00f),
                                new CurvePoint(+01f, -1.00f),
                                new CurvePoint(+00f, +1.00f),
                                new CurvePoint(-03f, +1.20f),
                                new CurvePoint(-100f, +2.00f)
                            };
                        else
                            this.needWarmCurve = new SimpleCurve
                                {
                                    new CurvePoint(+01f, -1.00f),
                                    new CurvePoint(+00f, +1.00f),
                                    new CurvePoint(-03f, +1.50f),
                                    new CurvePoint(-100f, +20.00f)
                                };

            #endregion

            #region [  needCoolCurve  ]

            stat = this.pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax, null);

            stat = targetTemperature - stat;

            if (stat < -10)
                this.needCoolCurve = new SimpleCurve { new CurvePoint(0f, 1f) };
            else
                if (stat < -3)
                    this.needCoolCurve = new SimpleCurve
                        {
                            new CurvePoint(-10f, -1.00f),
                            new CurvePoint(-03f, +0.00f),
                            new CurvePoint(+00f, +1.00f),
                            new CurvePoint(+03f, +1.10f)
                        };
                else
                    if (stat < 0)
                        this.needCoolCurve = new SimpleCurve
                            {
                                new CurvePoint(-03f, -1.00f),
                                new CurvePoint(-01f, -1.00f),
                                new CurvePoint(+00f, +1.00f),
                                new CurvePoint(+03f, +1.20f),
                                new CurvePoint(+10f, +1.50f)
                            };
                    else
                        this.needCoolCurve = new SimpleCurve
                            {
                                new CurvePoint(-01f, -1.00f),
                                new CurvePoint(+00f, +1.00f),
                                new CurvePoint(+03f, +1.50f),
                                new CurvePoint(+100f, +20.00f)
                            };

            #endregion
        }