mirror of
				https://gitgud.io/Stardust3D/rjw-patch-autopsy.git
				synced 2024-08-15 00:43:41 +00:00 
			
		
		
		
	cleanup
This commit is contained in:
		
							parent
							
								
									f2bbe509ef
								
							
						
					
					
						commit
						2b05dfac95
					
				
					 7 changed files with 43 additions and 26 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -41,6 +41,12 @@
 | 
			
		|||
  <PropertyGroup>
 | 
			
		||||
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <SignAssembly>true</SignAssembly>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <DelaySign>false</DelaySign>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Reference Include="0Harmony, Version=2.1.1.0, Culture=neutral, processorArchitecture=MSIL">
 | 
			
		||||
      <HintPath>..\packages\Lib.Harmony.2.1.1\lib\net472\0Harmony.dll</HintPath>
 | 
			
		||||
| 
						 | 
				
			
			@ -86,6 +92,7 @@
 | 
			
		|||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <None Include="packages.config" />
 | 
			
		||||
    <None Include="Stardust3D_code_signing.pfx" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 | 
			
		||||
</Project>
 | 
			
		||||
| 
						 | 
				
			
			@ -5,6 +5,5 @@ namespace RJW_patch_Autopsy
 | 
			
		|||
    public class Mod : ModBase
 | 
			
		||||
    {
 | 
			
		||||
        public override string ModIdentifier => "Stardust3D.RJW.patch.Autopsy";
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -12,45 +12,56 @@ namespace RJW_patch_Autopsy
 | 
			
		|||
    public static class NewMedicalRecipesUtilityPatch
 | 
			
		||||
    {
 | 
			
		||||
        [HarmonyPrefix]
 | 
			
		||||
        public static bool AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance, ref IEnumerable<Thing> __result)
 | 
			
		||||
        public static bool AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance,
 | 
			
		||||
            ref IEnumerable<Thing> __result)
 | 
			
		||||
        {
 | 
			
		||||
            //Collect vanilla parts
 | 
			
		||||
            BodyPartRecord core = corpse.InnerPawn.RaceProps.body.corePart;
 | 
			
		||||
            List<BodyPartRecord> queue = new List<BodyPartRecord> { core };
 | 
			
		||||
            HediffSet hediffSet = corpse.InnerPawn.health.hediffSet;
 | 
			
		||||
            List<Thing> results = new List<Thing>();
 | 
			
		||||
            List<BodyPartRecord> damagedParts = new List<BodyPartRecord>();
 | 
			
		||||
            var core = corpse.InnerPawn.RaceProps.body.corePart;
 | 
			
		||||
            var queue = new List<BodyPartRecord> {core};
 | 
			
		||||
            var hediffSet = corpse.InnerPawn.health.hediffSet;
 | 
			
		||||
            var results = new List<Thing>();
 | 
			
		||||
            var damagedParts = new List<BodyPartRecord>();
 | 
			
		||||
            while (queue.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                BodyPartRecord part = queue.First();
 | 
			
		||||
                var part = queue.First();
 | 
			
		||||
                queue.Remove(part);
 | 
			
		||||
                //Drop parts and bionics that are higher on the body tree.
 | 
			
		||||
                if (NewMedicalRecipesUtility.TryGetParts(corpse, recipeInfo, part, skillChance, ref results, ref damagedParts) && core != part)
 | 
			
		||||
                if (NewMedicalRecipesUtility.TryGetParts(corpse, recipeInfo, part, skillChance, ref results,
 | 
			
		||||
                        ref damagedParts) && core != part)
 | 
			
		||||
                    continue;
 | 
			
		||||
                queue.AddRange(part.parts.Where(x => !hediffSet.PartIsMissing(x)));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (BodyPartRecord part in damagedParts) NewMedicalRecipesUtility.DamageHarvested(corpse.InnerPawn, part);
 | 
			
		||||
            foreach (var part in damagedParts)
 | 
			
		||||
                NewMedicalRecipesUtility.DamageHarvested(corpse.InnerPawn, part);
 | 
			
		||||
 | 
			
		||||
            //Collect rjw rediffs
 | 
			
		||||
            List<Hediff> rjwNaturalDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs
 | 
			
		||||
                                            where x is Hediff_PartBaseNatural
 | 
			
		||||
                                            select x).ToList();
 | 
			
		||||
            List<Hediff> rjwArtificialDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs
 | 
			
		||||
                                               where x is Hediff_PartBaseArtifical
 | 
			
		||||
                                               select x).ToList();
 | 
			
		||||
            var rjwNaturalDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs
 | 
			
		||||
                where x is Hediff_PartBaseNatural
 | 
			
		||||
                select x).ToList();
 | 
			
		||||
            var rjwArtificialDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs
 | 
			
		||||
                where x is Hediff_PartBaseArtifical
 | 
			
		||||
                select x).ToList();
 | 
			
		||||
 | 
			
		||||
            //Log.Message(String.Format("Collected {0} natural and {1} artifical hediffs", rjwNaturalDiffs.Count(), rjwArtificialDiffs.Count()));
 | 
			
		||||
 | 
			
		||||
            //Collect parts from hediffs rjw's surgery methods
 | 
			
		||||
            List<Thing> rjwNaturalThings = rjwNaturalDiffs.Select(d => SexPartAdder.recipePartRemover(d)).ToList();
 | 
			
		||||
            List<Thing> rjwArtificialThings = rjwArtificialDiffs.Select(d => SexPartAdder.recipePartRemover(d)).ToList();
 | 
			
		||||
            var rjwNaturalThings = rjwNaturalDiffs.Select(SexPartAdder.recipePartRemover).ToList();
 | 
			
		||||
            var rjwArtificialThings =
 | 
			
		||||
                rjwArtificialDiffs.Select(SexPartAdder.recipePartRemover).ToList();
 | 
			
		||||
 | 
			
		||||
            //Log.Message(String.Format("Collected {0} things from {1} natural and {2} things from {3} artifical hediffs", rjwArtificialThings.Count(), rjwNaturalDiffs.Count(), rjwArtificialThings.Count(), rjwArtificialDiffs.Count()));
 | 
			
		||||
            //Log.Message(String.Format("Collected {0} things from {1} natural and {2} things from {3} artifical hediffs",
 | 
			
		||||
            //rjwArtificialThings.Count(), rjwNaturalDiffs.Count(), rjwArtificialThings.Count(), rjwArtificialDiffs.Count()));
 | 
			
		||||
 | 
			
		||||
            //Simulate success chance scaled with skill etc.
 | 
			
		||||
            rjwNaturalThings.ToList().ForEach(t => { if (Rand.Chance(Math.Min(skillChance, recipeInfo.NaturalChance))) results.Add(t); });
 | 
			
		||||
            rjwArtificialThings.ToList().ForEach(t => { if (Rand.Chance(Math.Min(skillChance, recipeInfo.BionicChance))) results.Add(t); });
 | 
			
		||||
            rjwNaturalThings.ToList().ForEach(t =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Rand.Chance(Math.Min(skillChance, recipeInfo.NaturalChance))) results.Add(t);
 | 
			
		||||
            });
 | 
			
		||||
            rjwArtificialThings.ToList().ForEach(t =>
 | 
			
		||||
            {
 | 
			
		||||
                if (Rand.Chance(Math.Min(skillChance, recipeInfo.BionicChance))) results.Add(t);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            //Remove all parts that were tried to harves from the corpse
 | 
			
		||||
            rjwNaturalDiffs.ToList().ForEach(d => corpse.InnerPawn.health.RemoveHediff(d));
 | 
			
		||||
| 
						 | 
				
			
			@ -58,7 +69,7 @@ namespace RJW_patch_Autopsy
 | 
			
		|||
 | 
			
		||||
            if (results.Count() > recipeInfo.PartNumber)
 | 
			
		||||
            {
 | 
			
		||||
                Random random = new Random();
 | 
			
		||||
                var random = new Random();
 | 
			
		||||
                __result = results.OrderBy(i => random.Next()).Take(recipeInfo.PartNumber);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
 | 
			
		|||
// You can specify all the values or you can default the Build and Revision Numbers
 | 
			
		||||
// by using the '*' as shown below:
 | 
			
		||||
// [assembly: AssemblyVersion("1.0.*")]
 | 
			
		||||
[assembly: AssemblyVersion("493.0.1.1")]
 | 
			
		||||
[assembly: AssemblyFileVersion("493.0.1.1")]
 | 
			
		||||
[assembly: AssemblyVersion("493.0.1.2")]
 | 
			
		||||
[assembly: AssemblyFileVersion("493.0.1.2")]
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue