Beispiel #1
0
 public static void Start(ThingDef Computer)
 {
     State.LoadCLRPackage();
     try
     {
         State.DoString(@" import ('RimCompute.dll', 'RimCompute')");
     }
     catch (Exception E)
     {
         LuaOutput += "Error loading RimCompute dll\n" + E + "\n";
     }
     try
     {
         State.DoString(@" local Stuf = RimLua()");
     }
     catch (Exception E)
     {
         LuaOutput += "Error loading RimCompute library\n" + E + "\n";
     }
     try
     {
         State.DoFile(Computer.GetModExtension <Script>().ScriptPath);
     }
     catch (Exception E)
     {
         LuaOutput += "Error loading script " + Computer.GetModExtension <Script>().ScriptName + "\n" + E + "\n";
     }
 }
 static void DisplayBlueprintGraphic(Graphic baseGraphic, ThingDef thingDef, Color ghostCol, ref Graphic __result)
 {
     if (thingDef.GetModExtension <ShowBlueprintExtension>() != null && thingDef.GetModExtension <ShowBlueprintExtension>().showBlueprintInGhostMode)
     {
         Graphic graphic = GraphicDatabase.Get(typeof(Graphic_Multi), thingDef.building.blueprintGraphicData.texPath, ShaderTypeDefOf.Cutout.Shader, baseGraphic.drawSize, Color.white, Color.white, thingDef.building.blueprintGraphicData, null);
         __result = graphic;
     }
 }
Beispiel #3
0
        // Token: 0x06000058 RID: 88 RVA: 0x0000567C File Offset: 0x0000387C
        public static bool GetProxAlly(ThingDef thingdef)
        {
            if (!thingdef.HasModExtension <ProximityDefs>())
            {
                return(false);
            }

            _ = thingdef.GetModExtension <ProximityDefs>().ProxAlly;
            return(new bool?(thingdef.GetModExtension <ProximityDefs>().ProxAlly).Value);
        }
Beispiel #4
0
        // Token: 0x0600005F RID: 95 RVA: 0x00005890 File Offset: 0x00003A90
        public static List <string> GetProxEquipped(ThingDef thingdef)
        {
            if (!thingdef.HasModExtension <ProximityDefs>() ||
                thingdef.GetModExtension <ProximityDefs>().ProxEquipped == null)
            {
                return(null);
            }

            return(thingdef.GetModExtension <ProximityDefs>().ProxEquipped);
        }
Beispiel #5
0
        // Token: 0x0600004E RID: 78 RVA: 0x000053B2 File Offset: 0x000035B2
        public static string GetProxHediff(ThingDef thingdef)
        {
            if (!thingdef.HasModExtension <ProximityDefs>() ||
                thingdef.GetModExtension <ProximityDefs>().ProxHediff == null)
            {
                return("");
            }

            return(thingdef.GetModExtension <ProximityDefs>().ProxHediff);
        }
        public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, IntVec3 cell, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null)
        {
            ThingDef         HiveDef   = hiveDef ?? RimWorld.ThingDefOf.Hive;
            HiveDefExtension HiveExt   = HiveDef.GetModExtension <HiveDefExtension>();
            ThingDef         TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner;
            HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>();

            if (extension != null && extension.TunnelDef != null)
            {
                TunnelDef = extension.TunnelDef;
            }
            Thing             thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
            TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner;

            if (hiveSpawner != null)
            {
                if (hiveSpawner.faction == null && faction != null)
                {
                    hiveSpawner.faction = faction;
                }
            }
            if (hiveSpawner.SpawnedFaction != null)
            {
                //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
            }
            QuestUtility.AddQuestTag(thing, questTag);
            CompSpawnerHives spawnerHives = thing.TryGetComp <CompSpawnerHives>();

            if (spawnerHives?.Props.tunnelDef != null)
            {
                TunnelDef = spawnerHives.Props.tunnelDef;
            }
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
                    hiveSpawner = thing as TunnelHiveSpawner;
                    if (hiveSpawner != null)
                    {
                        if (hiveSpawner.faction == null && faction != null)
                        {
                            hiveSpawner.faction = faction;
                        }
                    }
                    if (hiveSpawner.SpawnedFaction != null)
                    {
                        //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
                    }
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }
Beispiel #7
0
 public static void Postfix(ThingDef __instance, ref IEnumerable <StatDrawEntry> __result)
 {
     if (__instance.GetModExtension <AnimalStatExtension>() != null && !__instance.IsCorpse)
     {
         AnimalStatExtension extension = __instance.GetModExtension <AnimalStatExtension>();
         foreach (string stat in extension.statToAdd)
         {
             __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, stat.Translate(), extension.statValues[extension.statToAdd.IndexOf(stat)].Translate(), extension.statDescriptions[extension.statToAdd.IndexOf(stat)].Translate()
                                                           , 1));
         }
     }
 }
        public static void Postfix_SpecialDisplayStats(ThingDef __instance, ref IEnumerable <StatDrawEntry> __result, StatRequest req)
        {
            // Tool def
            if (req.Thing == null && __instance.IsSurvivalTool(out SurvivalToolProperties tProps))
            {
                foreach (StatModifier modifier in tProps.baseWorkStatFactors)
                {
                    __result = __result.Add(new StatDrawEntry(ST_StatCategoryDefOf.SurvivalTool,
                                                              modifier.stat.LabelCap,
                                                              modifier.value.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor),
                                                              overrideReportText: modifier.stat.description));
                }
            }

            // Stuff
            if (__instance.IsStuff && __instance.GetModExtension <StuffPropsTool>() is StuffPropsTool sPropsTool)
            {
                foreach (StatModifier modifier in sPropsTool.toolStatFactors)
                {
                    __result = __result.Add(new StatDrawEntry(ST_StatCategoryDefOf.SurvivalToolMaterial,
                                                              modifier.stat.LabelCap,
                                                              modifier.value.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor),
                                                              overrideReportText: modifier.stat.description));
                }
            }
        }
Beispiel #9
0
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            //base.DrawGhost(def, center, rot, ghostCol, thing);
            IntVec3 inputCell  = center;
            IntVec3 outputCell = center;

            //outputCell = center + rot.FacingCell;
            inputCell = center + rot.Opposite.FacingCell;

            //Not shure how i should sopport the angeled one
            bool isRight = false;

            if (thing != null && !thing.def.IsBlueprint)
            {
                isRight = (thing as Building_ItemPuller).Getright;
            }
            if (def.IsBlueprint)
            {
                outputCell = def.entityDefToBuild.GetModExtension <ModExtension_Puller>().GetOutputCell(center, rot, isRight);
            }
            else
            {
                outputCell = def.GetModExtension <ModExtension_Puller>().GetOutputCell(center, rot, isRight);
            }

            GenDraw.DrawFieldEdges(new List <IntVec3> {
                inputCell
            }, Common.CommonColors.inputCell);
            GenDraw.DrawFieldEdges(new List <IntVec3> {
                outputCell
            }, Common.CommonColors.outputCell);
        }
        /// <summary>
        /// Using the new ApparelExtension, we can have a string based apparel check.
        /// </summary>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <param name="body"></param>
        /// <param name="__result"></param>
        public static void Post_CanWearTogether(ThingDef A, ThingDef B, BodyDef body, ref bool __result)
        {
            try
            {
                if (A == null || B == null || body == null || __result == true)
                {
                    return;
                }
                var aHasExt = A.HasModExtension <ApparelExtension>();
                var bHasExt = B.HasModExtension <ApparelExtension>();
                if (aHasExt && bHasExt)
                {
                    var aExt  = A.GetModExtension <ApparelExtension>();
                    var bExt  = B.GetModExtension <ApparelExtension>();
                    var check = new HashSet <string>();
                    if (aExt.coverage?.Count > 0)
                    {
                        for (int i = 0; i < aExt.coverage.Count; i++)
                        {
                            var coverageItem = aExt.coverage[i].ToLowerInvariant();
                            if (!check.Contains(coverageItem))
                            {
                                check.Add(coverageItem);
                            }
                            else
                            {
                                Log.Warning("JecsTools :: ApparelExtension :: Warning:: " + A.label +
                                            " has multiple of the same tags.");
                                return;
                            }
                        }
                    }

                    if (bExt.coverage?.Count > 0)
                    {
                        for (int j = 0; j < bExt.coverage.Count; j++)
                        {
                            var coverageItem = bExt.coverage[j].ToLowerInvariant();
                            if (!check.Contains(coverageItem))
                            {
                                check.Add(coverageItem);
                            }
                            else
                            {
                                __result = false;
                                break;
                            }
                        }
                    }
                }
                else if ((aHasExt && !bHasExt) || (!aHasExt && bHasExt))
                {
                    __result = true;
                }
            }
            catch (Exception e)
            {
                Log.Message(e.ToString());
            }
        }
 protected override bool TryCastShot()
 {
     if (base.TryCastShot())
     {
         ThingDef             projectile   = this.GetProjectile();
         ProjectileProperties projectile2  = projectile.projectile;
         ThingDef             equipmentDef = EquipmentSource?.def;
         if (equipmentDef is null)
         {
             Log.Error($"Unable to retrieve weapon def from <color=teal>{GetType()}</color>. Please report to Oskar or Smash Phil.");
             return(true);
         }
         MoteProperties moteProps = equipmentDef.GetModExtension <MoteProperties>();
         if (moteProps is null)
         {
             Log.ErrorOnce($"<color=teal>{GetType()}</color> cannot be used without <color=teal>MoteProperties</color> DefModExtension. Motes will not be thrown.",
                           Gen.HashCombine(projectile.GetHashCode(), "MoteProperties".GetHashCode()));
             return(true);
         }
         float size = moteProps.Size(projectile2.GetDamageAmount(caster, null));
         for (int i = 0; i < moteProps.numTimesThrown; i++)
         {
             float relAngle = Quaternion.LookRotation(CurrentTarget.CenterVector3 - Caster.Position.ToVector3Shifted()).eulerAngles.y;
             SmokeMaker.ThrowMoteDef(moteProps.moteDef, caster.PositionHeld.ToVector3Shifted(), caster.MapHeld, size, moteProps.Velocity, relAngle + moteProps.Angle, moteProps.Rotation);
         }
         return(true);
     }
     return(false);
 }
Beispiel #12
0
 internal static void Postfix(ref bool __result, IntVec3 c, ThingDef plantDef, Map map)
 {
     if (__result && plantDef.HasModExtension <DM_ModExtension>())
     {
         DM_ModExtension ext  = plantDef.GetModExtension <DM_ModExtension>();
         Tile            tile = Find.WorldGrid[map.Tile];
         Log.Message("rainrate is " + map.weatherManager.curWeather.rainRate);
         if (tile.rainfall < ext.minRainfall || tile.rainfall > ext.maxRainfall || tile.temperature < ext.minTemperature || tile.temperature > ext.maxTemperature)
         {
             __result = false;
             return;
         }
         if (ext.needsRain && map.weatherManager.curWeather.rainRate < 1)
         {
             __result = false;
             return;
         }
         if (__result == false)
         {
             return;
         }
         if (ext.needsRain && map.weatherManager.curWeather.rainRate >= 1)
         {
             GenSpawn.Spawn(plantDef, c, map);
             __result = false;
         }
     }
 }
Beispiel #13
0
        public static void Postfix(ThingDef __instance, ref IEnumerable <StatDrawEntry> __result, StatRequest req)
        {
            // Tool def
            if (req.Thing == null && __instance.IsSurvivalTool(out SurvivalToolProperties tProps))
            {
                foreach (StatModifier modifier in tProps.baseWorkStatFactors)
                {
                    __result = __result.AddItem(new StatDrawEntry(ST_StatCategoryDefOf.SurvivalTool,
                                                                  modifier.stat.LabelCap,
                                                                  modifier.value.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor),
                                                                  reportText: modifier.stat.description,
                                                                  displayPriorityWithinCategory: 99999,
                                                                  //overrideReportTitle: SurvivalToolUtility.GetSurvivalToolOverrideReportText(this, modifier.stat),
                                                                  hyperlinks: null,
                                                                  forceUnfinalizedMode: false
                                                                  ));
                }
            }

            // Stuff
            if (__instance.IsStuff && __instance.GetModExtension <StuffPropsTool>() is StuffPropsTool sPropsTool)
            {
                foreach (StatModifier modifier in sPropsTool.toolStatFactors)
                {
                    __result = __result.AddItem(new StatDrawEntry(ST_StatCategoryDefOf.SurvivalToolMaterial,
                                                                  modifier.stat.LabelCap,
                                                                  modifier.value.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Factor),
                                                                  reportText: modifier.stat.description,
                                                                  displayPriorityWithinCategory: 99999));
                }
            }
        }
Beispiel #14
0
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            Map map = Find.CurrentMap;
            var ext = def.GetModExtension <ModExtension_WorkIORange>();

            if (ext == null || ext.TargetCellResolver == null)
            {
                Debug.LogWarning("targetCellResolver not found.");
                return;
            }

            var machine = center.GetThingList(map).Where(t => t.def == def).SelectMany(t => Option(t as IRange)).FirstOption();

            if (machine.HasValue)
            {
                machine.Value.GetAllTargetCells().Select(c => new { Cell = c, Color = ext.TargetCellResolver.GetColor(c, map, rot, CellPattern.Instance) })
                .GroupBy(a => a.Color)
                .ForEach(g => GenDraw.DrawFieldEdges(g.Select(a => a.Cell).ToList(), g.Key));
            }
            else
            {
                var min = ext.TargetCellResolver.GetRangeCells(def, center, def.size, map, rot, ext.TargetCellResolver.MinRange());
                var max = ext.TargetCellResolver.GetRangeCells(def, center, def.size, map, rot, ext.TargetCellResolver.MaxRange());
                min.Select(c => new { Cell = c, Color = ext.TargetCellResolver.GetColor(c, map, rot, CellPattern.BlurprintMin) })
                .Concat(max.Select(c => new { Cell = c, Color = ext.TargetCellResolver.GetColor(c, map, rot, CellPattern.BlurprintMax) }))
                .GroupBy(a => a.Color)
                .ForEach(g => GenDraw.DrawFieldEdges(g.Select(a => a.Cell).ToList(), g.Key));
            }

            map.listerThings.ThingsOfDef(def).SelectMany(t => Option(t as IRange)).Where(r => r.Position != center).ForEach(r =>
                                                                                                                            r.GetAllTargetCells().Select(c => new { Cell = c, Color = ext.TargetCellResolver.GetColor(c, map, rot, CellPattern.OtherInstance) })
                                                                                                                            .GroupBy(a => a.Color)
                                                                                                                            .ForEach(g => GenDraw.DrawFieldEdges(g.Select(a => a.Cell).ToList(), g.Key)));
        }
 public static float OPBeamGetDmgFact(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPBeamDefs>())
     {
         return(thingdef.GetModExtension <OPBeamDefs>().OPBeamDmgFactor);
     }
     return(1f);
 }
Beispiel #16
0
 private static bool IsValidPlant(ThingDef plant)
 {
     if (plant.GetModExtension <SecondaryResource>().forbiddenGrowBiomes.NullOrEmpty() || !plant.GetModExtension <SecondaryResource>().forbiddenGrowBiomes.Contains(Find.VisibleMap.Biome))
     {
         return(true);
     }
     return(false);
 }
 public static float OPBeamGetRadius(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPBeamDefs>())
     {
         return(thingdef.GetModExtension <OPBeamDefs>().OPBeamRadius);
     }
     return(8f);
 }
Beispiel #18
0
 public static int OPBombGetBlastMaxRadius(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPBombDefs>())
     {
         return(thingdef.GetModExtension <OPBombDefs>().OPBombBlastMaxRadius);
     }
     return(6);
 }
Beispiel #19
0
 public static int OPBombGetImpactRadius(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPBombDefs>())
     {
         return(thingdef.GetModExtension <OPBombDefs>().OPBombImpactRadius);
     }
     return(12);
 }
 public static int OPBeamGetNumFires(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPBeamDefs>())
     {
         return(thingdef.GetModExtension <OPBeamDefs>().OPBeamNumFirePts);
     }
     return(3);
 }
Beispiel #21
0
 public static int OPBombGetDmg(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPBombDefs>())
     {
         return(thingdef.GetModExtension <OPBombDefs>().OPBombDmg);
     }
     return(25);
 }
Beispiel #22
0
 public static string OPToxicGetHediff(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPToxicDefs>())
     {
         return(thingdef.GetModExtension <OPToxicDefs>().OPToxicHediff);
     }
     return(null);
 }
Beispiel #23
0
 public static float OPToxicGetSev(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPToxicDefs>())
     {
         return(thingdef.GetModExtension <OPToxicDefs>().OPToxicSeverity);
     }
     return(0f);
 }
Beispiel #24
0
 public static int OPToxicGetSevUpVal(ThingDef thingdef)
 {
     if (thingdef.HasModExtension <OPToxicDefs>())
     {
         return(thingdef.GetModExtension <OPToxicDefs>().OPSevUpTickPeriod);
     }
     return(120);
 }
 public static StuffExtension GetCachedExtension(this ThingDef thingDef)
 {
     if (!cachedExtension.TryGetValue(thingDef, out var extension))
     {
         cachedExtension[thingDef] = extension = thingDef.GetModExtension <StuffExtension>();
     }
     return(extension);
 }
Beispiel #26
0
        // Token: 0x06000022 RID: 34 RVA: 0x00004804 File Offset: 0x00002A04
        public static float GetProxMoveSpeedOffSet(ThingDef thingdef)
        {
            if (thingdef.HasModExtension <ProximityDefs>())
            {
                return(new float?(thingdef.GetModExtension <ProximityDefs>().ProxMoveSpeedOffSet).Value);
            }

            return(0f);
        }
Beispiel #27
0
        // Token: 0x0600002A RID: 42 RVA: 0x00004A24 File Offset: 0x00002C24
        public static float GetProxComfyTemperatureMaxOffSet(ThingDef thingdef)
        {
            if (thingdef.HasModExtension <ProximityDefs>())
            {
                return(new float?(thingdef.GetModExtension <ProximityDefs>().ProxComfyTemperatureMaxOffSet).Value);
            }

            return(0f);
        }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            base.DrawGhost(def, center, rot, ghostCol);

            if (def.GetModExtension <DefModExtension_DroneStation>().SquareJobRadius > 0)
            {
                int            squareAreaRadius = def.GetModExtension <DefModExtension_DroneStation>().SquareJobRadius;
                List <IntVec3> list             = new List <IntVec3>((squareAreaRadius * 2 + 1) * (squareAreaRadius * 2 + 1));
                for (int i = -squareAreaRadius; i <= squareAreaRadius; i++)
                {
                    for (int j = -squareAreaRadius; j <= squareAreaRadius; j++)
                    {
                        list.Add(new IntVec3(i, 0, j) + center);
                    }
                }
                GenDraw.DrawFieldEdges(list);
            }
        }
Beispiel #29
0
        public static void SetMenuHidden(this ThingDef def, bool value)
        {
            isMenuHiddenArray[def.index] = value;

            if (def.HasModExtension <ThingDefExtensionCE>()) // Check if this def has ThingDefExtensionCE
            {
                def.GetModExtension <ThingDefExtensionCE>().MenuHidden = value;
            }
        }
Beispiel #30
0
        /// <summary>
        /// Perpare the ThingDefExtensionCE.
        /// </summary>
        /// <param name="def">ThingDef with </param>
        private static void ProcessThingDefExtensionCE(ThingDef def)
        {
            ThingDefExtensionCE ext = def.GetModExtension <ThingDefExtensionCE>();

            if (ext != null)
            {
                isMenuHiddenArray[def.index] = ext.MenuHidden;
            }
        }