-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1222 from CombatExtended-Continued/VFETrenches
Add support for VFE Trenches
- Loading branch information
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using CombatExtended.CombatExtended.LoggerUtils; | ||
using UnityEngine; | ||
using Verse; | ||
using VFESecurity; | ||
|
||
namespace CombatExtended.Compatibility | ||
{ | ||
[StaticConstructorOnStartup] | ||
public class CETrenches | ||
{ | ||
private static bool vfeInstalled; | ||
private const string VFES_ModName = "Vanilla Furniture Expanded - Security"; | ||
static CETrenches() | ||
{ | ||
vfeInstalled = ModLister.HasActiveModWithName(VFES_ModName); | ||
} | ||
public static float GetHeightAdjust(IntVec3 cell, Map map) | ||
{ | ||
if (cell == null || map == null) | ||
{ | ||
return 0; | ||
} | ||
|
||
if (vfeInstalled) | ||
{ | ||
List<Thing> thingList = GridsUtility.GetThingList(cell, map); | ||
foreach (Thing thing in thingList) | ||
{ | ||
CompProperties_TerrainSetter compProperties = thing.def.GetCompProperties<CompProperties_TerrainSetter>(); | ||
if (compProperties == null) | ||
{ | ||
return 0f; | ||
} | ||
|
||
TerrainDef terrainDef = compProperties.terrainDef; | ||
TerrainDefExtension terrainDefExtension = TerrainDefExtension.Get(terrainDef); | ||
return -terrainDefExtension.coverEffectiveness * CollisionVertical.WallCollisionHeight; | ||
|
||
} | ||
} | ||
return 0f; | ||
} | ||
} | ||
} |