Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Defs/RecipeDefs/Recipes_Plasteel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<workSpeedStat>GeneralLaborSpeed</workSpeedStat>
<effectWorking>Smelt</effectWorking>
<soundWorking>Recipe_Machining</soundWorking>
<workAmount>30000</workAmount>
<workAmount>24000</workAmount>
<workSkillLearnFactor>0.75</workSkillLearnFactor>
<unfinishedThingDef>UnfinishedComponent</unfinishedThingDef>
<ingredients>
Expand All @@ -29,7 +29,7 @@
<li>Chemfuel</li>
</thingDefs>
</filter>
<count>100</count>
<count>50</count>
</li>
</ingredients>
<fixedIngredientFilter>
Expand Down
16 changes: 16 additions & 0 deletions Defs/ResearchProjectDefs/ResearchProjects_Assemblers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@
<li>PRF_UniversalAutocrafting</li>
</prerequisites>
<researchViewX>9</researchViewX>

<techprintCount MayRequire="ludeon.rimworld.royalty">1</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">3000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>

<ResearchProjectDef ParentName="PRF_AssemblersResearch">
Expand All @@ -132,5 +140,13 @@
<li>PRF_SelfCorrectingAssemblers</li>
</prerequisites>
<researchViewX>10</researchViewX>

<techprintCount MayRequire="ludeon.rimworld.royalty">2</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">4000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>
</Defs>
8 changes: 8 additions & 0 deletions Defs/ResearchProjectDefs/ResearchProjects_Batteries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
<li>PRF_CoreTierIII</li>
</prerequisites>
<researchViewX>9</researchViewX>

<techprintCount MayRequire="ludeon.rimworld.royalty">1</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">3000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>

</Defs>
8 changes: 8 additions & 0 deletions Defs/ResearchProjectDefs/ResearchProjects_Drones.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
<researchViewX>10</researchViewX>
<discoveredLetterTitle>About: Drone are now lv 20</discoveredLetterTitle>
<discoveredLetterText>You have upgraded your drones with advanced AI cores, this will let them do their tasks better than most humans will do. \n This will set any drones base level to 20. \n Unless other settings for specific dronestation is specified.</discoveredLetterText>

<techprintCount MayRequire="ludeon.rimworld.royalty">1</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">3000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>
<!-- this should set all drone base stats to 20 unless manually overwritten -->

Expand Down
8 changes: 8 additions & 0 deletions Defs/ResearchProjectDefs/ResearchProjects_Industrial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
</requiredResearchFacilities>
<researchViewX>9</researchViewX>
<description>Build two more advanced forms of miners. One will only produce resources with no stone, and one allows you to target-mine specific resources. Neither of the tier 3 miners will draw infestations thanks to the advanced technology they use to dampen vibrations.</description>

<techprintCount MayRequire="ludeon.rimworld.royalty">1</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">3000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>

</Defs>
8 changes: 8 additions & 0 deletions Defs/ResearchProjectDefs/ResearchProjects_SAL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@
</requiredResearchFacilities>
<researchViewX>12</researchViewX>
<researchViewY>4.3</researchViewY>

<techprintCount MayRequire="ludeon.rimworld.royalty">2</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">6000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>

</Defs>
16 changes: 16 additions & 0 deletions Defs/ResearchProjectDefs/ResearchProjects_Storage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
<li>MultiAnalyzer</li>
<li>PRF_ResearchTerminal</li>
</requiredResearchFacilities>

<techprintCount MayRequire="ludeon.rimworld.royalty">1</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">3000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>

<ResearchProjectDef ParentName="PRF_StorageResearch">
Expand All @@ -67,5 +75,13 @@
<li>MultiAnalyzer</li>
<li>PRF_ResearchTerminal</li>
</requiredResearchFacilities>

<techprintCount MayRequire="ludeon.rimworld.royalty">1</techprintCount>
<techprintCommonality MayRequire="ludeon.rimworld.royalty">1</techprintCommonality>
<techprintMarketValue MayRequire="ludeon.rimworld.royalty">3000</techprintMarketValue>
<heldByFactionCategoryTags MayRequire="ludeon.rimworld.royalty">
<li MayRequire="ludeon.rimworld.royalty">Outlander</li>
<li MayRequire="ludeon.rimworld.royalty">Empire</li>
</heldByFactionCategoryTags>
</ResearchProjectDef>
</Defs>
42 changes: 39 additions & 3 deletions Source/ProjectRimFactory/AutoMachineTool/Building_MIner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Building_Miner : Building_BaseMachine<Building_Miner>, IBillGiver,

public IEnumerable<RecipeDef> AllRecipes => this.def.AllRecipes;

private bool inSpace = false;

public IEnumerable<RecipeDef> GetAllRecipes()
{
return this.AllRecipes;
Expand Down Expand Up @@ -153,7 +155,7 @@ protected bool EffectTick()
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);

inSpace = Common.HarmonyPatches.PatchStorageUtil.GetPRFMapComponent(map).IsSpace;
if (this.GetComp<CompGlowerPulse>() != null)
{
this.GetComp<CompGlowerPulse>().Glows = false;
Expand Down Expand Up @@ -193,11 +195,32 @@ public string GetDescription(ThingDef def)
HelpText += "\r\n";
return HelpText;
}

protected override bool IsActive()
{
return base.IsActive() && !inSpace;
}
}

[StaticConstructorOnStartup]
public static class RecipeRegister
{
private static readonly float maxValuePerBill = 23f;
/// <summary>
/// Retuns a appropriate yield for a minable Thing
/// based on a "maxValuePerBill" Variable and the default yield
/// </summary>
/// <param name="def">Minable Building</param>
/// <returns>yield ammount</returns>
private static int GetMinableYieldForMinerBill(ThingDef def)
{
var yield = def.building.mineableYield;
var valuePerUnit = def.building.mineableThing.BaseMarketValue;
int count = Mathf.CeilToInt(maxValuePerBill / valuePerUnit);
if (def.defName == "MineableSilver") count = 5;
return Mathf.Min(yield, count);
}

static RecipeRegister()
{
var minerDef = DefDatabase<ThingDef>.GetNamedSilentFail("PRF_BillTypeMiner_I");
Expand All @@ -207,7 +230,7 @@ static RecipeRegister()
var mineables = DefDatabase<ThingDef>.AllDefs
.Where(d => d.mineable && d.building != null && d.building.mineableThing != null && d.building.mineableYield > 0)
.Where(d => d.building.isResourceRock || d.building.isNaturalRock)
.Select(d => new ThingDefCountClass(d.building.mineableThing, d.building.mineableYield))
.Select(d => new ThingDefCountClass(d.building.mineableThing, GetMinableYieldForMinerBill(d)))
// Create recipes for exluded items - for now - so players who had those recipes
// don't get errors are save game load.
// Once people have had this change for a while (Nov 2020?), can uncomment this line
Expand Down Expand Up @@ -253,6 +276,19 @@ static RecipeRegister()
//minerDef.recipes = recipeDefs;
}
}
private static float calculateWorkAmmount(ThingDefCountClass defCount)
{
var isRare = defCount.thingDef.BaseMarketValue >= 6;
var work = Mathf.Max(10000f, StatDefOf.MarketValue.Worker.GetValue(StatRequest.For(defCount.thingDef, null)) * defCount.count * 1000);
//Maybe make this a fuction at a later point
//As in factor per maket value
if (isRare)
{
work *= 5;
}
if (defCount.thingDef.defName == "MineableSilver") work *= 8;
return work;
}

private static RecipeDef CreateMiningRecipe(ThingDefCountClass defCount, EffecterDef effecter)
{
Expand All @@ -261,7 +297,7 @@ private static RecipeDef CreateMiningRecipe(ThingDefCountClass defCount, Effecte
r.label = "PRF.AutoMachineTool.AutoMiner.MineOre".Translate(defCount.thingDef.label);
r.jobString = "PRF.AutoMachineTool.AutoMiner.MineOre".Translate(defCount.thingDef.label);

r.workAmount = Mathf.Max(10000f, StatDefOf.MarketValue.Worker.GetValue(StatRequest.For(defCount.thingDef, null)) * defCount.count * 1000);
r.workAmount = calculateWorkAmmount(defCount);
r.workSpeedStat = StatDefOf.WorkToMake;
r.efficiencyStat = StatDefOf.WorkToMake;

Expand Down
9 changes: 9 additions & 0 deletions Source/ProjectRimFactory/Common/PRFMapComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class PRFMapComponent : MapComponent

private Dictionary<IntVec3, List<HarmonyPatches.IForbidPawnOutputItem>> ForbidPawnOutputItemLocations = new Dictionary<IntVec3, List<HarmonyPatches.IForbidPawnOutputItem>>();

private bool spaceTested = false;
public bool IsSpace = false;

public void RegisterIHideItemPos(IntVec3 pos, HarmonyPatches.IHideItem hideItem)
{
if(hideItemLocations.ContainsKey(pos))
Expand Down Expand Up @@ -97,6 +100,12 @@ public override void MapComponentTick()
{
base.MapComponentTick();
this.tickers.ForEach(t => t.Tick());

if(!spaceTested && ProjectRimFactory_ModComponent.ModSupport_SOS2)
{
spaceTested = true;
IsSpace = (bool)ProjectRimFactory_ModComponent.ModSupport_SOS2_IsSpace.Invoke(null, new object[] { this.map });
}
}

public void AddTicker(ITicker ticker)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public ProjectRimFactory_ModComponent(ModContentPack content) : base(content)

public static System.Reflection.MethodInfo ModSupport_ReserchPal_ResetLayout = null;
public static bool ModSupport_ReserchPal = false;


public static System.Reflection.MethodInfo ModSupport_SOS2_IsSpace = null;
public static bool ModSupport_SOS2 = false;

private void LoadModSupport()
{
if (ModLister.HasActiveModWithName("[KV] RimFridge"))
Expand Down Expand Up @@ -151,7 +154,11 @@ private void LoadModSupport()
Log.Error("PRF Could not find savestoragesettings.kv.rw assembly");
}
}

if (ModLister.HasActiveModWithName("Save Our Ship 2"))
{
ModSupport_SOS2 = true;
ModSupport_SOS2_IsSpace = AccessTools.Method("RimworldMod.AccessExtensions:IsSpace");
}

}

Expand Down
4 changes: 3 additions & 1 deletion Source/ProjectRimFactory/Industry/Building_DeepQuarry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public class Building_DeepQuarry : Building , IXMLThingDescription
public CompPowerTrader power;
public CompRefuelable fuel;
public int ProducedChunksTotal = 0;
private bool inSpace = false;

public override void SpawnSetup(Map map, bool respawningAfterLoad) {
base.SpawnSetup(map, respawningAfterLoad);
flick = GetComp<CompFlickable>();
power = GetComp<CompPowerTrader>();
fuel = GetComp<CompRefuelable>();
inSpace = Common.HarmonyPatches.PatchStorageUtil.GetPRFMapComponent(map).IsSpace;
}

public static IEnumerable<ThingDef> PossibleRockDefCandidates
Expand Down Expand Up @@ -78,7 +80,7 @@ private void HandelTick(int numTicks, bool consumeFuelWhileRunning)
!fuel.Props.consumeFuelOnlyWhenUsed) {
fuel.ConsumeFuel(fuel.Props.fuelConsumptionRate / 6000 * numTicks);
}*/

if (inSpace) return;
if (flick == null || flick.SwitchIsOn) // Either no switch or turned on
{
if (power == null || power.PowerOn) // Either does not use power or has power
Expand Down