コード例 #1
0
        public override void CompTick()
        {
            base.CompTick();

            //Tools.Warn(" >>>TICK begin<<< ", prcDebug);
            Tools.Warn(" >>>TICK begin tp:" + Registry.Count + "<<< ");
            if (HasSpot)
            {
                if (Tools.TwoTicksOneTrue())
                {
                    //foreach(Building cur in Registry)
                    for (int i = Registry.Count - 1; i >= 0; i--)
                    {
                        Building cur = Registry[i];
                        if ((!ToolsBuilding.CheckBuilding(cur)) || (!ToolsBuilding.CheckPower(cur)) || !InRangeSpot(cur))
                        {
                            Comp_LTF_TpSpot comp_LTF_TpSpot = cur?.TryGetComp <Comp_LTF_TpSpot>();
                            if (comp_LTF_TpSpot != null)
                            {
                                comp_LTF_TpSpot.ResetFacility();
                            }
                            RemoveSpot(cur);
                        }
                    }
                }
                IndexCorrecter();
            }


            // Tools.Warn(" >>>TICK end<<< ", prcDebug);
            Tools.Warn(" >>>TICK end " + Registry.Count + "<<< ");
        }
コード例 #2
0
        //Facility required

        /*
         * public static Building GetPoweredFacility(Building building, Building facility, CompAffectedByFacilities buildingFacilityComp= null, CompPowerTrader facilityPowerComp = null, bool debug = false)
         * {
         *  Building Answer = null;
         *
         *  //Building - needed to find other things
         *  if (!ToolsBuilding.CheckBuilding(building))
         *  {
         *      Tools.Warn("bad building, wont check facility", debug);
         *      return null;
         *  }
         *
         *  if(buildingFacilityComp == null)
         *      buildingFacilityComp = ToolsBuilding.GetAffectedComp(building, debug);
         *
         *  if (facility == null)
         *      ToolsBuilding.GetFacility(buildingFacilityComp, debug);
         *
         *  if (!ToolsBuilding.CheckBuilding((facility))
         *  {
         *      Tools.Warn(" give facility is not ok, getting one", debug);
         *
         *      Building newFacility = thing as Building;
         *      return null;
         *  }
         *
         *
         *
         *  if (facilityPowerComp != null)
         *  {
         *
         *  }
         *  else
         *  {
         *      if (!CheckPower(facility))
         *      {
         *          if (debug)
         *              Log.Warning("facility has no power");
         *      }
         *  }
         *
         *
         *  Answer = facility;
         *  return Answer;
         * }
         */
        public static bool TickCheckFacilityPower(Building facility, CompPowerTrader powerComp = null, bool debug = false)
        {
            bool Answer = true;

            //ToolsBuilding.CheckBuildingBelongsFacility(buildingFacilityComp, facility, debug);
            Tools.Warn("tick check facility", debug);

            //Valid
            Answer &= ToolsBuilding.CheckBuilding(facility);

            //power
            Answer &= ((powerComp == null) ? (ToolsBuilding.CheckPower(facility)):(ToolsBuilding.CheckPower(powerComp)));

            Tools.WarnRare("no powered facility", 300, debug);

            return(Answer);
        }