Skip to content

Commit

Permalink
Updated source code + added DefOf
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLoneTec committed Feb 12, 2025
1 parent cf979cb commit 90834e7
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 159 deletions.
Binary file modified Mods/Minerals/Assemblies/Minerals.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions Mods/Minerals/Source/Minerals/DynamicMineral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public override void TickLong()
if (sizeDiff > 0.1f || (sizeDiff > 0.02f && attributes.fastGraphicRefresh))
{
sizeWhenLastPrinted = apparentSize;
base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things);
base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlagDefOf.Things);
initializeTextureLocations();
}

Expand Down Expand Up @@ -516,11 +516,11 @@ public float lightByBiome(BiomeDef biome)
}
public override float valueAtPos(DynamicMineral aMineral)
{
return aMineral.Map.glowGrid.GameGlowAt(aMineral.Position);
return aMineral.Map.glowGrid.GroundGlowAt(aMineral.Position);
}
public override float valueAtPos(ThingDef_DynamicMineral myDef, IntVec3 aPosition, Map aMap)
{
return aMap.glowGrid.GameGlowAt(aPosition);
return aMap.glowGrid.GroundGlowAt(aPosition);
}
public override float valueAtMap(Map aMap)
{
Expand Down
73 changes: 13 additions & 60 deletions Mods/Minerals/Source/Minerals/Minerals.csproj
Original file line number Diff line number Diff line change
@@ -1,72 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D26AEA04-2715-4D47-86C6-EBE251DA0B7D}</ProjectGuid>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Minerals</RootNamespace>
<AssemblyName>Minerals</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Assemblies</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>..\..\Assemblies\</OutputPath>
<Product>Minerals</Product>
<deterministic>true</deterministic>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Optimize>true</Optimize>
<OutputPath>..\..\Assemblies</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<Prefer32Bit>false</Prefer32Bit>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Hardcore-SK-Source\R1.1\Assemblies\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>references\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Core_SK">
<HintPath>..\..\..\..\..\public\Hardcore-SK\Mods\Core_SK\Assemblies\Core_SK.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine.CoreModule">
<HintPath>references\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\Assemblies\Core_SK.dll</HintPath>
<Private>False</Private>
</Reference>
<PackageReference Include="Lib.Harmony" Version="2.3.3" ExcludeAssets="runtime" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.*" />
<PackageReference Include="Krafs.Publicizer" Version="2.2.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="events\NoticeMinerals.cs" />
<Compile Include="events\RichOreDeposit.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="harmonyPatching.cs" />
<Compile Include="initialization.cs" />
<Compile Include="StaticMineral.cs" />
<Compile Include="DynamicMineral.cs" />
<Compile Include="SaltCrystal.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Main.cs" />
<Compile Include="RiverRock.cs" />
<Compile Include="SolidRock.cs" />
<Compile Include="BigMineral.cs" />
<Compile Include="events\BlueSnow.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup />
<ItemGroup>
<None Include="..\..\Defs\ThingsDefs_Minerals\StaticMineralBase.xml">
<Link>xml\StaticMineralBase.xml</Link>
Expand All @@ -84,4 +36,5 @@
<Link>xml\Item_Resource_Gems.xml</Link>
</None>
</ItemGroup>
<Import Project="Properties\OutputPath.props" Condition="Exists('Properties\OutputPath.props')" />
</Project>
28 changes: 0 additions & 28 deletions Mods/Minerals/Source/Minerals/Minerals.userprefs

This file was deleted.

3 changes: 2 additions & 1 deletion Mods/Minerals/Source/Minerals/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion ("1.0.*")]
[assembly: AssemblyVersion ("15.0.0.0")]
[assembly: AssemblyFileVersion ("15.0.0.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
31 changes: 16 additions & 15 deletions Mods/Minerals/Source/Minerals/StaticMineral.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -124,6 +124,7 @@ public virtual ThingDef_StaticMineral attributes

public virtual void incPctYeild(float amount, Pawn miner)
{
//Log.Message("incPctYeild Entered with Pawn: " + miner.def.defName + ". Amount: " + amount);
// Increase yeild for when it is destroyed
float minerYield = 1f;
if (miner.def.race.IsMechanoid)
Expand Down Expand Up @@ -172,6 +173,7 @@ public virtual void incPctYeild(float amount, Pawn miner)
{
minerSkill = miner.skills.GetSkill(SkillDefOf.Mining).Level;
}
//Log.Message("minerSkill is: " + minerSkill);
float proportionDamaged = (float) Mathf.Min(amount, HitPoints) / (float) MaxHitPoints;
float proportionMined = proportionDamaged * minerYield;
yieldPct += proportionMined;
Expand Down Expand Up @@ -921,7 +923,7 @@ public class ThingDef_StaticMineral : ThingDef
{
// How far away it can spawn from an existing location
// Even though it is a static mineral, the map initialization uses "reproduction" to make clusters
public int spawnRadius = 1;
public float spawnRadius = 1;

// The probability that this mineral type will be spawned at all on a given map
public float perMapProbability = 0.5f;
Expand Down Expand Up @@ -1375,7 +1377,7 @@ public virtual StaticMineral SpawnAt(Map map, IntVec3 dest, float size)
GenSpawn.Spawn(output, dest, map, WipeMode.Vanish);
//category = originalDef;
output.size = size;
map.mapDrawer.MapMeshDirty(dest, MapMeshFlag.Buildings);
map.mapDrawer.MapMeshDirty(dest, MapMeshFlagDefOf.Buildings);
//Log.Message("Spawned " + defName + " at " + dest);
return output;
}
Expand Down Expand Up @@ -1408,17 +1410,6 @@ Predicate<IntVec3> isValidSite(Map myMap, IntVec3 myPosition)
{
return c => c.DistanceTo(myPosition) <= spawnRadius && CanSpawnAt(myMap, c);
}

Predicate<IntVec3> isValidSiteDebug(Map myMap, IntVec3 myPosition)
{
return c =>
{
Log.Message("TryFindReproductionDestination: isValidSiteDebug: c: " + c);
Log.Message("TryFindReproductionDestination: isValidSiteDebug: c.DistanceTo(myPosition): " + c.DistanceTo(myPosition));
Log.Message("TryFindReproductionDestination: isValidSiteDebug: CanSpawnAt(myMap, c): " + CanSpawnAt(myMap, c));
return c.DistanceTo(myPosition) <= spawnRadius && CanSpawnAt(myMap, c);
};
}
}


Expand Down Expand Up @@ -1510,7 +1501,17 @@ public virtual float diversitySettingFactor()
// The probablility of spawning at each point when a map is created
public virtual float mapSpawnProbFactor(Map map)
{
return tileSpawnProbFactor(map.Tile);
float result;
try
{
result = tileSpawnProbFactor(map.IsPocketMap? (map.Parent as PocketMapParent).sourceMap.Tile : map.Tile);
}
catch (Exception e)
{
Log.Warning("Minerals: mapSpawnProbFactor: exception caught: " + e + "\n" + map + "\n" + map.Tile + "\n" + map.IsPocketMap + "\n" + (map.Parent as PocketMapParent).sourceMap.Tile);
return 0;
}
return result;
}

// The probablility of spawning at each point when a map is created
Expand Down
Loading

0 comments on commit 90834e7

Please sign in to comment.