コード例 #1
0
 public IEnumerable <Building> GetBuildingsOf(CarnBuildingType type)
 {
     foreach (var building in carnivalBuildings)
     {
         if (building.Is(type))
         {
             yield return(building);
         }
     }
 }
コード例 #2
0
ファイル: CarnUtils.cs プロジェクト: Pyr3z/Carnivale
        public static bool Is(this ThingDef def, CarnBuildingType type)
        {
            CompProperties_CarnBuilding props = def.GetCompProperties <CompProperties_CarnBuilding>();

            if (props == null)
            {
                return(false);
            }

            return(props.type.Is(type));
        }
コード例 #3
0
        public LocalTargetInfo GetRandomTentDoor(bool suppressWarnings = false, CarnBuildingType secondaryType = CarnBuildingType.Bedroom)
        {
            var tent = GetRandomBuildingOf(CarnBuildingType.Tent | secondaryType, suppressWarnings) as Building_Tent;

            if (tent != null)
            {
                return(tent.GetTentFlap());
            }

            return(IntVec3.Invalid);
        }
コード例 #4
0
        public Building_Carn GetRandomBuildingOf(CarnBuildingType type, bool suppressWarnings = false)
        {
            if (!Active)
            {
                Log.Error("Cannot get carnival building: carnival is not in town.");
                return(null);
            }

            Building building;

            if (carnivalBuildings.Where(b => b.Is(type)).TryRandomElement(out building))
            {
                return(building as Building_Carn);
            }

            if (Prefs.DevMode && !suppressWarnings)
            {
                Log.Warning("[Carnivale] Tried to find any building of type " + type + " in CarnivalInfo, but none exists.");
            }
            return(null);
        }
コード例 #5
0
        public Building GetFirstBuildingOf(CarnBuildingType type)
        {
            if (!Active)
            {
                Log.Error("Cannot get carnival building: carnival is not in town.");
                return(null);
            }

            foreach (var building in this.carnivalBuildings)
            {
                if (building.Is(type))
                {
                    return(building);
                }
            }

            if (Prefs.DevMode)
            {
                Log.Warning("[Carnivale] Tried to find any building of type " + type + " in CarnivalInfo, but none exists.");
            }
            return(null);
        }
コード例 #6
0
ファイル: CarnUtils.cs プロジェクト: Pyr3z/Carnivale
 public static bool Is(this CarnBuildingType type, CarnBuildingType other)
 {
     return((type & other) == other);
 }
コード例 #7
0
ファイル: CarnUtils.cs プロジェクト: Pyr3z/Carnivale
 public static bool Is(this Building building, CarnBuildingType type)
 {
     return(building.def.Is(type));
 }