本文整理汇总了C#中IntVec3.GetTerrain方法的典型用法代码示例。如果您正苦于以下问题:C# IntVec3.GetTerrain方法的具体用法?C# IntVec3.GetTerrain怎么用?C# IntVec3.GetTerrain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntVec3
的用法示例。
在下文中一共展示了IntVec3.GetTerrain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllowsPlacing
/// <summary>
/// Restrict placement over non stony floors.
/// </summary>
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
{
TerrainDef terrain = loc.GetTerrain();
if ((terrain == TerrainDef.Named("Soil"))
|| (terrain == TerrainDef.Named("SoilRich"))
|| (terrain == TerrainDef.Named("Gravel"))
|| (terrain == TerrainDef.Named("MossyTerrain"))
|| (terrain == TerrainDef.Named("MarshyTerrain")))
{
return true;
}
return new AcceptanceReport("Dirt floor must be placed on soft soil.");
}
示例2: AllowsPlacing
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
{
ThingDef def = checkingDef as ThingDef;
var Restrictions = def.GetCompProperties( typeof( RestrictedPlacement_Comp ) ) as RestrictedPlacement_Properties;
if( Restrictions == null ){
Log.Error( "Could not get restrictions!" );
return false;
}
TerrainDef terrainDef = loc.GetTerrain();
for( int i = 0; i < Restrictions.RestrictedTerrain.Count; i++ )
if( Restrictions.RestrictedTerrain[ i ] == terrainDef )
return true;
return "MessagePlacementNotOnTerrain".Translate() + terrainDef.label;
}
示例3: AllowsPlacing
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
{
var Restrictions = checkingDef.RestrictedPlacement_Properties();
#if DEBUG
if( Restrictions == null )
{
Log.Error( "Community Core Library :: Restricted PlaceWorker :: NotOnTerrain - Unable to get properties!" );
return AcceptanceReport.WasRejected;
}
#endif
TerrainDef terrainDef = loc.GetTerrain();
for( int i = 0; i < Restrictions.RestrictedTerrain.Count; i++ )
{
if( Restrictions.RestrictedTerrain[ i ] == terrainDef )
{
return "MessagePlacementNotOn".Translate(terrainDef.label);
}
}
return AcceptanceReport.WasAccepted;
}
示例4: JobOnCell
public override Job JobOnCell(Pawn pawn, IntVec3 cell)
{
// first run check to improve performance
if (!pawn.CanReserve(cell) || cell.IsForbidden(pawn)) return null;
// set plant to grow
DetermineWantedPlantDef(cell);
// cut improper plants in current cell
var plant = Find.ThingGrid.ThingAt<Plant>(cell);
if (plant != null)
{
if (plant.def != wantedPlantDef && Find.DesignationManager.DesignationOn(plant) == null)
{
DesignatePlantToCut(plant);
}
return null;
}
// cut improper adjucent sow blockers (trees)
var adjacentSowBlocker = GenPlant.AdjacentSowBlocker(wantedPlantDef, cell) as Plant;
if (adjacentSowBlocker != null)
{
if (Find.DesignationManager.DesignationOn(adjacentSowBlocker) == null)
{
var zoneGrowing = Find.ZoneManager.ZoneAt(adjacentSowBlocker.Position) as Zone_Growing;
if (zoneGrowing == null || zoneGrowing.GetPlantDefToGrow() != adjacentSowBlocker.def)
{
DesignatePlantToCut(adjacentSowBlocker);
}
}
return null;
}
// haul aside objects that block growing
var haulGarbageAsideJob = HaulGarbageAsideJob(cell, pawn);
if (haulGarbageAsideJob != null)
{
return haulGarbageAsideJob;
}
// cultivate or fertilize soil if needed
var growingZone = Find.ZoneManager.ZoneAt(cell) as RA_Zone_Growing;
if (growingZone != null)
{
if (growingZone.needsFertilization && cell.GetTerrain().defName.Contains("Cultivated"))
{
return pawn.CanReach(cell, PathEndMode.ClosestTouch, pawn.NormalMaxDanger())
? new Job(DefDatabase<JobDef>.GetNamedSilentFail("Fertilize"), cell)
: null;
}
if (growingZone.needsCultivation && !cell.GetTerrain().defName.Contains("Cultivated") && !cell.GetTerrain().defName.Contains("Fertilized"))
{
if (!Find.DesignationManager.AllDesignationsAt(cell).Any())
{
Find.DesignationManager.AddDesignation(new Designation(cell,
DefDatabase<DesignationDef>.GetNamedSilentFail("CultivateLand")));
}
return null;
}
}
// last check for allowed planting
if (wantedPlantDef.CanEverPlantAt(cell))
{
// plant
return new Job(JobDefOf.Sow, cell)
{
plantDefToSow = wantedPlantDef
};
}
// default exit
return null;
}
示例5: _CanBuildOnTerrain
internal static bool _CanBuildOnTerrain( BuildableDef entDef, IntVec3 c, Rot4 rot, Thing thingToIgnore = null )
{
CompProperties_RestrictedPlacement Restrictions = null;
if( entDef is TerrainWithComps )
{
var terrainWithComps = entDef as TerrainWithComps;
if(
( !terrainWithComps.placeWorkers.NullOrEmpty() ) &&
( terrainWithComps.placeWorkers.Contains( typeof( PlaceWorker_OnlyOnTerrain ) ) )
)
{
Restrictions = terrainWithComps.GetCompProperties( typeof( CompRestrictedPlacement ) ) as CompProperties_RestrictedPlacement;
}
}
else if( entDef is ThingDef )
{
var thingDef = entDef as ThingDef;
if(
( !thingDef.placeWorkers.NullOrEmpty() ) &&
( thingDef.placeWorkers.Contains( typeof( PlaceWorker_OnlyOnTerrain ) ) )
)
{
Restrictions = thingDef.GetCompProperties<CompProperties_RestrictedPlacement>();
}
}
if( Restrictions != null )
{
var cellRect = GenAdj.OccupiedRect( c, rot, entDef.Size );
cellRect.ClipInsideMap();
var iterator = cellRect.GetIterator();
while( !iterator.Done() )
{
if( !Restrictions.RestrictedTerrain.Contains( Find.TerrainGrid.TerrainAt( iterator.Current ) ) )
{
return false;
}
var thingList = iterator.Current.GetThingList();
for( int index = 0; index < thingList.Count; ++index )
{
if( thingList[ index ] != thingToIgnore )
{
var terrainDef = thingList[ index ].def.entityDefToBuild as TerrainDef;
if(
( terrainDef != null )&&
( !Restrictions.RestrictedTerrain.Contains( terrainDef ) )
)
{
return false;
}
}
}
iterator.MoveNext();
}
}
else
{
// Use the vanilla method to check
if(
( entDef is TerrainDef ) &&
( !c.GetTerrain().changeable )
)
{
return false;
}
var cellRect = GenAdj.OccupiedRect( c, rot, entDef.Size );
cellRect.ClipInsideMap();
var iterator = cellRect.GetIterator();
while( !iterator.Done() )
{
if( !Find.TerrainGrid.TerrainAt( iterator.Current ).affordances.Contains( entDef.terrainAffordanceNeeded ) )
{
return false;
}
var thingList = iterator.Current.GetThingList();
for( int index = 0; index < thingList.Count; ++index )
{
if( thingList[ index ] != thingToIgnore )
{
var terrainDef = thingList[ index ].def.entityDefToBuild as TerrainDef;
if(
( terrainDef != null )&&
( !terrainDef.affordances.Contains( entDef.terrainAffordanceNeeded ) )
)
{
return false;
}
}
}
iterator.MoveNext();
}
}
// Allow placement
return true;
}