mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Draft for Thoughts and Penalties of Missing or Multiple Queens
This commit is contained in:
parent
8d541c78c9
commit
b5121b0a04
15 changed files with 405 additions and 18 deletions
|
@ -19,8 +19,15 @@ namespace RJW_Genes
|
|||
|
||||
public override bool Applies(StatRequest req)
|
||||
{
|
||||
// => ModsConfig.BiotechActive && req.HasThing && req.Thing.Spawned && req.Thing.Position.InSunlight(req.Thing.Map);
|
||||
throw new NotImplementedException();
|
||||
if (req.Pawn == null || !req.Pawn.Spawned)
|
||||
return false;
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(req.Pawn, GeneDefOf.rjw_genes_zealous_loyalty))
|
||||
{
|
||||
return HiveUtility.QueensOnMap() >= 2;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,15 @@ namespace RJW_Genes
|
|||
|
||||
public override bool Applies(StatRequest req)
|
||||
{
|
||||
//ModsConfig.BiotechActive && req.HasThing && req.Thing.Spawned && req.Thing.Position.InSunlight(req.Thing.Map);
|
||||
throw new NotImplementedException();
|
||||
if (req.Pawn == null || !req.Pawn.Spawned)
|
||||
return false;
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(req.Pawn, GeneDefOf.rjw_genes_zealous_loyalty))
|
||||
{
|
||||
return HiveUtility.QueensOnMap() == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,36 @@ namespace RJW_Genes
|
|||
/// </summary>
|
||||
public class ConditionalStatAffecter_QueenCloseBy : ConditionalStatAffecter
|
||||
{
|
||||
|
||||
const float EFFECT_DISTANCE = 10.0f;
|
||||
|
||||
public override string Label => (string)"StatsReport_QueenCloseBy".Translate();
|
||||
|
||||
public override bool Applies(StatRequest req)
|
||||
{
|
||||
// => ModsConfig.BiotechActive && req.HasThing && req.Thing.Spawned && req.Thing.Position.InSunlight(req.Thing.Map);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
if (req.Pawn == null || !req.Pawn.Spawned)
|
||||
return false;
|
||||
|
||||
// Case A: Check for Loyal Pawns if their One Queen is nearby
|
||||
if (GeneUtility.HasGeneNullCheck(req.Pawn, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 1)
|
||||
{
|
||||
Pawn queen = HiveUtility.GetQueensOnMap()[0];
|
||||
|
||||
return req.Pawn.Position.DistanceTo(queen.Position) <= EFFECT_DISTANCE;
|
||||
}
|
||||
|
||||
// Case A: Check for Queen if another Queen is nearby
|
||||
if (GeneUtility.HasGeneNullCheck(req.Pawn, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() >= 2)
|
||||
{
|
||||
foreach (Pawn queen in HiveUtility.GetQueensOnMap())
|
||||
{
|
||||
if (queen != req.Pawn && req.Pawn.Position.DistanceTo(queen.Position) <= EFFECT_DISTANCE)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
39
Source/Genes/Hive/Helpers/HiveUtility.cs
Normal file
39
Source/Genes/Hive/Helpers/HiveUtility.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
internal class HiveUtility
|
||||
{
|
||||
public static bool IsAdultQueen(Pawn pawn)
|
||||
{
|
||||
|
||||
if (pawn == null || !pawn.Spawned)
|
||||
return false;
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_queen))
|
||||
{
|
||||
return pawn.ageTracker.Adult;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int QueensOnMap()
|
||||
{
|
||||
List<Pawn> playersPawns = Find.CurrentMap.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer);
|
||||
return playersPawns.Count(pawn => pawn.Spawned && IsAdultQueen(pawn));
|
||||
}
|
||||
|
||||
public static List<Pawn> GetQueensOnMap()
|
||||
{
|
||||
List<Pawn> playersPawns = Find.CurrentMap.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer);
|
||||
return playersPawns.FindAll(pawn => pawn.Spawned && IsAdultQueen(pawn));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class ThoughtWorker_QueenPresent_Social : ThoughtWorker
|
||||
{
|
||||
protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
|
||||
{
|
||||
if (!p.RaceProps.Humanlike)
|
||||
return (ThoughtState) false;
|
||||
|
||||
if (!other.RaceProps.Humanlike)
|
||||
return (ThoughtState) false;
|
||||
|
||||
if (!RelationsUtility.PawnsKnowEachOther(p, other))
|
||||
return (ThoughtState) false;
|
||||
|
||||
// Only check if they are spawned
|
||||
if (!p.Spawned || !other.Spawned)
|
||||
{
|
||||
return (ThoughtState)false;
|
||||
}
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 1)
|
||||
{
|
||||
return (ThoughtState) HiveUtility.IsAdultQueen(other);
|
||||
}
|
||||
|
||||
return (ThoughtState)false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class ThoughtWorker_RivalQueen_Social : ThoughtWorker
|
||||
{
|
||||
protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
|
||||
{
|
||||
if (!p.RaceProps.Humanlike)
|
||||
return (ThoughtState)false;
|
||||
if (!other.RaceProps.Humanlike)
|
||||
return (ThoughtState)false;
|
||||
|
||||
if (!RelationsUtility.PawnsKnowEachOther(p, other))
|
||||
return (ThoughtState)false;
|
||||
|
||||
// Only check if they are spawned
|
||||
if (!p.Spawned || !other.Spawned)
|
||||
{
|
||||
return (ThoughtState)false;
|
||||
}
|
||||
|
||||
if(HiveUtility.IsAdultQueen(p) && HiveUtility.IsAdultQueen(other))
|
||||
{
|
||||
return (ThoughtState)true;
|
||||
}
|
||||
return (ThoughtState)false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class Thoughtworker_MultipleQueens_Mood : ThoughtWorker
|
||||
{
|
||||
|
||||
protected override ThoughtState CurrentStateInternal(Pawn p)
|
||||
{
|
||||
// Error Handling and Check for Pawn being on Map
|
||||
if (p == null || !p.Spawned)
|
||||
return (ThoughtState) false;
|
||||
// Queens cannot have loyalty thoughts
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_queen))
|
||||
return (ThoughtState)false;
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() >= 2)
|
||||
{
|
||||
return (ThoughtState)true;
|
||||
}
|
||||
|
||||
return (ThoughtState) false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
33
Source/Genes/Hive/Thoughts/Thoughtworker_QueenAbsent_Mood.cs
Normal file
33
Source/Genes/Hive/Thoughts/Thoughtworker_QueenAbsent_Mood.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class Thoughtworker_QueenAbsent_Mood : ThoughtWorker
|
||||
{
|
||||
|
||||
protected override ThoughtState CurrentStateInternal(Pawn p)
|
||||
{
|
||||
// Error Handling and Check for Pawn being on Map
|
||||
if (p == null || !p.Spawned)
|
||||
return (ThoughtState) false;
|
||||
// Queens cannot have loyalty thoughts
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_queen))
|
||||
return (ThoughtState)false;
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 0)
|
||||
{
|
||||
return (ThoughtState)true;
|
||||
}
|
||||
|
||||
return (ThoughtState) false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class Thoughtworker_QueenPresent_Mood : ThoughtWorker
|
||||
{
|
||||
|
||||
protected override ThoughtState CurrentStateInternal(Pawn p)
|
||||
{
|
||||
// Error Handling and Check for Pawn being on Map
|
||||
if (p == null || !p.Spawned)
|
||||
return (ThoughtState) false;
|
||||
// Queens cannot have loyalty thoughts
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_queen))
|
||||
return (ThoughtState)false;
|
||||
|
||||
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 1)
|
||||
{
|
||||
return (ThoughtState)true;
|
||||
}
|
||||
|
||||
return (ThoughtState) false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
29
Source/Genes/Hive/Thoughts/Thoughtworker_RivalQueen_Mood.cs
Normal file
29
Source/Genes/Hive/Thoughts/Thoughtworker_RivalQueen_Mood.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class Thoughtworker_RivalQueen_Mood : ThoughtWorker
|
||||
{
|
||||
|
||||
protected override ThoughtState CurrentStateInternal(Pawn p)
|
||||
{
|
||||
if (p == null || !p.Spawned)
|
||||
return (ThoughtState) false;
|
||||
|
||||
if (HiveUtility.IsAdultQueen(p) && HiveUtility.QueensOnMap() >= 2)
|
||||
{
|
||||
return (ThoughtState) true;
|
||||
}
|
||||
|
||||
return (ThoughtState) false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue