示例#1
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     extinguishComp          = base.GetComp <CompExtinguishable>();
     lightableRefuelableComp = base.GetComp <CompLightableRefuelable>();
     this.breakdownableComp  = base.GetComp <CompBreakdownable>();
 }
        public static void DoBreakdownMaintenance(this CompBreakdownable _this)
        {
            _this.DoBreakdown();

            // reset durability
            _this.Durability(1f);
        }
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     this.powerComp         = this.parent.GetComp <CompPowerTrader>();
     this.refuelableComp    = this.parent.GetComp <CompRefuelable>();
     this.breakdownableComp = this.parent.GetComp <CompBreakdownable>();
 }
示例#4
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     this.stoneComp         = this.parent.GetComp <CompExtinguishable>();
     this.refuelableComp    = this.parent.GetComp <CompRefuelable>();
     this.breakdownableComp = this.parent.GetComp <CompBreakdownable>();
 }
示例#5
0
        private void DoDestroyDestroyable()
        {
            foreach (var itemPos in destroyableItems)
            {
                List <Thing> items = itemPos.GetThingList(Site.Map);

                foreach (var item in items)
                {
                    CompRefuelable compRefuelable = item.TryGetComp <CompRefuelable>();
                    if (compRefuelable != null)
                    {
                        float refuelInt = Mathf.Clamp(compRefuelable.Fuel - compRefuelable.Props.fuelCapacity, 0, compRefuelable.Props.fuelCapacity);

                        compRefuelable.Refuel(refuelInt);
                    }

                    CompBreakdownable compBreakdownable = item.TryGetComp <CompBreakdownable>();
                    if (compBreakdownable != null)
                    {
                        compBreakdownable.DoBreakdown();
                    }

                    if (item.def.CanHaveFaction)
                    {
                        item.SetFaction(Faction.OfPlayer);
                    }
                }
            }
        }
示例#6
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     powerComp         = GetComp <CompPowerTrader>();
     refuelableComp    = GetComp <CompRefuelable>();
     breakdownableComp = GetComp <CompBreakdownable>();
 }
        public static bool InUse(this CompBreakdownable _this)
        {
            // TODO: Add back in if/when CCL gets out.
            // CCL LowIdleDraw; if not null and in lower power mode, assume not in use.
            // var compLowIdleDraw = parent.GetComp<CompPowerLowIdleDraw>();
            // if ( compLowIdleDraw != null && compLowIdleDraw.LowPowerMode )
            //     return false;

            // CompPowered; if not null and powered off (for any reason), assume not in use.
            var compPowerTrader = _this.parent.GetComp <CompPowerTrader>();

            if (compPowerTrader != null && !compPowerTrader.PowerOn)
            {
                return(false);
            }

            // TODO: figure out why this section causes a hard CTD
            //// CompFueled; if not null and not consumed fuel between ticks, assume not in use
            //var compFueled = parent.GetComp<CompRefuelable>();
            //if ( compFueled != null && compFueled.FuelPercent >= lastFuelAmount )
            //    return false;
            //if ( compFueled != null )
            //    lastFuelAmount = compFueled.FuelPercent;

            // nothing stuck, assume in use.
            return(true);
        }
 internal static void Durability(this CompBreakdownable _this, float value)
 {
     if (_this?.parent?.Map == null)
     {
         return;
     }
     MapComponent_Durability.ForMap(_this.parent.Map).SetDurability(_this, value);
 }
 internal static float Durability(this CompBreakdownable _this)
 {
     if (_this?.parent?.Map == null)
     {
         return(1f);
     }
     return(MapComponent_Durability.ForMap(_this.parent.Map).GetDurability(_this));
 }
示例#10
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     powerTrader   = GetComp <CompPowerTrader>();
     breakdownable = GetComp <CompBreakdownable>();
     Current.Game.GetComponent <PsiTechManager>().RegisterTrainer(this);
     Trainer = GetComp <CompPsiTechTrainer>();
 }
示例#11
0
 public override void SpawnSetup(Map map, bool bla)
 {
     base.SpawnSetup(map, bla);
     heatPusherComp    = base.GetComp <CompHeatPusher>();
     flickableComp     = base.GetComp <CompFlickable>();
     glowerComp        = base.GetComp <CompGlower>();
     refuelableComp    = base.GetComp <CompRefuelable>();
     breakdownableComp = base.GetComp <CompBreakdownable>();
 }
        internal static float MaintenanceComplexityFactor(this CompBreakdownable _this)
        {
            if (_this?.parent == null)
            {
                return(1f);
            }

            return(Mathf.Sqrt(_this.parent.def.ComponentCount() / 2f));
        }
示例#13
0
 public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
 {
     base.DeSpawn(mode);
     heatPusherComp    = null;
     flickableComp     = null;
     glowerComp        = null;
     refuelableComp    = null;
     breakdownableComp = null;
 }
 public override void SpawnSetup(Map map, bool blabla)
 {
     base.SpawnSetup(map, blabla);
     powerComp         = GetComp <CompPowerTrader>();
     refuelableComp    = GetComp <CompRefuelable>();
     breakdownableComp = GetComp <CompBreakdownable>();
     powerComp         = GetComp <CompPowerTrader>();
     consoleDef        = DefDatabase <ThingDef> .GetNamed("ET_Console");
 }
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     this.refuelableComp    = this.parent.GetComp <CompRefuelable>();
     this.breakdownableComp = this.parent.GetComp <CompBreakdownable>();
     if (base.Props.basePowerConsumption < 0f && !this.parent.IsBrokenDown() && FlickUtility.WantsToBeOn(this.parent))
     {
         base.PowerOn = true;
     }
 }
 public static float GetDurability( CompBreakdownable comp )
 {
     float durability;
     if ( !_durabilities.TryGetValue( comp, out durability ) )
     {
         durability = 1f;
         _durabilities.Add( comp, durability );
     }
     return durability;
 }
示例#17
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     powerComp         = GetComp <CompPowerTrader>();
     refuelableComp    = GetComp <CompRefuelable>();
     breakdownableComp = GetComp <CompBreakdownable>();
     foreach (Bill item in billStack)
     {
         item.ValidateSettings();
     }
 }
示例#18
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(true);
     this.refuelableComp = this.parent.GetComp <CompRefuelable>();
     this.refuelableDualConsumptionComp = this.parent.GetComp <CompRefuelableDualConsumption>();
     this.breakdownableComp             = this.parent.GetComp <CompBreakdownable>();
     if (base.Props.basePowerConsumption < 0f && !this.parent.IsBrokenDown())
     {
         base.PowerOn = true;
     }
 }
示例#19
0
 /// <summary>
 /// This is called seperately when the Mod-Thread is done.
 /// It is needed to be seperately from SpawnSetup, so that the graphics can be found
 /// </summary>
 private void SpawnSetup_Part2()
 {
     this.powerComp         = base.GetComp <CompPowerTrader_EmergencyPowerCore>();
     this.refuelableComp    = base.GetComp <CompRefuelable>();
     this.breakdownableComp = base.GetComp <CompBreakdownable>();
     this.flickableComp     = base.GetComp <CompFlickable>();
     if (!this.IsBrokenDown())
     {
         this.powerComp.PowerOn = true;
     }
 }
示例#20
0
 private static void BreakDown()
 {
     foreach (Thing item in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
     {
         CompBreakdownable compBreakdownable = item.TryGetComp <CompBreakdownable>();
         if (compBreakdownable != null && !compBreakdownable.BrokenDown)
         {
             compBreakdownable.DoBreakdown();
         }
     }
 }
示例#21
0
        public float GetDurability(CompBreakdownable comp)
        {
            float durability;

            if (!_durabilities.TryGetValue(comp, out durability))
            {
                durability = 1f;
                _durabilities.Add(comp, durability);
            }
            return(durability);
        }
        public static bool Prefix(CompBreakdownable __instance, ref string __result)
        {
            // vanilla can handle broken down
            if (__instance.BrokenDown)
            {
                return(true);
            }

            // we'll handle showing the maintenance
            __result = "FluffyBreakdowns.Maintenance".Translate(__instance.Durability().ToStringPercent());
            return(false);
        }
示例#23
0
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            base.PostSpawnSetup(respawningAfterLoad);
            breakdownableComp = parent.GetComp <CompBreakdownable>();
            if (base.Props.basePowerConsumption < 0f && !parent.IsBrokenDown() && FlickUtility.WantsToBeOn(parent))
            {
                base.PowerOn = true;
            }
            compGasPowerPlantSettings = parent.GetComp <CompGasPowerPlantSettings>();

            gasConsumePerTick = compGasPowerPlantSettings.Props.GasConsumption / 60000;
        }
示例#24
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     itemFilterComp    = GetComp <CompInnerContainerItemFilter>();
     refuelableComp    = GetComp <CompRefuelable>();
     breakdownableComp = GetComp <CompBreakdownable>();
     powerComp         = GetComp <CompPowerTrader>();
     if (Faction != null && Faction.IsPlayer)
     {
         contentsKnown = true;
     }
 }
示例#25
0
 private void RestoreDefencesAndPower()
 {
     foreach (var thing in map.spawnedThings)
     {
         if (thing.TryGetComp <CompPowerPlant>() != null || thing.TryGetComp <CompPowerBattery>() != null || (thing.def.building != null && thing.def.building.IsTurret))
         {
             CompBreakdownable bdcomp = thing.TryGetComp <CompBreakdownable>();
             if (bdcomp != null)
             {
                 bdcomp.Notify_Repaired();
             }
         }
     }
 }
        public override void DoEffect(TargetInfo target, Thing caster)
        {
            CompBreakdownable breakdownable = target.Thing.TryGetComp <CompBreakdownable>();

            if (breakdownable != null)
            {
                breakdownable.DoBreakdown();
            }
            CompExplosive explosive = target.Thing.TryGetComp <CompExplosive>();

            if (explosive != null)
            {
                explosive.StartWick();
            }
        }
示例#27
0
        public override void PostSpawnSetup()
        {
            base.PostSpawnSetup();
            IncidentDef incidentDef = DefDatabase <IncidentDef> .GetNamed("ShortCircuit");

            if (incidentDef.workerClass != typeof(IncidentWorker_RTShortCircuit))
            {
                incidentDef.workerClass = typeof(IncidentWorker_RTShortCircuit);
                DefDatabase <IncidentDef> .ResolveAllReferences();

                Log.Message("RT_Fuse: replaced IncidentWorker for ShortCircuit.");
            }
            compBreakdownable = parent.TryGetComp <CompBreakdownable>();
            compFlickable     = parent.TryGetComp <CompFlickable>();
        }
示例#28
0
        public override void PostSpawnSetup(bool respawningAfterLoad)
        {
            base.PostSpawnSetup(respawningAfterLoad);

            flickable     = parent.GetComp <CompFlickable>();
            breakdownable = parent.GetComp <CompBreakdownable>();
            schedule      = parent.GetComp <CompSchedule>();

            // set flickable to false, to avoid immediately flooding the area with
            // deadly toxins.

            if (!respawningAfterLoad && flickable != null)
            {
                flickable.SwitchIsOn = false;
            }

            // get ventPos
            ventPos = GenGas.VentingPosition(parent);
        }
示例#29
0
        public float PotentialProduction(CompPowerTrader comp)
        {
#if DEBUG
            CompPowerPlant    _plant         = comp as CompPowerPlant;
            CompRefuelable    _refuelable    = _plant?.parent.RefuelableComp();
            CompBreakdownable _breakdownable = _plant?.parent.BreakdownableComp();

            string msg = comp.parent.def.defName;
            msg += $"\n\tpowerplant: {_plant != null}";
            if (_plant != null)
            {
                msg += $"\n\trefuelable: {_refuelable != null}";
                msg += $"\n\tfueled: {_refuelable?.HasFuel}";
                msg += $"\n\tbreakdownable: {_breakdownable != null}";
                msg += $"\n\tbroken: {_breakdownable?.BrokenDown}";
                msg += $"\n\tdesired: {_plant.DesiredOutput()}";
                msg += $"\n\tcurrent: {_plant.PowerOutput}";
            }

            Log.Message(msg);
#endif

            if (!(comp is CompPowerPlant plant))
            {
                return(0);
            }

            CompRefuelable refuelable = plant.parent.RefuelableComp();
            if (refuelable != null && !refuelable.HasFuel)
            {
                return(0);
            }

            CompBreakdownable breakdownable = plant.parent.BreakdownableComp();
            if (breakdownable != null && breakdownable.BrokenDown)
            {
                return(0);
            }

            // TODO: check how this interacts with variable power output buildings, e.g. solar, wind.
            return(Mathf.Max(plant.DesiredOutput(), plant.PowerOutput, 0));
        }
示例#30
0
        public override void MapComponentTick()
        {
            base.MapComponentTick();

            int tick     = Find.TickManager.TicksGame;
            var orphaned = new List <CompBreakdownable>();

            foreach (KeyValuePair <CompBreakdownable, float> _dur in _durabilities)
            {
                float             durability = _dur.Value;
                CompBreakdownable comp       = _dur.Key;
                if (comp?.parent?.Spawned ?? false)
                {
                    if (durability < .5 && (tick + comp.GetHashCode()) % _moteIntervalRequiresRepair == 0)
                    {
                        MoteMaker.ThrowSmoke(comp.parent.DrawPos, map, (1f - durability) * 1 / 2f);
                    }

                    if (durability < .25 && (tick + comp.GetHashCode()) % _moteIntervalRequiresCriticalRepair == 0)
                    {
                        MoteMaker.ThrowMicroSparks(comp.parent.DrawPos, map);
                    }
                }

                // can't simply use !Spawned, since that would allow resetting durability by moving furniture.
                if (comp?.parent?.DestroyedOrNull() ?? true)
                {
                    // mark for removal
                    orphaned.Add(comp);
                }
            }

            // remove
            foreach (CompBreakdownable comp in orphaned)
            {
                _durabilities.Remove(comp);
            }
        }
示例#31
0
        public void makeExplosion()
        {
            //Passe le dispositif en broken
            if (this.parent != null)
            {
                CompBreakdownable bd = this.parent.TryGetComp <CompBreakdownable>();
                if (bd != null)
                {
                    bd.DoBreakdown();
                }

                Building b = (Building)parent;
                b.HitPoints -= (int)(b.HitPoints * Rand.Range(0.10f, 0.45f));

                if (isSkyCloudCore)
                {
                    GenExplosion.DoExplosion(this.parent.Position, this.parent.Map, 8, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                }
                else
                {
                    GenExplosion.DoExplosion(this.parent.Position, this.parent.Map, 2, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                }
            }
        }
 public static bool RequiresMaintenance( CompBreakdownable comp )
 {
     return GetDurability( comp ) < maintenanceThreshold;
 }
示例#33
0
 public override void PostSpawnSetup()
 {
     base.PostSpawnSetup();
     IncidentDef incidentDef = DefDatabase<IncidentDef>.GetNamed("ShortCircuit");
     if (incidentDef.workerClass != typeof(IncidentWorker_RTShortCircuit))
     {
         incidentDef.workerClass = typeof(IncidentWorker_RTShortCircuit);
         DefDatabase<IncidentDef>.ResolveAllReferences();
         Log.Message("RT_Fuse: replaced IncidentWorker for ShortCircuit.");
     }
     compBreakdownable = parent.TryGetComp<CompBreakdownable>();
     compFlickable = parent.TryGetComp<CompFlickable>();
 }
 public static void SetDurability( CompBreakdownable comp, float durability )
 {
     _durabilities[comp] = Mathf.Clamp( durability, .001f, 1f );
 }