-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from cyinghan/master
update for 1.4 and enemy raid mount fix
- Loading branch information
Showing
58 changed files
with
17,486 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using HugsLib; | ||
using HugsLib.Utils; | ||
using Verse; | ||
using UnityEngine; | ||
using HugsLib.Settings; | ||
using GiddyUpCore.Storage; | ||
using RimWorld; | ||
using Battlemounts.Concepts; | ||
|
||
namespace BattleMounts | ||
{ | ||
public class Base : ModBase | ||
{ | ||
internal static Base Instance { get; private set; } | ||
|
||
internal static SettingHandle<int> enemyMountChance; | ||
internal static SettingHandle<int> enemyMountChanceTribal; | ||
|
||
internal static SettingHandle<int> inBiomeWeight; | ||
internal static SettingHandle<int> outBiomeWeight; | ||
internal static SettingHandle<int> nonWildWeight; | ||
|
||
private int minPercentage = 0; | ||
private int maxPercentage = 100; | ||
|
||
public override string ModIdentifier | ||
{ | ||
get { return "BattleMounts"; } | ||
} | ||
public Base() | ||
{ | ||
Instance = this; | ||
} | ||
public override void DefsLoaded() | ||
{ | ||
base.DefsLoaded(); | ||
|
||
enemyMountChance = Settings.GetHandle<int>("enemyMountChance", "BM_EnemyMountChance_Title".Translate(), "BM_EnemyMountChance_Description".Translate(), 20, Validators.IntRangeValidator(minPercentage, maxPercentage)); | ||
enemyMountChanceTribal = Settings.GetHandle<int>("enemyMountChanceTribal", "BM_EnemyMountChanceTribal_Title".Translate(), "BM_EnemyMountChanceTribal_Description".Translate(), 40, Validators.IntRangeValidator(minPercentage, maxPercentage)); | ||
|
||
inBiomeWeight = Settings.GetHandle<int>("inBiomeWeight", "BM_InBiomeWeight_Title".Translate(), "BM_InBiomeWeight_Description".Translate(), 70, Validators.IntRangeValidator(minPercentage, maxPercentage)); | ||
outBiomeWeight = Settings.GetHandle<int>("outBiomeWeight", "BM_OutBiomeWeight_Title".Translate(), "BM_OutBiomeWeight_Description".Translate(), 15, Validators.IntRangeValidator(minPercentage, maxPercentage)); | ||
nonWildWeight = Settings.GetHandle<int>("nonWildWeight", "BM_NonWildWeight_Title".Translate(), "BM_NonWildWeight_Description".Translate(), 15, Validators.IntRangeValidator(minPercentage, maxPercentage)); | ||
|
||
|
||
} | ||
public override void WorldLoaded() | ||
{ | ||
base.WorldLoaded(); | ||
LessonAutoActivator.TeachOpportunity(BM_ConceptDefOf.BM_Mounting, OpportunityType.GoodToKnow); | ||
LessonAutoActivator.TeachOpportunity(BM_ConceptDefOf.BM_Enemy_Mounting, OpportunityType.GoodToKnow); | ||
} | ||
|
||
public ExtendedDataStorage GetExtendedDataStorage() | ||
{ | ||
return GiddyUpCore.Base.Instance.GetExtendedDataStorage(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8092BA5D-6451-4BA3-A1F5-914AC774A8B3}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Battlemounts</RootNamespace> | ||
<AssemblyName>Battlemounts</AssemblyName> | ||
<TargetFramework>net472</TargetFramework> | ||
<FileAlignment>512</FileAlignment> | ||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>false</DebugSymbols> | ||
<DebugType>none</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\..\Assemblies\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Base.cs" /> | ||
<Compile Include="Concepts\BM_ConceptDefOf.cs" /> | ||
<Compile Include="Harmony\IncidentWorker_Ambush_EnemyFaction.cs" /> | ||
<Compile Include="Harmony\IncidentWorker_Raid.cs" /> | ||
<Compile Include="Harmony\Jobdriver_Cleanup.cs" /> | ||
<Compile Include="Harmony\Pawn_JobTracker.cs" /> | ||
<Compile Include="Harmony\FloatMenuMakerMap.cs" /> | ||
<Compile Include="Legacy\BM_JobDefOf.cs" /> | ||
<Compile Include="Legacy\JobDriver_Mounted_Battlemount.cs" /> | ||
<Compile Include="Legacy\JobDriver_Mount_Battlemount.cs" /> | ||
<Compile Include="ModExtensions\MultiplayerPatch.cs" /> | ||
<Compile Include="Utilities\EnemyMountUtility.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="0MultiplayerAPI"> | ||
<HintPath>packages\0MultiplayerAPI.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="GiddyUpCore"> | ||
<HintPath>..\..\..\..\GiddyUpCore\1.4\Assemblies\GiddyUpCore.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\..\..\..\..\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<PackageReference Include="Lib.Harmony"> | ||
<Version>2.1.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="TaskPubliciser"> | ||
<Version>1.0.3</Version> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="UnlimitedHugs.Rimworld.HugsLib"> | ||
<Version>9.0.0</Version> | ||
<ExcludeAssets>runtime</ExcludeAssets> | ||
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
<Target Name="MyCode" BeforeTargets="UpdateReferences"> | ||
<PropertyGroup> | ||
<AssemblyCSharp>$(PkgKrafs_Rimworld_Ref)\ref\net472\Assembly-CSharp.dll</AssemblyCSharp> | ||
<PubliciseOutputPath>$(PkgKrafs_Rimworld_Ref)\ref\net472\</PubliciseOutputPath> | ||
<AssemblyCSharp_Publicised>$(PubliciseOutputPath)Assembly-CSharp_publicised.dll</AssemblyCSharp_Publicised> | ||
</PropertyGroup> | ||
<Publicise TargetAssemblyPath="$(AssemblyCSharp)" OutputPath="$(PubliciseOutputPath)" Condition="Exists('$(AssemblyCSharp)')" /> | ||
<ItemGroup> | ||
<Reference Include="$(AssemblyCSharp_Publicised)"> | ||
<SpecificVersion>false</SpecificVersion> | ||
<HintPath>$(AssemblyCSharp_Publicised)</HintPath> | ||
<Implicit>true</Implicit> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</Target> | ||
<Target Name="UpdateReferences" AfterTargets="ResolveLockFileReferences"> | ||
<ItemGroup> | ||
<Reference Remove="$(PkgKrafs_Rimworld_Ref)\ref\net472\Assembly-CSharp.dll" /> | ||
</ItemGroup> | ||
</Target> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26730.16 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BattleMounts", "BattleMounts.csproj", "{8092BA5D-6451-4BA3-A1F5-914AC774A8B3}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8092BA5D-6451-4BA3-A1F5-914AC774A8B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8092BA5D-6451-4BA3-A1F5-914AC774A8B3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8092BA5D-6451-4BA3-A1F5-914AC774A8B3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8092BA5D-6451-4BA3-A1F5-914AC774A8B3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {90CEBB6F-C385-4B55-A4D3-664D4E3C7466} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Battlemounts.Concepts | ||
{ | ||
[DefOf] | ||
class BM_ConceptDefOf | ||
{ | ||
public static ConceptDef BM_Mounting; | ||
public static ConceptDef BM_Enemy_Mounting; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using HarmonyLib; | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
using Verse.AI; | ||
using GiddyUpCore; | ||
using GiddyUpCore.Jobs; | ||
using GiddyUpCore.Utilities; | ||
|
||
namespace BattleMounts.Harmony | ||
{ | ||
[HarmonyPatch(typeof(FloatMenuMakerMap), "AddDraftedOrders")] | ||
[HarmonyPatch(new Type[] { typeof(Vector3), typeof(Pawn), typeof(List<FloatMenuOption>), typeof(bool) })] | ||
static class FloatMenuMakerMap_AddDraftedOrders | ||
{ | ||
static void Postfix(Vector3 clickPos, Pawn pawn, List<FloatMenuOption> opts) | ||
{ | ||
foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true)) | ||
{ | ||
if ((current.Thing is Pawn target) && target.RaceProps.Animal) | ||
{ | ||
GUC_FloatMenuUtility.AddMountingOptions(target, pawn, opts); | ||
} | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
1.4/Source/BattleMounts/Harmony/IncidentWorker_Ambush_EnemyFaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Battlemounts.Utilities; | ||
using BattleMounts; | ||
using GiddyUpCore.Utilities; | ||
using HarmonyLib; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using System.Text; | ||
using Verse; | ||
|
||
namespace Battlemounts.Harmony | ||
{ | ||
[HarmonyPatch(typeof(IncidentWorker_Ambush), "DoExecute")] | ||
static class IncidentWorker_Ambush_DoExecute | ||
{ | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
var instructionsList = new List<CodeInstruction>(instructions); | ||
for (var i = 0; i < instructionsList.Count; i++) | ||
{ | ||
CodeInstruction instruction = instructionsList[i]; | ||
yield return instruction; | ||
|
||
if (instructionsList[i].operand as MethodInfo == AccessTools.Method(typeof(IncidentWorker_Ambush), "PostProcessGeneratedPawnsAfterSpawning")) //Identifier for which IL line to inject to | ||
|
||
{ | ||
yield return new CodeInstruction(OpCodes.Ldarga_S, 2);//load generated pawns as parameter | ||
yield return new CodeInstruction(OpCodes.Ldarg_1);//load incidentparms as parameter | ||
yield return new CodeInstruction(OpCodes.Call, typeof(EnemyMountUtility).GetMethod("mountAnimals"));//Injected code //yield return new CodeInstruction(OpCodes.Stloc_2); | ||
} | ||
|
||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Battlemounts.Utilities; | ||
using BattleMounts; | ||
using GiddyUpCore.Utilities; | ||
using HarmonyLib; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using System.Text; | ||
using Verse; | ||
using Verse.AI; | ||
using Verse.AI.Group; | ||
|
||
namespace Battlemounts.Harmony | ||
{ | ||
[HarmonyPatch(typeof(IncidentWorker_Raid), "TryGenerateRaidInfo")] | ||
static class IncidentWorker_Raid_TryGenerateRaidInfo | ||
{ | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
var instructionsList = new List<CodeInstruction>(instructions); | ||
|
||
foreach (var instruction in instructionsList) | ||
{ | ||
if (instruction.operand as MethodInfo == AccessTools.Method(typeof(PawnsArrivalModeWorker), "Arrive")) | ||
{ | ||
yield return new CodeInstruction(OpCodes.Call, typeof(IncidentWorker_Raid_TryGenerateRaidInfo).GetMethod("MountAnimals"));//don't execute this, execute it in MountAnimals | ||
continue; | ||
} | ||
yield return instruction; | ||
} | ||
} | ||
|
||
|
||
public static void MountAnimals(PawnsArrivalModeWorker instance, List<Pawn> pawns, IncidentParms parms) | ||
{; | ||
|
||
|
||
if (pawns.Count == 0) | ||
{ | ||
return; | ||
} | ||
parms.raidArrivalMode.Worker.Arrive(pawns, parms); | ||
if (!(parms.raidArrivalMode == null || parms.raidArrivalMode == PawnsArrivalModeDefOf.EdgeWalkIn) || (parms.raidStrategy != null && parms.raidStrategy.workerClass == typeof(RaidStrategyWorker_Siege))) | ||
{ | ||
return; | ||
} | ||
NPCMountUtility.generateMounts(ref pawns, parms, Base.inBiomeWeight, Base.outBiomeWeight, Base.nonWildWeight, Base.enemyMountChance, Base.enemyMountChanceTribal); | ||
|
||
foreach (Pawn pawn in pawns) | ||
{ | ||
if (pawn.equipment == null) | ||
{ | ||
pawn.equipment = new Pawn_EquipmentTracker(pawn); | ||
} | ||
} | ||
foreach(Pawn pawn in pawns)//Moved this code here so we can check if the pawn actually has apparel. | ||
{ | ||
if (pawn.apparel != null && pawn.apparel.WornApparel != null && pawn.apparel.WornApparel.Any((Apparel ap) => ap.def == ThingDefOf.Apparel_ShieldBelt)) | ||
{ | ||
LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
} |
Oops, something went wrong.