public static bool TryGetValue(this ToolComp comp, ToolType toolType, StatDef stat, out float factor, out float offset) { factor = 1f; offset = 0f; if (!comp.TryGetValue(toolType, out var val)) { return(false); } bool flag = false; factor = toolType.workStatFactors.GetStatValueFromList(stat, 0f); if (factor != 0f) { factor *= val; flag = true; } else { factor = 1f; } offset = toolType.workStatOffset.GetStatValueFromList(stat, 0f); if (offset != 0f) { flag = true; offset = val - offset; } return(flag); }
public static float GetValue(this ToolComp comp, ToolType toolType, float fallback = 0f) { if (comp.TryGetValue(toolType, out float val)) { return(val); } return(fallback); }
public static float GetValue(this ToolComp comp, JobDef job, ToolType toolType = null, float fallback = 0f) { if (comp.TryGetValue(job, out float val, toolType)) { return(val); } return(fallback); }
public static float GetValue(this ToolDef toolDef, ToolType toolType, float fallback = 0f, ThingDef stuffDef = null) { if (toolDef.TryGetValue(toolType, out float val, stuffDef)) { return(val); } return(fallback); }
public static float GetToolValue(this ThingWithComps thing, ToolType toolType, float fallback = 0f) { if (thing.IsTool(out var comp) && comp.TryGetValue(toolType, out float val)) { return(val); } return(fallback); }
public static float GetStatValue(this ThingWithComps tool, ToolType toolType, StatDef stat, bool applyPostProcess = true, float fallback = 0f) { if (tool == null) { return(fallback); } return(stat.Worker.GetValue(tool, toolType, applyPostProcess)); }
public static float GetValue(this CompProperties_Tool toolProp, ToolType toolType, float fallback = 0f, ThingDef stuffDef = null) { if (toolProp.TryGetValue(toolType, out float val, stuffDef)) { return(val); } return(fallback); }
public static bool TryGetToolValue(this ThingWithComps thing, ToolType toolType, out float val) { val = 0f; if (!thing.IsTool(out var comp)) { return(false); } return(comp.TryGetValue(toolType, out val)); }
public static string ToolStatDrawEntry(ThingWithComps tool, ToolType toolType, float value, ThingDef stuffDef = null) { var stat = StatDefOf.ToolEffectivenessFactor; var builder = new StringBuilder(stat.description); var statReq = tool == null?Patch_StatRequest_For.For(toolType, stuffDef) : Patch_StatRequest_For.For(tool, toolType); builder.AppendLine("\n\n" + stat.Worker.GetExplanationFull(statReq, stat.toStringNumberSense, value)); return(builder.ToString()); }
public static bool TryGetToolValue(this ThingWithComps thing, ToolType toolType, StatDef stat, out float factor, out float offset) { factor = 1f; offset = 0f; if (!thing.IsTool(out var comp)) { return(false); } return(comp.TryGetValue(toolType, stat, out factor, out offset)); }
public static bool TryGetValue(this ToolComp comp, ToolType toolType, out float val) { val = 0f; if (!comp.ToolTypes.Contains(toolType)) { return(false); } val = comp.parent.GetStatValue(toolType, StatDefOf.ToolEffectivenessFactor); return(true); }
public static bool TryGetValue(this ToolDef toolDef, ToolType toolType, out float val, ThingDef stuffDef = null) { val = 0f; if (!toolDef.CompProp.toolTypesValue.ToolTypeListContains(toolType, out var modifier)) { return(false); } val = modifier.value * toolType.GetStuffEfficiency(stuffDef); return(true); }
public ToolInfo BestTool(ToolType toolType) { var info = BestTools[toolType]; if (info == null) { return(null); } if (!ValidateTool(info.tool)) { info = BestTool(toolType); } return(info); }
private ToolInfo privateBestTool(ToolType toolType) { ToolInfo info = null; float val = 0f; foreach (var currInfo in useableTools) { float currVal = currInfo.comp[toolType]; if (currInfo.comp.TryGetValue(toolType, out var baseVal) && baseVal > 1f && currVal > val) { info = currInfo; val = currVal; } } return(info); }
public ToolInfo ClosestToolInfo(ToolType toolType, IntVec3 pos, Pawn pawn = null) { var reservation = pawn?.MapHeld.reservationManager; var faction = pawn?.Faction; var flag = pawn.CanUseTools(out var tracker); ThingFilter assignmentFilter = null; if (flag) { assignmentFilter = tracker.ToolAssignment.filter; } ToolInfo info = null; float bestDist = float.MaxValue; foreach (var currInfo in UseableToolInfos) { if (pawn != null) { if (flag) { if (currInfo.tool.ToolIsForbidden(pawn, assignmentFilter, reservation, faction)) { continue; } } else if (currInfo.tool.ToolIsForbidden(pawn, reservation, faction)) { continue; } } if (!currInfo.comp.TryGetValue(toolType, out float val) || val < 1f || !Distance(currInfo.tool, pos, out float dist)) { continue; } if (dist < bestDist) { bestDist = dist; info = currInfo; } } return(info); }
public ThingWithComps ClosestTool(ToolType toolType, IntVec3 pos, Pawn pawn = null) => ClosestToolInfo(toolType, pos, pawn)?.tool;
public static float GetValue(this StatWorker statWorker, ThingWithComps tool, ToolType toolType, bool applyPostProcess = true) { return(statWorker.GetValue(Patch_StatRequest_For.For(tool, toolType), applyPostProcess)); }
public static bool ToolTypeListContains(this List <ToolTypeModifier> modList, ToolType toolType, out ToolTypeModifier modifier) { modifier = null; if (modList != null) { for (int i = 0; i < modList.Count; i++) { if (modList[i].toolType == toolType) { modifier = modList[i]; return(true); } } } return(false); }
public static bool TryGetValue(this ToolComp comp, JobDef job, out float val, ToolType toolType = null) { val = 0f; if (toolType == null && !Dictionaries.jobToolType.TryGetValue(job, out toolType)) { return(false); } if (!comp.TryGetValue(toolType, out val)) { return(false); } val *= comp.CompProp.jobBonus.GetJobValueFromList(job, 1f); return(true); }
public static bool TryGetValue(this ToolComp comp, ThingDef billGiver, out float val, ToolType toolType = null) { val = 0f; if (toolType == null && !Dictionaries.billGiverToolType.TryGetValue(billGiver, out toolType)) { return(false); } if (!comp.TryGetValue(toolType, out val)) { return(false); } val *= comp.CompProp.billGiverBonus.GetBillGiverValueFromList(billGiver, 1f); return(true); }
public static bool TryGetToolValue(this ThingWithComps thing, ThingDef billGiver, out float val, ToolType toolType = null) { val = 0f; if (!thing.IsTool(out var comp)) { return(false); } return(comp.TryGetValue(billGiver, out val, toolType)); }
public static float GetToolTypeValueFromList(this List <ToolTypeModifier> modList, ToolType toolType, float defaultValue = 0f) { if (modList != null) { for (int i = 0; i < modList.Count; i++) { if (modList[i].toolType == toolType) { return(modList[i].value); } } } return(defaultValue); }
public static bool TryGetValue(this ToolComp comp, ThingDef billGiver, StatDef stat, out float factor, out float offset, ToolType toolType = null) { factor = 1f; offset = 0f; if (toolType == null && !Dictionaries.billGiverToolType.TryGetValue(billGiver, out toolType)) { return(false); } if (!comp.TryGetValue(billGiver, out var val, toolType)) { return(false); } factor = toolType.workStatFactors.GetStatValueFromList(stat, 0f); if (factor != 0f) { factor *= val; } else { factor = 1f; } offset = toolType.workStatOffset.GetStatValueFromList(stat, 0f); if (offset != 0f) { offset = val - offset; } return(true); }
public static bool ToolTypeListContains(this List <ToolTypeModifier> modList, ToolType toolType) => modList.ToolTypeListContains(toolType, out _);
public static bool TryGetValue(this ToolComp comp, JobDef job, StatDef stat, out float factor, out float offset, ToolType toolType = null) { factor = 1f; offset = 0f; if (toolType == null && !Dictionaries.jobToolType.TryGetValue(job, out toolType)) { return(false); } if (!comp.TryGetValue(job, out var val, toolType)) { return(false); } bool flag = false; factor = toolType.workStatFactors.GetStatValueFromList(stat, 0f); if (factor != 0f) { factor *= val; flag = true; } else { factor = 1f; } offset = toolType.workStatOffset.GetStatValueFromList(stat, 0f); if (offset != 0f) { flag = true; offset = val - offset; } return(flag); }
public static StatDrawEntry ToolTypeDrawEntry(ThingWithComps tool, ToolType toolType, float value, ThingDef stuffDef = null) => new StatDrawEntry(StatCategoryDefOf.Tools, toolType.LabelCap, value.ToStringPercent("F0"), ToolStatDrawEntry(tool, toolType, value, stuffDef), 99999, overrideReportTitle: toolType.description, hyperlinks: null, forceUnfinalizedMode: false);
public void FindBestTool(ToolType toolType) => bestTools[toolType] = privateBestTool(toolType);