├── ExtendedComponents.png ├── ExtendedThingCode ├── Druid_Traps.xml ├── PlantTrapProperties.cs ├── Plant_Trap.cs └── readme.md ├── LICENSE ├── README.md ├── RimWorldThings.png └── src ├── CompSlotLoadable.png ├── CompToggleDef1.png ├── CompToggleDef2.png ├── Gizmos.png ├── Jobs_from_white_alter.png ├── MainTabs.png ├── ModdingOverview.pdf └── PawnSelected.png /ExtendedComponents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/ExtendedComponents.png -------------------------------------------------------------------------------- /ExtendedThingCode/Druid_Traps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Plant 6 | UnificaMagica.PlantExtended 7 | LowPlant 8 | True 9 | 10 | 0.8 11 | 12 | Long 13 | False 14 | True 15 | MapMeshOnly 16 | false 17 | 18 | CutoutPlant 19 | 20 | 21 | Plant 22 | RawBad 23 | 24 | 25 | 0.5 26 | 1.0 27 | true 28 | Harvest_Standard 29 | Harvest_Standard_Finish 30 | 190 31 | 260 32 | 0.1 33 | 34 | 0.3 35 | 1.00 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | DruidHerbs 44 | 45 | A beautiful collection of herbs in this pot. You feel slight magic wafting through them. 46 | Normal 47 | 48 | 85 49 | 34 50 | 51 | 52 | Things/Plant/Daylily 53 | Graphic_Random 54 | 55 | Item 56 | true 57 | 58 | 0.03 59 | 60 | 61 | 1 62 | true 63 | false 64 | Standard 65 | true 66 | 400 67 | 68 |
  • SowDruidDefensiveSpot
  • 69 |
  • Decorative
  • 70 |
    71 | 0.3 72 | 0.1 73 | 1.5 74 | 5 75 | 76 | 0.3 77 | 1.05 78 | 79 |
    80 | 81 | 82 |
    83 | 84 | 85 | 86 | 87 | EntanglingVinePlant 88 | 89 | This wirey plant seems to move and sway on its own. You feel like it's watching you, and that makes you nervous. 90 | Normal 91 | 92 | 85 93 | 34 94 | 95 | 96 | Things/Plant/Daylily 97 | Graphic_Random 98 | 99 | Item 100 | true 101 | 102 | 0.03 103 | 104 | 105 | 1 106 | true 107 | false 108 | Standard 109 | true 110 | 400 111 | 112 |
  • SowDruidDefensiveSpot
  • 113 |
    114 | 0.3 115 | 0.1 116 | 1.5 117 | 5 118 | 119 | 0.3 120 | 1.05 121 | 122 |
    123 | 124 |
  • 125 | Entangling Vines ready 126 | 6 127 | EntanglingVines 128 | 1000 129 | 0.8 130 | true 131 |
  • 132 |
    133 |
    134 | 135 | 136 | EntanglingVines 137 | ThingWithComps 138 | Item 139 | 140 | Vines snare you as you step. 141 | 142 | Things/Druid/Plant_EntanglingVine 143 | Graphic_Single 144 | 145 | Item 146 | PassThroughOnly 147 | 0.0 148 | Wood_Drop 149 | Wood_Drop 150 | 151 | 0.0 152 | 10 153 | 0.4 154 | 1.0 155 | 500 156 | -1 157 | -1 158 | 159 | true 160 | Rare 161 | 90 162 | true 163 | MapMeshOnly 164 | true 165 | true 166 | 1 167 | Never 168 | 169 |
  • Chunks
  • 170 |
    171 | 172 |
  • 173 | 0.1 174 | true 175 |
  • 176 |
    177 |
    178 | 179 | 180 | 181 | 182 | PoppingFernPlant 183 | 184 | A typical fern in most aspects until you see the large central pod. It is covered in downy fur and seems to breath slightly under stress. 185 | Normal 186 | 187 | 15 188 | 34 189 | 190 | 191 | Things/Plant/Daylily 192 | Graphic_Random 193 | 194 | Item 195 | true 196 | 197 | 0.03 198 | 199 | 200 | 1 201 | true 202 | false 203 | Standard 204 | true 205 | 400 206 | 207 |
  • SowDruidDefensiveSpot
  • 208 |
    209 | 0.3 210 | 0.1 211 | 1.5 212 | 5 213 | 214 | 0.3 215 | 1.05 216 | 217 |
    218 | 219 |
  • 220 | Ready to explode 221 | 5000 222 | true 223 | 0.8 224 | 50 225 | MortarBomb_Explode 226 |
  • 227 |
    228 |
    229 | 230 | 231 | 232 | 233 | DruidDefensiveSpot 234 | 235 | Druids plant specialized plants here for short range defenses. 236 | Building_PlantGrower 237 | 238 | Things/Building/Furniture/PlantPot 239 | Graphic_Single 240 | 241 | (0.3, 0.6, 0.3) 242 | 243 | 244 | (0.2,0.2,0.6,0.6) 245 | 246 | 247 | Building 248 | PassThroughOnly 249 | 0.20 250 | 251 | 100 252 | 495 253 | 2 254 | 0.0 255 | 256 | 257 |
  • Woody
  • 258 |
  • Stony
  • 259 |
    260 | 35 261 | 262 |
  • 263 | 264 | 1.0 265 | Misc9 266 | false 267 | 268 | DruidHerbs 269 | SowDruidDefensiveSpot 270 | 271 | false 272 | 273 |
  • PlaceWorker_NotUnderRoof
  • 274 | 275 | 2.4 276 | 277 |
  • 278 | Bomb 279 | .1 280 |
  • 281 |
    282 | 286 |
    287 | 288 | 289 |
    290 | -------------------------------------------------------------------------------- /ExtendedThingCode/PlantTrapProperties.cs: -------------------------------------------------------------------------------- 1 | using RimWorld; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System; 7 | using Verse; 8 | 9 | namespace UnificaMagica { 10 | 11 | 12 | public static class ExtendedComponent { 13 | 14 | public static void InitializeExtComps(IExtendedThing _thing) { 15 | List l = new List(); 16 | _thing.ExtComps = l; 17 | Log.Message("ExtendedComponent.InitializeExtComps 1"); 18 | for (int i = 0; i < _thing.def.extcomps.Count; i++) { 19 | Log.Message("ExtendedComponent.InitializeExtComps 1.1"); 20 | ExtInstComp extComp = (ExtInstComp)Activator.CreateInstance (_thing.def.extcomps[i].compClass); 21 | Log.Message("ExtendedComponent.InitializeExtComps 1.2"); 22 | extComp.parent = _thing; 23 | Log.Message("ExtendedComponent.InitializeExtComps 1.3"); 24 | l.Add(extComp);// _thing.ExtComps.Add(extComp); 25 | Log.Message("ExtendedComponent.InitializeExtComps 1.4"); 26 | extComp.Initialize (_thing.def.extcomps[i]); 27 | Log.Message("ExtendedComponent.InitializeExtComps 1.5"); 28 | } 29 | Log.Message("ExtendedComponent.InitializeExtComps 2"); 30 | } 31 | 32 | }; 33 | 34 | 35 | // ExtendedComponent is my redo of Components that don't depdend on parent being a ThingWithComps 36 | // ExtComps_X is the load-time defined data of the ExtendedComponent. 37 | // ExtInstComps_X is the instance definition of the ExtendedComponent with local data and functionality. 38 | // At Runtime, the ExtComps_X create the ExtInstComps_X. 39 | 40 | public class ExtComp { 41 | 42 | public Type compClass; 43 | 44 | public ExtComp() { 45 | } 46 | public ExtComp(Type compClass) { 47 | this.compClass = compClass; 48 | } 49 | } 50 | 51 | // definition of 52 | public class ExtComp_PlantTrap : ExtComp { 53 | public int rearmTime = 2000; // num ticks to rearm 54 | public bool isAoE = true; 55 | public float TrapSpringChance = 0.8f; 56 | public string ArmedLabel = "unnamed plant trap"; 57 | 58 | public ExtComp_PlantTrap() { 59 | this.compClass = typeof(ExtInstComp_PlantTrap); 60 | } 61 | } 62 | 63 | 64 | public class ExtInstComp { 65 | public IExtendedThing parent; 66 | public ExtComp propsint; // static properties of the ExtendedComponent 67 | // need to get to write to file and initialize 68 | 69 | public virtual void Initialize(ExtComp props) { this.propsint = props; } 70 | public virtual void PostExposeData() { 71 | } 72 | 73 | public ExtComp Props { 74 | get 75 | { 76 | return this.propsint; 77 | } 78 | } 79 | } 80 | 81 | // instance data added to CompProperties_X 82 | public class ExtInstComp_PlantTrap : ExtInstComp { 83 | public int rearmAt = -1; 84 | public bool Armed = true; 85 | 86 | // Returns true if sprung 87 | public virtual void SpringPlantTrap( Pawn p, PlantExtended pt) { 88 | this.Armed = false; 89 | this.rearmAt = Find.TickManager.TicksGame + this.Props.rearmTime;//((ExtComp_PlantTrap)this.props).rearmTime; 90 | } 91 | 92 | public override void PostExposeData() { 93 | Log.Message("ExtInstComp_PlantTrap.postExposeData 1"); 94 | base.PostExposeData(); 95 | Log.Message("ExtInstComp_PlantTrap.postExposeData 2"); 96 | Scribe_Values.LookValue(ref this.rearmAt, "rearmAt", -1, false); 97 | Log.Message("ExtInstComp_PlantTrap.postExposeData 3"); 98 | Scribe_Values.LookValue(ref this.Armed, "Armed", true, false); 99 | Log.Message("ExtInstComp_PlantTrap.postExposeData 4"); 100 | } 101 | 102 | public new ExtComp_PlantTrap Props 103 | { 104 | get 105 | { 106 | return (ExtComp_PlantTrap)this.propsint; 107 | } 108 | } 109 | } 110 | 111 | 112 | 113 | /* 114 | // definition of 115 | public class CompProperties_PlantTrap_Explode : CompProperties_PlantTrap { 116 | public int damageAmountBase = 1; 117 | public SoundDef soundExplode = null; 118 | 119 | public CompProperties_PlantTrap_Explode() { 120 | this.compClass = typeof(CompPlantTrap_Explode); 121 | } 122 | }; 123 | 124 | // instance of 125 | public class CompPlantTrap_Explode : CompPlantTrap { 126 | //public float explosionRadius =this.thepot.def.specialDisplayRadius; 127 | 128 | public override void SpringPlantTrap( Pawn p, Plant_Trap pt ){ 129 | // public static void DoExplosion (IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, SoundDef explosionSound = null, ThingDef projectile = null, ThingDef source = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1) 130 | GenExplosion.DoExplosion (pt.Position, pt.Map, pt.thepot.def.specialDisplayRadius, DamageDefOf.Bomb, pt, this.soundExplode); 131 | } 132 | } 133 | */ 134 | 135 | 136 | public class ExtComp_PlantTrap_Generator : ExtComp_PlantTrap { 137 | public int numGen; 138 | public ThingDef genthing; 139 | 140 | public ExtComp_PlantTrap_Generator() { 141 | this.compClass = typeof(ExtInstComp_PlantTrap_Generator); 142 | } 143 | } 144 | 145 | 146 | 147 | public class ExtInstComp_PlantTrap_Generator : ExtInstComp_PlantTrap { 148 | 149 | public override void SpringPlantTrap( Pawn p, PlantExtended pt) 150 | { 151 | base.SpringPlantTrap(p,pt); 152 | for(int i = 0; i< this.Props.numGen ; i++ ) { 153 | Thing thing = ThingMaker.MakeThing(this.Props.genthing, null); 154 | GenPlace.TryPlaceThing(thing, pt.Position, pt.Map , ThingPlaceMode.Near, null); 155 | } 156 | } 157 | 158 | public override void PostExposeData() { 159 | Log.Message("ExtInstComp_PlantTrap_Generator.postExposeData 1"); 160 | base.PostExposeData(); 161 | Log.Message("ExtInstComp_PlantTrap_Generator.postExposeData 2"); 162 | // Scribe_Values.LookValue(ref this.numGen, "numGen", null, false); // default value is in ThingDef 163 | // Log.Message("ExtInstComp_PlantTrap_Generator.postExposeData 3"); 164 | // Scribe_Values.LookValue(ref this.genthing, "genthing", null , false); // default value is in ThingDef 165 | // Log.Message("ExtInstComp_PlantTrap_Generator.postExposeData 4"); 166 | } 167 | 168 | public new ExtComp_PlantTrap_Generator Props 169 | { 170 | get 171 | { 172 | return (ExtComp_PlantTrap_Generator)this.propsint; 173 | } 174 | } 175 | } 176 | 177 | 178 | 179 | 180 | public class ExtComp_PlantTrap_Explosive : ExtComp_PlantTrap { 181 | public int damageAmountBase = 1; 182 | public SoundDef soundExplode = null; 183 | 184 | public ExtComp_PlantTrap_Explosive() { 185 | this.compClass = typeof(ExtInstComp_PlantTrap_Explosive); 186 | } 187 | } 188 | 189 | public class ExtInstComp_PlantTrap_Explosive : ExtInstComp_PlantTrap { 190 | 191 | public override void SpringPlantTrap( Pawn p, PlantExtended pt) 192 | { 193 | base.SpringPlantTrap(p,pt); 194 | // public static void DoExplosion (IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, SoundDef explosionSound = null, ThingDef projectile = null, ThingDef source = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1) 195 | GenExplosion.DoExplosion (pt.Position, pt.Map, pt.thepot.def.specialDisplayRadius, DamageDefOf.Bomb, pt, this.Props.soundExplode); 196 | } 197 | 198 | public override void PostExposeData() { 199 | base.PostExposeData(); 200 | // Scribe_Values.LookValue(ref this.numGen, "numGen", null, false); // default value is in ThingDef 201 | // Log.Message("ExtInstComp_PlantTrap_Generator.postExposeData 3"); 202 | // Scribe_Values.LookValue(ref this.genthing, "genthing", null , false); // default value is in ThingDef 203 | // Log.Message("ExtInstComp_PlantTrap_Generator.postExposeData 4"); 204 | } 205 | 206 | public new ExtComp_PlantTrap_Explosive Props 207 | { 208 | get 209 | { 210 | return (ExtComp_PlantTrap_Explosive)this.propsint; 211 | } 212 | } 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /ExtendedThingCode/Plant_Trap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using UnityEngine; 6 | using Verse; 7 | using Verse.Sound; 8 | using RimWorld; 9 | 10 | namespace UnificaMagica 11 | { 12 | 13 | // [StaticConstructorOnStartup] 14 | public class ExtThingDef: Verse.ThingDef { 15 | public List extcomps = new List(); 16 | } 17 | 18 | // ExtendedThings are extended with Extended Components (ExtComp and ExtInstComp) 19 | public interface IExtendedThing { 20 | List ExtComps { 21 | get; 22 | set; 23 | } 24 | ExtThingDef def { 25 | get; 26 | set; 27 | } 28 | 29 | // initialize ExtComps when creating and loading 30 | void PostMake(); 31 | void ExposeData(); 32 | } 33 | 34 | 35 | [StaticConstructorOnStartup] 36 | public class PlantExtended : Plant, IExtendedThing { 37 | 38 | protected List extcomps = null; // set during InitializeExtendedComps 39 | // ExtThingDef defint; 40 | 41 | public List ExtComps { 42 | get { return this.extcomps; } 43 | set { this.extcomps = value; } 44 | } 45 | public new ExtThingDef def { 46 | get { return (ExtThingDef) base.def; } 47 | set { 48 | ExtThingDef dd = value as ExtThingDef; 49 | if ( dd == null ) { 50 | Log.Error("Can not set a non-ExtThingDef to an IExtendedThing"); 51 | Log.Error("Can not set a non-ExtThingDef ("+( value )+") to an IExtendedThing"); 52 | } 53 | base.def = value; 54 | } 55 | } 56 | 57 | public override void PostMake() 58 | { 59 | Log.Message("PlantExtended.PostMake 1"); 60 | base.PostMake(); 61 | Log.Message("PlantExtended.PostMake 2"); 62 | ExtendedComponent.InitializeExtComps(this); 63 | Log.Message("PlantExtended.PostMake 3"); 64 | } 65 | 66 | public override void ExposeData() 67 | { 68 | Log.Message("PlantExtended.ExposeData 1"); 69 | base.ExposeData(); 70 | Log.Message("PlantExtended.ExposeData 2"); 71 | if (Scribe.mode == LoadSaveMode.LoadingVars) 72 | { 73 | Log.Message("PlantExtended.ExposeData 2.1"); 74 | ExtendedComponent.InitializeExtComps(this); 75 | Log.Message("PlantExtended.ExposeData 2.2"); 76 | } 77 | for (int i = 0; i < this.ExtComps.Count; i++) 78 | { 79 | this.ExtComps[i].PostExposeData(); 80 | } 81 | Log.Message("PlantExtended.ExposeData 3"); 82 | } 83 | 84 | public Building_PlantGrower thepot = null; 85 | 86 | public List planttraps = new List(); 87 | 88 | /* 89 | public void Initialize() 90 | { 91 | // Plant Traps 92 | for (int i = 0; i < this.def.comps.Count; i++) { 93 | ThingComp thingComp = (ThingComp)Activator.CreateInstance (this.def.comps [i].compClass); 94 | thingComp.parent = this; 95 | this.comps.Add (thingComp); 96 | thingComp.Initialize (this.def.comps [i]); 97 | } 98 | } 99 | */ 100 | 101 | // find the pot this is in 102 | protected bool initPot() { 103 | if ( base.Map == null ) return false; 104 | List list = base.Map.thingGrid.ThingsListAt(base.Position); 105 | for (int i = 0; i < list.Count; i++) 106 | { 107 | Thing thing = list[i]; 108 | if (thing is Building_PlantGrower ) { 109 | // Log.Warning("PlantTrap found pot"); 110 | this.thepot = (Building_PlantGrower)thing; 111 | } 112 | } 113 | // Log.Warning("PlantTrap pot : "+this.thepot); 114 | // Log.Warning("Creating Plant_Trap with properties:"); 115 | // Helpers.PrintObject(this.def.planttraps); 116 | //((DruidPlantProperties)this.def.plant).planttraps); 117 | 118 | return true; 119 | } 120 | 121 | 122 | 123 | public IEnumerable alertzone = null; 124 | public void initAlertZone() { 125 | 126 | Log.Message("PlantTrap.initAlertZonw 1 "); 127 | Log.Message("PlantTrap.initAlertZonw 1 : the pot "+this.thepot); 128 | float r = this.thepot.def.specialDisplayRadius; 129 | Log.Message("PlantTrap.initAlertZonw 2 "); 130 | this.alertzone = GenRadial.RadialCellsAround (this.Position, r, true); 131 | Log.Message("PlantTrap.initAlertZonw 3 "); 132 | } 133 | 134 | 135 | // protected int rearmAt = 0; 136 | 137 | 138 | // --------------------------------------------------------------------- 139 | // From Building_Trap below 140 | // --------------------------------------------------------------------- 141 | // private List touchingPawns = new List (); 142 | //protected bool Armed = true; 143 | 144 | 145 | protected void Spring(Pawn p, ExtInstComp_PlantTrap _ptp) 146 | { 147 | // Log.Message("PlantTrap.Spring! "); 148 | SoundDef.Named("PlantTrapSpring").PlayOneShot(new TargetInfo(base.Position, base.Map, false)); 149 | if (p.Faction != null) 150 | { 151 | p.Faction.TacticalMemory.TrapRevealed(base.Position, base.Map); 152 | } 153 | _ptp.SpringPlantTrap(p,this); 154 | 155 | } 156 | 157 | public override void Tick () 158 | { 159 | int curtick = Find.TickManager.TicksGame; 160 | 161 | Log.Message("PlantTrap.Tick 1 "+base.LabelMouseover+ " : " + curtick); 162 | //this.TickInterval 163 | if ( curtick % 2000 == 0 ) { this.TickLong(); } 164 | 165 | if ( this.thepot == null ) { 166 | if ( this.initPot() == false ) { 167 | Log.Message("PlantTrap.Tick .. map not set on first pass so return"); 168 | return; 169 | } 170 | } // Map not set on first pass so return 171 | 172 | // only mature trips 173 | Log.Message("PlantTrap.Tick 2 "); 174 | if ( base.Map != null && base.LifeStage == PlantLifeStage.Mature ) { 175 | 176 | // check for alert zone initialization 177 | Log.Message("PlantTrap.Tick 2.1"); 178 | if ( this.alertzone == null ) { 179 | Log.Message("PlantTrap.Tick 2.1.1"); 180 | this.initAlertZone(); 181 | Log.Message("PlantTrap.Tick 2.1.2"); 182 | } 183 | 184 | // find if there is an active trap; reactivate any needing it 185 | bool anyarmed = false; 186 | Log.Message("PlantTrap.Tick 2.2"); 187 | 188 | // handle all traps 189 | // foreach ( ExtInstComp_PlantTrap ptp in this.def.GetComps() ) 190 | foreach ( ExtInstComp ptp2 in this.ExtComps ) { 191 | ExtInstComp_PlantTrap ptp = ptp2 as ExtInstComp_PlantTrap; 192 | if ( ptp != null ) { 193 | 194 | // check for rearm if not armed 195 | // Log.Message("PlantTrap.Tick rearm check "+this.Armed+" " + Find.TickManager.TicksGame +" "+ this.rearmAt+ " " + (Find.TickManager.TicksGame > this.rearmAt )); 196 | Log.Message("PlantTrap.Tick 2.2.1"); 197 | if ( ptp.Armed == false && ( ptp.rearmAt != -1 ) && ( curtick > ptp.rearmAt ) ) { 198 | Log.Message("PlantTrap.Tick 2.2.1.1"); 199 | ptp.Armed = true; 200 | Log.Message("PlantTrap.Tick 2.2.1.2"); 201 | } 202 | 203 | // if armed, check alert zones 204 | Log.Message("PlantTrap.Tick 2.2.2"); 205 | if ( ptp.Armed == true ) { 206 | Log.Message("PlantTrap.Tick 2.2.2.1"); 207 | anyarmed = true; 208 | Log.Message("PlantTrap.Tick 2.2.2.2"); 209 | } 210 | 211 | Log.Message("PlantTrap.Tick 2.2.3"); 212 | } 213 | } 214 | 215 | // find all Pawns nearby 216 | Log.Message("PlantTrap.Tick 2.3"); 217 | List pawnthings = new List(); 218 | Log.Message("PlantTrap.Tick 2.4"); 219 | if ( anyarmed ) { 220 | // find all pawns 221 | Log.Message("PlantTrap.Tick 2.4.1"); 222 | foreach ( IntVec3 pp in this.alertzone) { // for each spot in alert zone 223 | Log.Message("PlantTrap.Tick 2.4.1.1"); 224 | List thingList = pp.GetThingList (base.Map); 225 | Log.Message("PlantTrap.Tick 2.4.1.2"); 226 | for (int i = 0; i < thingList.Count; i++) { 227 | Log.Message("PlantTrap.Tick 2.4.1.2.1"); 228 | Pawn pawn = thingList [i] as Pawn; 229 | Log.Message("PlantTrap.Tick 2.4.1.2.2"); 230 | if (pawn != null ) { 231 | Log.Message("PlantTrap.Tick 2.4.1.2.2.1"); 232 | pawnthings.Add(pawn); 233 | Log.Message("PlantTrap.Tick 2.4.1.2.2.2"); 234 | } 235 | Log.Message("PlantTrap.Tick 2.4.1.2.3"); 236 | } 237 | Log.Message("PlantTrap.Tick 2.4.1.3"); 238 | } 239 | Log.Message("PlantTrap.Tick 2.4.2"); 240 | } 241 | 242 | // is anyarmed, chekc 243 | Log.Message("PlantTrap.Tick 2.5"); 244 | if ( anyarmed ) { 245 | Log.Message("PlantTrap.Tick 2.5.1"); 246 | foreach ( ExtInstComp ptp2 in this.ExtComps ) { 247 | ExtInstComp_PlantTrap ptp = ptp2 as ExtInstComp_PlantTrap; 248 | if ( ptp != null ) { 249 | //foreach ( PlantTrapProperties ptp in ((UnificaMagica.DruidPlantDef)this.def).planttraps ) { 250 | Log.Message("PlantTrap.Tick 2.5.1.1"); 251 | if ( ptp.Armed ) { 252 | Log.Message("PlantTrap.Tick 2.5.1.1.1"); 253 | foreach ( Pawn pawn in pawnthings ) { 254 | Log.Message("PlantTrap.Tick 2.5.1.1.1.1"); 255 | if ( this.CheckSpring (pawn,ptp) ) { 256 | Log.Message("PlantTrap.Tick 2.5.1.1.1.1.1"); 257 | if ( ptp.Props.isAoE ) break; // apply only once if AoE 258 | //if ( ((ExtComp_PlantTrap)ptp.props).isAoE ) break; // apply only once if AoE 259 | } 260 | Log.Message("PlantTrap.Tick 2.5.1.1.1.2"); 261 | } 262 | Log.Message("PlantTrap.Tick 2.5.1.1.2"); 263 | } 264 | Log.Message("PlantTrap.Tick 2.5.1.2"); 265 | } 266 | Log.Message("PlantTrap.Tick 2.5.2"); 267 | } 268 | } 269 | 270 | //delete(pawnthings); 271 | Log.Message("PlantTrap.Tick 2.6"); 272 | 273 | } 274 | Log.Message("PlantTrap.Tick 3 - End"); 275 | } 276 | 277 | 278 | 279 | protected virtual bool CheckSpring (Pawn p, ExtInstComp_PlantTrap _ptp) 280 | { 281 | bool retval = false; 282 | if ( ! _ptp.Armed ) return false; 283 | 284 | float sc = this.SpringChance(p); 285 | float rr = Rand.Value; 286 | // Log.Message("PlantTrap.CheckSpring : rand("+rr+") chance("+sc+")"); 287 | if (Rand.Value < sc ) { //this.SpringChance (p)) 288 | // Log.Message("PlantTrap.CheckSpring : sprung"); 289 | retval = true; 290 | this.Spring (p,_ptp); 291 | if (p.Faction == Faction.OfPlayer || p.HostFaction == Faction.OfPlayer) { 292 | Letter let = new Letter ("LetterFriendlyTrapSprungLabel".Translate (new object[] { p.NameStringShort }), "LetterFriendlyTrapSprung".Translate (new object[] { p.NameStringShort }), LetterType.BadNonUrgent, new TargetInfo (base.Position, base.Map, false)); 293 | Find.LetterStack.ReceiveLetter (let, null); 294 | } 295 | } 296 | return retval; 297 | } 298 | 299 | protected virtual float SpringChance (Pawn p) 300 | { 301 | float num; 302 | if (this.KnowsOfTrap (p)) { 303 | num = 0.004f; 304 | // Log.Message("PlantTrap.SpringChance 1 : "+num); 305 | } 306 | else { 307 | num = this.GetStatValue (StatDefOf.TrapSpringChance, true); 308 | // Log.Message("PlantTrap.SpringChance 1 : "+num); 309 | } 310 | num *= GenMath.LerpDouble (0.4f, 0.8f, 0f, 1f, p.BodySize); 311 | if (p.RaceProps.Animal) { 312 | num *= 0.1f; 313 | } 314 | // Log.Message("PlantTrap.SpringChance chance: "+num+" base is "+StatDefOf.TrapSpringChance); 315 | return Mathf.Clamp01 (num); 316 | } 317 | 318 | public bool KnowsOfTrap(Pawn p) 319 | { 320 | if ( this.thepot == null ) { 321 | // Log.Error("can not find pot of plant "+this+" at "+this.Position); 322 | return false; 323 | } 324 | Faction f = this.thepot.Faction; 325 | // Log.Message("PlantTrap.KnowsOfTrap 0 : is faction null "+(f == null)); 326 | 327 | bool retval = (p.Faction != null && !p.Faction.HostileTo(f)) || (p.Faction == null && p.RaceProps.Animal && !p.InAggroMentalState) || (p.guest != null && p.guest.released); 328 | // Log.Message("PlantTrap.KnowsOfTrap 1 "+retval); 329 | // Log.Message("PlantTrap.KnowsOfTrap 2 "+(p.Faction!= null)); 330 | // Log.Message("PlantTrap.KnowsOfTrap 3 "+f); 331 | // Log.Message("PlantTrap.KnowsOfTrap 4 "+p.Faction.HostileTo(f)); 332 | //return (p.Faction != null && !p.Faction.HostileTo(base.Faction)) || (p.Faction == null && p.RaceProps.Animal && !p.InAggroMentalState) || (p.guest != null && p.guest.released); 333 | return (p.Faction != null && !p.Faction.HostileTo(f)) || (p.Faction == null && p.RaceProps.Animal && !p.InAggroMentalState) || (p.guest != null && p.guest.released); 334 | } 335 | 336 | 337 | public override string GetInspectString() 338 | { 339 | string retval = base.GetInspectString(); 340 | StringBuilder stringBuilder = new StringBuilder(); 341 | 342 | Log.Message("PlantExtended.GetInspectString()"); 343 | 344 | stringBuilder.Append(retval); 345 | 346 | //if ( this.def.ExtComps.Count != 0 ) 347 | if (this.LifeStage == PlantLifeStage.Growing) 348 | { 349 | stringBuilder.AppendLine("Druid Plant is not mature"); 350 | } else if (this.LifeStage == PlantLifeStage.Mature) { 351 | bool fl = false; 352 | 353 | foreach ( ExtInstComp ptp2 in this.ExtComps ) { 354 | ExtInstComp_PlantTrap ptp = ptp2 as ExtInstComp_PlantTrap; 355 | if ( ptp != null ) { 356 | if ( ptp.Armed ) { stringBuilder.AppendLine( ptp.Props.ArmedLabel ); fl = true; } 357 | else { 358 | stringBuilder.AppendLine( ptp.Props.ArmedLabel + " in " + ptp.rearmAt + " ticks"); 359 | } 360 | } 361 | } 362 | if ( fl == false ) { stringBuilder.AppendLine("No armed traps"); 363 | } 364 | } 365 | 366 | return stringBuilder.ToString(); 367 | } 368 | } 369 | } 370 | -------------------------------------------------------------------------------- /ExtendedThingCode/readme.md: -------------------------------------------------------------------------------- 1 | # Extended Code 2 | 3 | This is the code for a tutorial. 4 | 5 | NOTE: This code is a mess and directly taken from my hacking on my [UnificaMagica](https://ludeon.com/forums/index.php?topic=31826.msg325689#msg325689) mod. 6 | 7 | [Link to tutorial explaining this code.](https://github.com/roxxploxx/RimWorldModGuide/wiki/SHORTTUTORIAL%3A-ExtendedThings) 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RimWorldModGuide 2 | My attempt at a RimWorld guide to assist models. 3 | 4 | # ([Enter the Guide Here](https://github.com/roxxploxx/RimWorldModGuide/wiki)) 5 | 6 | Finding this helpful? [Support me on Patreon](https://www.patreon.com/roxxploxx). Thanks! 7 | -------------------------------------------------------------------------------- /RimWorldThings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/RimWorldThings.png -------------------------------------------------------------------------------- /src/CompSlotLoadable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/CompSlotLoadable.png -------------------------------------------------------------------------------- /src/CompToggleDef1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/CompToggleDef1.png -------------------------------------------------------------------------------- /src/CompToggleDef2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/CompToggleDef2.png -------------------------------------------------------------------------------- /src/Gizmos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/Gizmos.png -------------------------------------------------------------------------------- /src/Jobs_from_white_alter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/Jobs_from_white_alter.png -------------------------------------------------------------------------------- /src/MainTabs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/MainTabs.png -------------------------------------------------------------------------------- /src/ModdingOverview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/ModdingOverview.pdf -------------------------------------------------------------------------------- /src/PawnSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxxploxx/RimWorldModGuide/63adb0d35218f6585a96ffeb4dd80756aaf95f9c/src/PawnSelected.png --------------------------------------------------------------------------------