diff --git a/CommunityCoreLibrary.sln b/CommunityCoreLibrary.sln index 3e5cb6e..da31265 100644 --- a/CommunityCoreLibrary.sln +++ b/CommunityCoreLibrary.sln @@ -215,7 +215,7 @@ Global $30.inheritsScope = text/plain $30.scope = text/plain description = RimWorld Alpha 11 Community Core Library - version = 0.11.1 + version = 0.11.3 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CommunityCoreLibrary.userprefs b/CommunityCoreLibrary.userprefs index f449d77..52b4d86 100644 --- a/CommunityCoreLibrary.userprefs +++ b/CommunityCoreLibrary.userprefs @@ -1,14 +1,13 @@  - + - - - - - - - + + + + + + diff --git a/DLL_Project/Alerts/Alert_PlaceWorker_Restriction.cs b/DLL_Project/Alerts/Alert_PlaceWorker_Restriction.cs new file mode 100644 index 0000000..dcee086 --- /dev/null +++ b/DLL_Project/Alerts/Alert_PlaceWorker_Restriction.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using RimWorld; +using UnityEngine; +using Verse; +using Verse.AI; + +namespace CommunityCoreLibrary +{ + + public static class PlaceWorker_Restriction_Alert_Data + { + private static List< Thing > destroyedThings; + public static List< Thing > DestroyedThings + { + get{ return destroyedThings; } + } + + private static int cooldownTicks; + + public static bool AlertPlayer + { + get{ return ( destroyedThings.Count > 0 ); } + } + + static PlaceWorker_Restriction_Alert_Data() + { + destroyedThings = new List(); + cooldownTicks = 0; + } + + public static void Cooldown( int ticks = 1 ) + { + cooldownTicks -= ticks; + if( ( cooldownTicks <= 0 )&& + ( destroyedThings.Count > 0 ) ) + destroyedThings.Clear(); + } + + public static void Add( Thing thing ) + { + destroyedThings.Add( thing ); + cooldownTicks = 250; + } + + } + + public class Alert_PlaceWorker_Restriction : Alert_Critical + { + public override AlertReport Report + { + get + { + // Alert the player if something got destroyed + if( PlaceWorker_Restriction_Alert_Data.AlertPlayer == false ) + return false; + + // Return the first or default instance as the culprit + return AlertReport.CulpritIs( PlaceWorker_Restriction_Alert_Data.DestroyedThings.FirstOrDefault() ); + } + } + + public override string FullExplanation{ + get{ + var msg = new StringBuilder(); + msg.AppendLine( "AlertPlaceWorkerRestrictionSupportRemovedDesc".Translate() ); + foreach( var t in PlaceWorker_Restriction_Alert_Data.DestroyedThings ) + msg.AppendLine( " " + t.def.defName ); + return msg.ToString(); + } + } + public override void AlertActiveUpdate() + { + if( PlaceWorker_Restriction_Alert_Data.AlertPlayer == true ) + { + base.AlertActiveUpdate(); + PlaceWorker_Restriction_Alert_Data.Cooldown(); + } + } + + public Alert_PlaceWorker_Restriction() + { + this.baseLabel = "AlertPlaceWorkerRestrictionSupportRemovedLabel".Translate(); + } + + } +} + diff --git a/DLL_Project/CommunityCoreLibrary.csproj b/DLL_Project/CommunityCoreLibrary.csproj index ae16157..77ddb9d 100644 --- a/DLL_Project/CommunityCoreLibrary.csproj +++ b/DLL_Project/CommunityCoreLibrary.csproj @@ -12,7 +12,7 @@ v3.5 512 - 0.11.1 + 0.11.3 true @@ -83,6 +83,7 @@ + +
  • CommunityCoreLibrary.PlaceWorker_OnlyUnderRoof
  • + + Furniture + false + + + RestrictedCountTest @@ -48,6 +90,7 @@ +
  • CommunityCoreLibrary.PlaceWorker_RestrictedCount
  • Furniture @@ -94,6 +137,7 @@ Any +
  • CommunityCoreLibrary.PlaceWorker_NotOnTerrain
  • Furniture @@ -140,6 +184,7 @@ Any +
  • CommunityCoreLibrary.PlaceWorker_OnlyOnTerrain
  • Furniture @@ -191,6 +236,7 @@ Heavy +
  • CommunityCoreLibrary.PlaceWorker_NotOnThing
  • Furniture @@ -241,7 +287,9 @@ Heavy + Rare +
  • CommunityCoreLibrary.PlaceWorker_OnlyOnThing
  • Furniture