Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Added existing building check to CompBuildPeriodically
Browse files Browse the repository at this point in the history
  • Loading branch information
juanosarg committed May 3, 2022
1 parent 91ea742 commit b61729b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Binary file modified 1.3/Assemblies/VFECore.dll
Binary file not shown.
30 changes: 23 additions & 7 deletions Source/VFECore/AnimalBehaviours/Comps/CompBuildPeriodically.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,32 @@ public void CheckDuplicates(Pawn pawn)

public void TryCreateBuilding(Pawn pawn)
{
ThingDef newThing = ThingDef.Named(this.Props.defOfBuilding);
Thing newbuilding = GenSpawn.Spawn(newThing, pawn.Position, pawn.Map, WipeMode.Vanish);
bool buildingFound = false;
List<Thing> list = parent.Map.thingGrid.ThingsListAt(pawn.Position);
for (int i = 0; i < list.Count; i++)
{
if (list[i].def.IsEdifice())
{
buildingFound = true;
}
}

this.thingBuilt = newbuilding;
if (!Props.checkForExistingEdifices || (Props.checkForExistingEdifices && !buildingFound)) {

ThingDef newThing = ThingDef.Named(this.Props.defOfBuilding);
Thing newbuilding = GenSpawn.Spawn(newThing, pawn.Position, pawn.Map, WipeMode.Vanish);

this.thingBuilt = newbuilding;

if (this.effecter == null)
{
this.effecter = EffecterDefOf.Mine.Spawn();
}
this.effecter.Trigger(pawn, newbuilding);

if (this.effecter == null)
{
this.effecter = EffecterDefOf.Mine.Spawn();
}
this.effecter.Trigger(pawn, newbuilding);



}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public CompProperties_BuildPeriodically()
public int maxBuildingsPerMap = 10;
public List<string> acceptedTerrains = null;
public bool onlyOneExistingPerPawn = false;
public bool checkForExistingEdifices = false;
}
}

0 comments on commit b61729b

Please sign in to comment.