public override void ExposeData() { base.ExposeData(); Scribe_Values.Look <Map>(ref targetMap, "targetMap", null, false); Scribe_Values.Look <IntVec3>(ref targetPosition, "targetPosition", new IntVec3(), false); Scribe_Values.Look <int>(ref timeToLive, "timeToLive", GenTicks.SecondsToTicks(30), false); }
public override void CompTick() { if (this.Props.secondsBetweenSteps <= 0.0f) { Log.ErrorOnce("CompLumbering :: CompProperties_Lumbering secondsBetweenSteps needs to be more than 0", 132); } if (this.Props.secondsPerStep <= 0.0f) { Log.ErrorOnce("CompLumbering :: CompProperties_Lumbering secondsPerStep needs to be more than 0", 133); } if (this.Lumberer != null && this.Props.secondsPerStep > 0.0f && Find.TickManager.TicksGame > this.ticksToCycle) { if (this.Lumberer?.pather?.MovingNow ?? false) { this.cycled = !this.cycled; this.ticksToCycle = Find.TickManager.TicksGame + GenTicks.SecondsToTicks(this.Props.secondsPerStep); if (this.Props.sound != null) { this.Props.sound.PlayOneShot(SoundInfo.InMap(this.Lumberer)); } if (this.cycled) { ResolveCycledGraphic(); } else { //Log.Message("1b"); ResolveBaseGraphic(); } this.Lumberer.stances.StaggerFor(GenTicks.SecondsToTicks(this.Props.secondsBetweenSteps)); } } }
public void UseShadowClone(DamageInfo dinfo) { ThingDef cloneToUse = RWBYDefOf.Blake_ShadowClone; // default float cloneDuration = 2f; Color color = new Color(); if (remainingUses > 0 && elementalShadowCloneToUse != null) { remainingUses -= 1; cloneToUse = elementalShadowCloneToUse; cloneDuration = elementalShadowCloneDuration; color = elementalShadowCloneColor; } if (cloneToUse == RWBYDefOf.Blake_ShadowClone_Ice && dinfo.Instigator is Pawn attackerPawn && dinfo.Weapon != null && !dinfo.Weapon.IsRangedWeapon) // add stun(freeze) to melee attacker { attackerPawn.stances.stunner.StunFor_NewTmp(GenTicks.SecondsToTicks(4.5f), pawn); } Thing thing = ThingMaker.MakeThing(cloneToUse); thing.TryGetComp <CompShadowClone>().SetData(pawn, GenTicks.SecondsToTicks(cloneDuration), color); GenSpawn.Spawn(thing, pawn.Position, pawn.Map); thing.TryGetComp <CompShadowClone>().MovePawnOut(); if (cloneToUse == RWBYDefOf.Blake_ShadowClone_Fire) { thing.TryGetComp <CompExplosiveSilent>().StartWick(); } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); powerComp = GetComp <CompPowerTrader>(); medpodSettings = GetComp <CompMedPodSettings>(); treatmentRestrictions = GetComp <CompTreatmentRestrictions>(); MaxDiagnosingTicks = GenTicks.SecondsToTicks(medpodSettings.MaxDiagnosisTime); MaxHealingTicks = GenTicks.SecondsToTicks(medpodSettings.MaxPerHediffHealingTime); DiagnosingPowerConsumption = medpodSettings.DiagnosisModePowerConsumption; HealingPowerConsumption = medpodSettings.HealingModePowerConsumption; AlwaysTreatableHediffs = treatmentRestrictions.AlwaysTreatableHediffs; NeverTreatableHediffs = treatmentRestrictions.NeverTreatableHediffs; DisallowedRaces = treatmentRestrictions.DisallowedRaces; // Add a blocker region for the MedPod main machinery // (If one already exists, then we are probably loading a save with an existing MedPod) Thing something = Map.thingGrid.ThingsListAtFast(InvisibleBlockerPosition).FirstOrDefault(x => x.def.Equals(MedPodDef.MedPodInvisibleBlocker)); if (something != null) { something.DeSpawn(); } Thing t = ThingMaker.MakeThing(MedPodDef.MedPodInvisibleBlocker); GenPlace.TryPlaceThing(t, InvisibleBlockerPosition, Map, ThingPlaceMode.Direct, out resultingBlocker, null, null, Rotation); }
public override void CompTick() { Pawn pawn = (Pawn)base.parent; if (((Pawn)parent).health.hediffSet.GetPartHealth(((Pawn)parent).RaceProps.body.corePart) < ((Pawn)parent).RaceProps.body.corePart.def.hitPoints * Props.startThreshold * ((Pawn)parent).def.race.baseHealthScale) { if (GenTicks.TicksGame > lastheal + GenTicks.SecondsToTicks(Props.delay)) { foreach (Hediff h in pawn.health.hediffSet.hediffs) { if (h.def == HediffDefOf.Cut || h.def == HediffDefOf.Stab || h.def == HediffDefOf.Bruise || h.def == HediffDefOf.Bite || h.def == HediffDefOf.Gunshot || h.def == HediffDefOf.Scratch || h.def == HediffDefOf.Shredded || h.def == HediffDef.Named("Crush") || h.def == HediffDef.Named("Crack") || (h.def == HediffDefOf.MissingBodyPart && Props.restoreBodyParts)) { h.Heal(Props.amount); } } lastheal = GenTicks.TicksGame; } restoring = true; } if (restoring && ((Pawn)parent).health.hediffSet.GetPartHealth(((Pawn)parent).RaceProps.body.corePart) >= ((Pawn)parent).RaceProps.body.corePart.def.hitPoints * Props.endThreshold * ((Pawn)parent).def.race.baseHealthScale) { restoring = false; } base.CompTick(); }
public Thing TryDispenseFood(Pawn eater, Pawn getter) { if (getter == null) { getter = eater; } if (!CanDispenseNow) { return(null); } ThingDef meal = ReplimatUtility.PickMeal(eater, getter); if (meal == null) { return(null); } if (!HasStockFor(meal)) { //Log.Error("[Replimat] " + "Did not find enough foodstock in tanks while trying to replicate."); return(null); } ReplicatingTicks = GenTicks.SecondsToTicks(2f); def.building.soundDispense.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); Thing dispensedMeal = ThingMaker.MakeThing(meal, null); float dispensedMealMass = dispensedMeal.def.BaseMass; powerComp.PowerNet.TryConsumeFeedstock(ReplimatUtility.convertMassToFeedstockVolume(dispensedMealMass)); return(dispensedMeal); }
public override void Tick() { base.Tick(); if (!this.IsHashIntervalTick(AutoDef.dischargePeriodTicks)) { return; } AutocleanerJobDef job = CurJobDef as AutocleanerJobDef; if (job == null) { return; } charge -= job.dischargePerSecond * GenTicks.TicksToSeconds(AutoDef.dischargePeriodTicks); if (charge < 0) { charge = 0; } if (charge > AutoDef.charge) { charge = AutoDef.charge; } }
public override string GetInspectString() { StringBuilder stringBuilder = new StringBuilder(); if (this.IsActive()) { stringBuilder.AppendLine("Shield: " + this.FieldIntegrity_Current + "/" + this.m_FieldIntegrity_Max); } else if (this.CurrentStatus == enumShieldStatus.Initilising) { //stringBuilder.AppendLine("Initiating shield: " + ((warmupTicks * 100) / recoverWarmup) + "%"); stringBuilder.AppendLine("Ready in " + Math.Round(GenTicks.TicksToSeconds(m_WarmupTicksRemaining)) + " seconds."); //stringBuilder.AppendLine("Ready in " + m_warmupTicksCurrent + " seconds."); } else { stringBuilder.AppendLine("Shield disabled!"); } if (m_Power != null) { string text = m_Power.CompInspectStringExtra(); if (!text.NullOrEmpty()) { stringBuilder.AppendLine(text); } } return(stringBuilder.ToString()); }
public void CreatePortal(Pawn p) { if (p.Map == null) { Messages.Message("MessageTextNoPortalMap".Translate().Formatted(p.Named("PAWN")).AdjustedFor(p, "PAWN").CapitalizeFirst(), pawn, MessageTypeDefOf.NegativeEvent); return; } Thing portalA = ThingMaker.MakeThing(RWBYDefOf.Raven_Portal); GenSpawn.Spawn(portalA, pawn.Position, pawn.Map); Thing portalB = ThingMaker.MakeThing(RWBYDefOf.Raven_Portal); GenSpawn.Spawn(portalB, p.Position, p.Map); if (portalA is ThingWithComps_Portal tPortalA && tPortalA.Spawned) { tPortalA.RegisterConnectedPortal(portalB); } if (portalB is ThingWithComps_Portal tPortalB && tPortalB.Spawned) { tPortalB.RegisterConnectedPortal(portalA); } RWBYDefOf.Shoot_Fireball.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map, false)); RWBYDefOf.Shoot_Fireball.PlayOneShot(new TargetInfo(p.Position, p.Map, false)); cooldownTicks = GenTicks.SecondsToTicks(30); }
public override void Tick() { base.Tick(); if (!powerComp.PowerOn) { return; } if (this.IsHashIntervalTick(60)) { List <Thing> list = Map.thingGrid.ThingsListAtFast(Position); Thing foodInFeeder = list.FirstOrDefault(x => x.def.IsNutritionGivingIngestible); if (foodInFeeder == null) { //Log.Message("[Replimat] " + this.ThingID.ToString() + " is empty"); int maxKib = Mathf.FloorToInt(powerComp.PowerNet.GetTanks().Sum(x => x.storedFeedstock) / volumePerKibble); maxKib = Mathf.Min(maxKib, 75); if (maxKib > 0 && powerComp.PowerNet.TryConsumeFeedstock(volumePerKibble * maxKib)) { ReplicatingTicks = GenTicks.SecondsToTicks(2f); this.def.building.soundDispense.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); Thing t = ThingMaker.MakeThing(ThingDefOf.Kibble, null); t.stackCount = maxKib; GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct); } } else if (foodInFeeder.def == ThingDefOf.Kibble && foodInFeeder.stackCount < 20) { //Log.Message("[Replimat] " + this.ThingID.ToString() + " currently has " + foodInFeeder.stackCount.ToString() + " units of " + foodInFeeder.def.label.ToString()); int refill = Mathf.Min(foodInFeeder.def.stackLimit - foodInFeeder.stackCount, 75); int maxKib = Mathf.FloorToInt(powerComp.PowerNet.GetTanks().Sum(x => x.storedFeedstock) / volumePerKibble); maxKib = Mathf.Min(maxKib, refill); if (maxKib > 0 && powerComp.PowerNet.TryConsumeFeedstock(volumePerKibble * maxKib)) { ReplicatingTicks = GenTicks.SecondsToTicks(2f); this.def.building.soundDispense.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); foodInFeeder.stackCount += maxKib; } } } powerComp.PowerOutput = -125f; if (ReplicatingTicks > 0) { ReplicatingTicks--; powerComp.PowerOutput = -1500f; } }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); if (parent.CurStageIndex == 2) { parent.pawn.stances.stunner.StunFor_NewTmp(GenTicks.SecondsToTicks(1f), null); } }
public void ConfirmAction(int x, float volumeOfFeedstockRequired) { ReplicatingTicks = GenTicks.SecondsToTicks(2f); def.building.soundDispense.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); this.powerComp.PowerNet.TryConsumeFeedstock(volumeOfFeedstockRequired); Thing t = ThingMaker.MakeThing(ThingDefOf.MealSurvivalPack, null); t.stackCount = x; GenPlace.TryPlaceThing(t, this.InteractionCell, base.Map, ThingPlaceMode.Near); }
public override void Tick() { base.Tick(); if (!powerComp.PowerOn || !ReplimatUtility.CanFindComputer(this, PowerComp.PowerNet)) { return; } if (this.IsHashIntervalTick(60)) { List <Thing> list = Map.thingGrid.ThingsListAtFast(Position); Thing foodInFeeder = list.FirstOrDefault(x => x.def.IsNutritionGivingIngestible); if (foodInFeeder == null) { int maxAnimFeed = Mathf.FloorToInt(powerComp.PowerNet.GetTanks().Sum(x => x.storedFeedstock) / volumePerAnimalFeed); maxAnimFeed = Mathf.Min(maxAnimFeed, CurrentAnimalFeedDef.stackLimit); if (maxAnimFeed > 0 && powerComp.PowerNet.TryConsumeFeedstock(volumePerAnimalFeed * maxAnimFeed)) { ReplicatingTicks = GenTicks.SecondsToTicks(2f); def.building.soundDispense.PlayOneShot(new TargetInfo(Position, Map, false)); Thing t = ThingMaker.MakeThing(CurrentAnimalFeedDef, null); t.stackCount = maxAnimFeed; GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct); } } else if (foodInFeeder.def == CurrentAnimalFeedDef && foodInFeeder.stackCount < (CurrentAnimalFeedDef.stackLimit * 0.25)) { int refill = Mathf.Min(foodInFeeder.def.stackLimit - foodInFeeder.stackCount, foodInFeeder.def.stackLimit); int maxAnimFeed = Mathf.FloorToInt(powerComp.PowerNet.GetTanks().Sum(x => x.storedFeedstock) / volumePerAnimalFeed); maxAnimFeed = Mathf.Min(maxAnimFeed, refill); if (maxAnimFeed > 0 && powerComp.PowerNet.TryConsumeFeedstock(volumePerAnimalFeed * maxAnimFeed)) { ReplicatingTicks = GenTicks.SecondsToTicks(2f); def.building.soundDispense.PlayOneShot(new TargetInfo(Position, Map, false)); foodInFeeder.stackCount += maxAnimFeed; } } } powerComp.PowerOutput = -powerComp.Props.basePowerConsumption; if (ReplicatingTicks > 0) { ReplicatingTicks--; powerComp.PowerOutput = -Math.Max(stateDependentPowerComp.ActiveModePowerConsumption, powerComp.Props.basePowerConsumption); } }
public override void CompTick() { base.CompTick(); if (GetPawn == null || GetPawn.Dead || GetPawn.Map == null) { return; } if (GetPawn.IsHashIntervalTick(GenTicks.SecondsToTicks(Props.secondsBetweenLightning)) && (GetPawn.IsFighting() || GetPawn.InAggroMentalState)) { IntVec3 strikeLocation = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(GetPawn.Map) && !GetPawn.Map.roofGrid.Roofed(sq) && GetPawn.Position.DistanceTo(sq) <= Props.lightningRadius, GetPawn.Map, 1000); Find.CurrentMap.weatherManager.eventHandler.AddEvent(new WeatherEvent_LightningStrike(GetPawn.Map, strikeLocation)); } }
private string GetTimeString(int ticks) { if (ticks < GenDate.TicksPerHour) { return(GenTicks.TicksToSeconds(ticks).ToString("F0") + "s"); } if (ticks < GenDate.TicksPerDay) { return((ticks / GenDate.TicksPerHour).ToString("F0") + "h"); } return(ticks.ToStringTicksToDays("F1")); }
public override void CompTick() { if (!first) { first = true; start = GenTicks.TicksGame; } base.CompTick(); if (start + GenTicks.SecondsToTicks(Props.lifetime) < GenTicks.TicksGame) { parent.Destroy(); } }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); timeLimitTick = GenTicks.SecondsToTicks(Props.timeLimit); if (!isPlanted) { isPlanted = true; plantedTick = Find.TickManager.TicksGame; remainingTick = timeLimitTick; remainingSecond = Props.timeLimit; } ThrowText(parent.DrawPos + new Vector3(0, 0, 0.5f), parent.Map, remainingSecond.ToString(), Color.red); }
public override void Tick() { base.Tick(); Map map = base.Map; Corpse corpse; if (GenTicks.TicksGame % GenTicks.SecondsToTicks(5) == 0) { if (this.Spawned && !this.Downed && !this.Dead && FindNearestCorpse(this, map, out corpse) && !IsBusy) { this.jobs.StartJob(new Job(RWBDefOf.RWBSpinCocoon, corpse), JobCondition.InterruptForced); } } }
protected override void Impact(Thing hitThing) { if (hitThing is Pawn targetPawn && launcher is Pawn CasterPawn) { float damageToDeal = 50f; damageToDeal = damageToDeal * CasterPawn.health.hediffSet.hediffs.FindAll(h => h.def == RWBYDefOf.RWBY_SilverEyes).Count; DamageInfo dinfo1 = new DamageInfo(DamageDefOf.Burn, damageToDeal, 0f, -1f, CasterPawn, null, CasterPawn.def, DamageInfo.SourceCategory.ThingOrUnknown, targetPawn); dinfo1.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); Vector3 direction1 = (targetPawn.Position - CasterPawn.Position).ToVector3(); dinfo1.SetAngle(direction1); targetPawn.stances.stunner.StunFor_NewTmp(GenTicks.SecondsToTicks(5f), CasterPawn); targetPawn.TakeDamage(dinfo1); } this.Destroy(DestroyMode.Vanish); }
public override void CompTick() { base.CompTick(); if (startGameTick == 0) { startGameTick = Find.TickManager.TicksGame; } // If time is up, destroy parent if (Find.TickManager.TicksGame > startGameTick + GenTicks.SecondsToTicks(this.Props.lifetime)) { parent.Destroy(DestroyMode.Vanish); } }
protected override IEnumerable <Toil> MakeNewToils() { job.count = 1; Toil transformWeaponPreparations = new Toil(); transformWeaponPreparations.FailOn(() => totalNeededWork < 0); transformWeaponPreparations.initAction = delegate() { GetActor().pather.StopDead(); ThingWithComps thingToTransform = (ThingWithComps)TargetB; if (thingToTransform != null && thingToTransform.AllComps.Find(c => c is CompWeaponTransform comp1 && comp1.transformationPending) is CompWeaponTransform compWeaponTransform) { totalNeededWork = GenTicks.SecondsToTicks(compWeaponTransform.GetTransformTimeInSeconds()); workLeft = totalNeededWork; }
public override void MapComponentTick() { // Triggers once per second (60 ticks) if ((Find.TickManager.TicksGame % GenTicks.SecondsToTicks(1f)) == 0) { if (this.RoomState.Count > 0) { this.RoomState.Clear(); } List <Pawn> pawns = Find.CurrentMap.mapPawns.FreeColonists; if (!pawns.NullOrEmpty()) { // Check if room should be locked or unlocked foreach (Pawn pawn in pawns) { /* Old check for prisoners - seems deprecated... * if (pawn.IsPrisonerOfColony) * { * continue; * } */ Room room = pawn.GetRoom(); if (room != null && room.Owners.Count() > 0) { this.RefreshRoomState(room, pawn); } } foreach (KeyValuePair <Room, LockState> keyPair in this.RoomState) { if (keyPair.Value == LockState.WantUnlock) { // Unlock room this.SetRoomDoors(keyPair.Key, false); } else if (keyPair.Value == LockState.WantLock) { // Lock room this.SetRoomDoors(keyPair.Key, true); } } } } }
protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); this.UpdateTargets(); int shotsPerBurst = this.ShotsPerBurst; bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1; if (flag2) { this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1); } bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0; bool result; if (flag3) { Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true); this.Ability.Notify_AbilityFailed(true); result = false; } else { for (int i = 0; i < this.TargetsAoE.Count; i++) { Thing glyph = ThingMaker.MakeThing(RWBYDefOf.Weiss_Glyph_Summon); glyph.TryGetComp <CompGlyphSummon>().SetData(GenTicks.SecondsToTicks(1.5f), RWBYDefOf.Grimm_ArmaGigas_Summoned); GenSpawn.Spawn(glyph, TargetsAoE[i].Cell, caster.Map); CasterPawn.TryGetComp <CompAbilityUserAura>().AbilityData.AllPowers.Find(a => a.Def == RWBYDefOf.Weiss_SummonArmaGigas).CooldownTicksLeft = 3600; CasterPawn.TryGetComp <CompAbilityUserAura>().AbilityData.AllPowers.Find(a => a.Def == RWBYDefOf.Weiss_SummonArmaGigasSword).CooldownTicksLeft = 3600; bool abilitySucceeded = true; if (abilitySucceeded) { flag = true; } } this.PostCastShot(flag, out flag); bool postSucceed = !flag; if (postSucceed) { this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing); } result = flag; } return(result); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); InnerPawn.Rotation = Rot4.Random; this.SetForbidden(false, false); GetComps <CompRottable>() .Select(comp => comp.props) .OfType <CompProperties_Rottable>() .Cast <CompProperties_Rottable>() .Do(rotcomp => { rotcomp.daysToRotStart = 1f * GenTicks.SecondsToTicks(10) / 60000f; rotcomp.daysToDessicated = 1f * GenTicks.SecondsToTicks(30) / 60000f; }); }
protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); this.UpdateTargets(); int shotsPerBurst = this.ShotsPerBurst; bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1; if (flag2) { this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1); } bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0; bool result; if (flag3) { Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true); this.Ability.Notify_AbilityFailed(true); result = false; } else { for (int i = 0; i < this.TargetsAoE.Count; i++) { Thing timeDilationGlyph = ThingMaker.MakeThing(RWBYDefOf.Weiss_Glyph_TimeDilation); timeDilationGlyph.TryGetComp <CompTimeDilationGlyph>().SetData(GenTicks.SecondsToTicks(10f)); GenSpawn.Spawn(timeDilationGlyph, TargetsAoE[i].Cell, caster.Map); bool abilitySucceeded = true; if (abilitySucceeded) { flag = true; } } this.PostCastShot(flag, out flag); bool postSucceed = !flag; if (postSucceed) { this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing); } result = flag; } return(result); }
public string GetInspectString() { StringBuilder stringBuilder = new StringBuilder(); if (this.isOnline()) { stringBuilder.AppendLine("Shield: " + (object)this.shieldCurrentStrength + "/" + (object)this.shieldMaxShieldStrength); } else if (this.enabled) { stringBuilder.AppendLine("Ready in " + (object)Math.Round((double)GenTicks.TicksToSeconds(this.shieldRecoverWarmup - this.warmupTicksCurrent)) + " seconds."); } else { stringBuilder.AppendLine("Shield disabled!"); } return(stringBuilder.ToString()); }
public override string CompInspectStringExtra() { StringBuilder _StringBuilder = new StringBuilder(); //return base.CompInspectStringExtra(); _StringBuilder.Append(base.CompInspectStringExtra()); if (IsActive()) { _StringBuilder.AppendLine("Shield_Energy_Current".Translate(Mathf.FloorToInt(ShieldEnergyCurrent), ShieldEnergyMax)); } else if (this.CurrentStatus == EnumShieldStatus.Initilising) { _StringBuilder.AppendLine("Shield_Init".Translate(GenTicks.TicksToSeconds(zzShieldWarmupTicks).ToString("f1"))); } else { _StringBuilder.AppendLine("Shield_Inactive".Translate()); } if (CompPower != null) { string text = CompPower.CompInspectStringExtra(); if (!text.NullOrEmpty()) { _StringBuilder.Append(text); } else { _StringBuilder.Append("No_Power_Comp_Text".Translate()); } } else { _StringBuilder.Append("No_Power_Comp".Translate()); } return(_StringBuilder.ToString()); }
protected override IEnumerable <Toil> MakeNewToils() { job.count = 1; Toil toilGoto = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnSomeonePhysicallyInteracting(TargetIndex.A); yield return(toilGoto); if (this.pawn.TryGetComp <CompDodogama>() is CompDodogama compDodogama) { this.totalNeededWork = GenTicks.SecondsToTicks(compDodogama.Props.timeToEatInSeconds); workLeft = totalNeededWork; maxNutritionPercent = compDodogama.Props.maxNutritionFromRock; } else { totalNeededWork = -1; } Toil eatRock = new Toil(); eatRock.FailOn(() => totalNeededWork < 0).FailOnSomeonePhysicallyInteracting(TargetIndex.A); eatRock.tickAction = delegate() { workLeft--; if (workLeft <= 0f) { pawn.needs.food.CurLevel += maxNutritionPercent * TargetA.Thing.HitPoints / TargetA.Thing.MaxHitPoints; TargetA.Thing.Destroy(); eatRock.actor.jobs.curDriver.ReadyForNextToil(); } }; eatRock.defaultCompleteMode = ToilCompleteMode.Never; eatRock.WithProgressBar(TargetIndex.A, () => 1f - this.workLeft / this.totalNeededWork, false, -0.5f); yield return(eatRock); yield break; }
public Thing TryDispenseFood(Pawn eater, Pawn getter) { if (getter == null) { getter = eater; } if (!CanDispenseNow) { return(null); } ThingDef meal = ReplimatUtility.PickMeal(eater, getter); if (meal == null) { return(null); } if (!HasStockFor(meal)) { return(null); } ReplicatingTicks = GenTicks.SecondsToTicks(2f); def.building.soundDispense.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); Thing dispensedMeal = ThingMaker.MakeThing(meal, null); ReplimatUtility.GenerateIngredients(dispensedMeal, eater); float dispensedMealMass = dispensedMeal.def.BaseMass; powerComp.PowerNet.TryConsumeFeedstock(ReplimatUtility.ConvertMassToFeedstockVolume(dispensedMealMass)); return(dispensedMeal); }
public override void Tick() { base.Tick(); if (!powerComp.PowerOn) { return; } powerComp.PowerOutput = -125f; if (this.IsHashIntervalTick(60)) { List <Building_ReplimatFeedTank> tanks = GetTanks; List <Thing> list = Map.thingGrid.ThingsListAtFast(Position); Thing food = list.FirstOrDefault(x => settings.AllowedToAccept(x)); if (food == null) { return; } float stockvol = ReplimatUtility.convertMassToFeedstockVolume(food.def.BaseMass); float FreeSpace = tanks.Sum(x => x.AmountCanAccept); if (FreeSpace >= stockvol) { float buffy = stockvol; food.stackCount = food.stackCount - 1; if (food.stackCount == 0) { food.Destroy(); } DematerializingTicks = GenTicks.SecondsToTicks(2f); foreach (var tank in tanks.InRandomOrder()) { if (buffy > 0f) { float sent = Mathf.Min(buffy, tank.AmountCanAccept); buffy -= sent; tank.AddFeedstock(sent); } } } } if (DematerializingTicks > 0) { DematerializingTicks--; powerComp.PowerOutput = -1000f; if (this.wickSustainer == null) { this.StartWickSustainer(); } else if (this.wickSustainer.Ended) { this.StartWickSustainer(); } else { this.wickSustainer.Maintain(); } if (this.IsHashIntervalTick(5)) { dematerializingCycleInt++; if (dematerializingCycleInt > 2) { dematerializingCycleInt = 0; } } } }