public static int GetScarecrowRadius(this SObject Obj) { int BaseRadius = GetScarecrowBaseRadius(Obj); if (Obj.IsScarecrow()) { if (Obj.IsCombinedMachine()) { double RadiusMultiplier = Obj.GetScarecrowRadiusMultiplier(); double Result = BaseRadius * RadiusMultiplier; #if NEVER //DEBUG ModEntry.Logger.Log(string.Format("{0}: Base={1}, Computed={2}", nameof(GetScarecrowRadius), BaseRadius, Result), ModEntry.InfoLogLevel); #endif return((int)Math.Round(Result, MidpointRounding.AwayFromZero)); } else { return(BaseRadius); } } else { return(BaseRadius); } }
internal static bool CanCombine(SObject Machine1, SObject Machine2) { return(Machine1 != null && Machine2 != null && Machine1.bigCraftable.Value && Machine2.bigCraftable.Value && Machine1.Stack >= 1 && Machine2.Stack >= 1 && Machine1.ParentSheetIndex == Machine2.ParentSheetIndex && (Machine1.IsCombinedMachine() || Machine2.IsCombinedMachine() || Machine1.canStackWith(Machine2))); }
public static double GetScarecrowRadiusMultiplier(this SObject Obj) { if (Obj.IsScarecrow() && Obj.IsCombinedMachine()) { double TilesMultiplier = Obj.GetProcessingPower(); double RadiusMultiplier = Math.Sqrt(TilesMultiplier); return(RadiusMultiplier); } else { return(1.0); } }
public static bool Prefix(SObject __instance, ISalable other, ref bool __result) { try { // Always return false if the machine has been merged with another machine if (__instance.IsCombinedMachine()) { __result = false; return(false); } else { return(true); } } catch (Exception ex) { ModEntry.Logger.Log(string.Format("Unhandled Error in {0}.{1}:\n{2}", nameof(CanStackWithPatch), nameof(Prefix), ex), LogLevel.Error); return(true); } }