From 6f4b75628bf555a2c935eaeb4ef6905896a0f0fe Mon Sep 17 00:00:00 2001 From: ForsakenShell Date: Thu, 9 Jul 2015 15:03:01 -0600 Subject: [PATCH] v0.11.3 [adds] + RestrictedPlacement_Comp now ticks (normal(1:250) and rare(1:1)) and destoys the Thing if it's support disappears, an alert is also thrown to the player [changes] + PlaceWorker_WallAttachment should only work as intended on natural and man-made walls (use edifice AND graphic linker to validate) --- CommunityCoreLibrary.sln | 2 +- CommunityCoreLibrary.userprefs | 15 ++- .../Alerts/Alert_PlaceWorker_Restriction.cs | 91 +++++++++++++++++ DLL_Project/CommunityCoreLibrary.csproj | 4 +- .../PlaceWorkers/PlaceWorker_OnlyOnSurface.cs | 3 +- .../PlaceWorker_WallAttachment.cs | 4 +- DLL_Project/Properties/AssemblyInfo.cs | 4 +- .../ThingComps/RestrictedPlacement_Comp.cs | 92 ++++++++++++++++++ _Mod/Community Core Library/About/About.xml | 2 +- .../Assemblies/Community Core Library.dll | Bin 48640 -> 51200 bytes .../Languages/English/Keyed/PlaceWorkers.xml | 4 +- .../Buildings_PlaceWorker_Restrictions.xml | 48 +++++++++ 12 files changed, 252 insertions(+), 17 deletions(-) create mode 100644 DLL_Project/Alerts/Alert_PlaceWorker_Restriction.cs 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