public override IEnumerable <Command> CompGetGizmosExtra() { var com = new Command_Action { defaultLabel = ResourceBank.CycleLayerLabel, defaultDesc = ResourceBank.CycleLayerDesc, icon = currentLayer == NetLayer.Lower ? ResourceBank.UILower : ResourceBank.UIUpper, activateSound = SoundDef.Named("DesignateMine"), hotKey = KeyBindingDefOf.CommandColonistDraft, action = () => { var oldLayer = currentLayer; currentLayer = currentLayer == NetLayer.Lower ? NetLayer.Upper : NetLayer.Lower; MoteThrower.ThrowText(parent.Position.ToVector3Shifted(), ResourceBank.CycleLayerMote.Translate(currentLayer.ToStringTranslated())); AirNetManager.NotifyCompLayerChange(this, oldLayer); } }; foreach (var current in base.CompGetGizmosExtra()) { yield return(current); } yield return(com); }
public override void OnItemTransfer(Thing item, BeltComponent other) { if (this.IsReceiver()) { return; } int minPuffs = (A2BResearch.TeleporterHeat.IsResearched() ? 1 : 4); int maxPuffs = (A2BResearch.TeleporterHeat.IsResearched() ? 2 : 6); float heat = PowerComponent.PowerOutput / basePowerConsumption * DegreesPerDistance; Room room = GridsUtility.GetRoom(parent.Position); if (room != null) { room.PushHeat(heat); } for (int i = 0; i < Rand.RangeInclusive(minPuffs, maxPuffs); ++i) { MoteThrower.ThrowAirPuffUp(parent.DrawPos); } room = GridsUtility.GetRoom(ReceiverPos); if (room != null) { room.PushHeat(heat); } for (int i = 0; i < Rand.RangeInclusive(minPuffs, maxPuffs); ++i) { MoteThrower.ThrowAirPuffUp(Gen.TrueCenter(ReceiverPos, parent.Rotation, new IntVec2(2, 1), 0.5f)); } }
protected virtual void Freeze() { _beltPhase = Phase.Frozen; Messages.Message(Constants.TxtFrozenMsg.Translate(), MessageSound.Negative); MoteThrower.ThrowMicroSparks(Gen.TrueCenter(parent)); }
public void StartReload() { this.count = 0; this.needReload = true; if (this.Wielder == null) { Log.ErrorOnce("Wielder of " + this.parent + " is null!", 7381889); this.FinishReload(); } else { if (this.reloaderProp.throwMote) { MoteThrower.ThrowText(this.Wielder.Position.ToVector3Shifted(), Translator.Translate("CR_ReloadingMote"), -1); } Job job = new Job(DefDatabase <JobDef> .GetNamed("VanillaReloadableGuns", true), this.Wielder, this.parent) { playerForced = true }; if (this.Wielder.drafter != null) { this.Wielder.drafter.TakeOrderedJob(job); } else { ExternalPawnDrafter.TakeOrderedJob(this.Wielder, job); } } }
// ===================== Main Work Function ===================== /// <summary> /// Main function: /// - display some spore. /// - try to attach a mood effect on nearby colonists. /// </summary> public override void Tick() { base.Tick(); if (this.lifeCounterInTicks < this.sporeSpawningDurationInTicks) { MoteThrower.ThrowDustPuff(this.TrueCenter(), Rand.Value); this.ticksToNearPawnCheck++; if (this.ticksToNearPawnCheck > GenTicks.TicksPerRealSecond) { this.ticksToNearPawnCheck = 0; foreach (Pawn pawn in Find.MapPawns.AllPawns) { if ((pawn.Position.InHorDistOf(this.Position, sporeEffectRadius)) && (pawn.needs.mood != null)) { pawn.needs.mood.thoughts.TryGainThought(Util_CavePlant.breathedGleamcapSmokeDef); } } } this.lifeCounterInTicks++; } else { // Inform the gleamcap that the spore spawner is destroyed. this.parent.sporeSpawnerBuilding = null; this.Destroy(); } }
public void StartReload() { count = 0; needReload = true; #if DEBUG if (Wielder == null) { Log.ErrorOnce("Wielder of " + parent + " is null!", 7381889); FinishReload(); return; } #endif if (reloaderProp.throwMote) { MoteThrower.ThrowText(Wielder.Position.ToVector3Shifted(), "CR_ReloadingMote".Translate()); } var job = new Job(DefDatabase <JobDef> .GetNamed("ReloadWeapon"), Wielder, parent) { playerForced = true }; if (Wielder.drafter != null) { Wielder.drafter.TakeOrderedJob(job); } else { ExternalPawnDrafter.TakeOrderedJob(Wielder, job); } }
protected Toil GetToilPlayTheGuitar() { int tickCounter = 0; Toil toil = new Toil() { initAction = () => { tickCounter = Rand.Range(35, 50); MoteAttached moteAttached = (MoteAttached)ThingMaker.MakeThing(Util_CampfireParty.Mote_Guitar); moteAttached.AttachTo(this.pawn); GenSpawn.Spawn(moteAttached, this.pawn.Position); this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + new IntVec3(0, 0, -1)); }, tickAction = () => { tickCounter--; if (tickCounter <= 0) { tickCounter = Rand.Range(35, 50); MoteThrower.ThrowDrift(this.pawn.Position, Util_CampfireParty.Mote_MusicNote); } // Gain some joy. this.pawn.needs.joy.GainJoy(this.CurJob.def.joyGainRate * 0.000144f, Util_CampfireParty.JoyKindDefOf_Social); this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + new IntVec3(0, 0, -1)); }, defaultDuration = 240, defaultCompleteMode = ToilCompleteMode.Delay }; return(toil); }
protected virtual void Explode() { this.Destroy(DestroyMode.Vanish); ThingDef preExplosionSpawnThingDef = this.def.projectile.preExplosionSpawnThingDef; GenExplosion.DoExplosion(base.Position, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.soundExplode, this.def, this.equipmentDef, this.def.projectile.postExplosionSpawnThingDef, this.def.projectile.explosionSpawnChance, false, preExplosionSpawnThingDef, this.def.projectile.explosionSpawnChance); MoteThrower.ThrowLightningGlow(base.Position.ToVector3Shifted(), 10F); }
protected override void Impact(Thing hitThing) { base.Impact(hitThing); if (hitThing != null) { int damageAmountBase = this.def.projectile.damageAmountBase; BodyPartDamageInfo value; DamageDef_CR damDefCR = def.projectile.damageDef as DamageDef_CR; if (damDefCR != null && damDefCR.harmOnlyOutsideLayers) { value = new BodyPartDamageInfo(null, BodyPartDepth.Outside); } else { value = new BodyPartDamageInfo(null, null); } DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.def); ProjectilePropertiesCR propsCR = def.projectile as ProjectilePropertiesCR; if (propsCR != null && !propsCR.secondaryDamage.NullOrEmpty()) { // Get the correct body part Pawn pawn = hitThing as Pawn; if (pawn != null && def.projectile.damageDef.workerClass == typeof(DamageWorker_AddInjuryCR)) { dinfo = new DamageInfo(dinfo.Def, dinfo.Amount, dinfo.Instigator, dinfo.Angle, new BodyPartDamageInfo(DamageWorker_AddInjuryCR.GetExactPartFromDamageInfo(dinfo, pawn), false, (HediffDef)null), dinfo.Source); } List <DamageInfo> dinfoList = new List <DamageInfo>() { dinfo }; foreach (SecondaryDamage secDamage in propsCR.secondaryDamage) { dinfoList.Add(new DamageInfo(secDamage.def, secDamage.amount, dinfo.Instigator, dinfo.Part, dinfo.Source)); } foreach (DamageInfo curDinfo in dinfoList) { hitThing.TakeDamage(curDinfo); } } else { hitThing.TakeDamage(dinfo); } } else { SoundDefOf.BulletImpactGround.PlayOneShot(base.Position); MoteThrower.ThrowStatic(this.ExactPosition, ThingDefOf.Mote_ShotHit_Dirt, 1f); } }
// ===================== Drawing functions ===================== public void ComputeDrawingParameters() { this.generatorAngleInDegrees += this.generatorAngleIncrementPerTickInDegrees; if ((this.generatorIsStarted) && (Rand.Value < 0.015)) { MoteThrower.ThrowStatic(this.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead) + Gen.RandomHorizontalVector(0.6f), ThingDefOf.Mote_ExplosionFlash, 3f); } }
protected override bool TryCastShot() { if (!base.TryCastShot()) { return(false); } MoteThrower.ThrowStatic(this.caster.Position, ThingDefOf.Mote_ShotFlash, 9f); return(true); }
private void ToilTick() { ticksToSleepZ--; if (ticksToSleepZ <= 0) { MoteThrower.ThrowDrift(pawn.Position, ThingDefOf.Mote_SleepZ); ticksToSleepZ += TicksBetweenSleepZs; } }
public void FinishReload() { SoundStarter.PlayOneShot(this.parent.def.soundInteract, SoundInfo.InWorld(this.Wielder.Position, 0)); if (this.reloaderProp.throwMote) { MoteThrower.ThrowText(this.Wielder.Position.ToVector3Shifted(), Translator.Translate("CR_ReloadedMote"), -1); } this.count = this.reloaderProp.roundPerMag; this.needReload = false; }
public void FinishReload() { parent.def.soundInteract.PlayOneShot(SoundInfo.InWorld(Wielder.Position)); if (reloaderProp.throwMote) { MoteThrower.ThrowText(Wielder.Position.ToVector3Shifted(), "CR_ReloadedMote".Translate()); } count = reloaderProp.roundPerMag; needReload = false; }
private void DoOutOfAmmoAction() { if (Props.throwMote) { MoteThrower.ThrowText(position.ToVector3Shifted(), "CR_OutOfAmmo".Translate() + "!"); } if (wielder != null && compInventory != null && (wielder.jobs == null || wielder.CurJob.def != JobDefOf.Hunt)) { compInventory.SwitchToNextViableWeapon(); } }
public virtual void Jam() { int max = Rand.RangeInclusive(1, 3); for (int i = 0; i < max; ++i) { MoteThrower.ThrowMicroSparks(parent.DrawPos); } _beltPhase = Phase.Jammed; Messages.Message(Constants.TxtJammedMsg.Translate(), MessageSound.Negative); }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { base.Destroy(mode); this.launcher.NotifyTargetIsDestroyedOrMissed(this.target); if (mode == DestroyMode.Kill) { MoteThrower.ThrowLightningGlow(this.DrawPos, 6f); for (int smokeIndex = 0; smokeIndex < 3; smokeIndex++) { MoteThrower.ThrowSmoke(this.DrawPos + new Vector3(Rand.Range(0, 1), 0, Rand.Range(0, 1)), 3f); } SoundInfo infos = SoundInfo.InWorld(this); SoundDef.Named("Explosion_Bomb").PlayOneShot(infos); } }
public new bool TryTalkTo(SpeechMessage speech, Pawn talkee) { if (!CanTalkTo(talkee)) { return(false); } if (speech.ThoughtDef != null && talkee.needs.mood != null) { Thought_Memory thoughtMemory = (Thought_Memory)ThoughtMaker.MakeThought(speech.ThoughtDef); thoughtMemory.powerFactor = 1f; talkee.needs.mood.thoughts.TryGainThought(thoughtMemory); } MoteThrower.MakeSpeechOverlay(pawn); lastTalkTime = Find.TickManager.TicksGame; return(true); }
protected override void Impact(Thing hitThing) { base.Impact(hitThing); if (hitThing != null) { if (hitThing.def.category == ThingCategory.Pawn && hitThing.def.race.isFlesh) { DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, this.def.projectile.damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(new BodyPartDamageInfo(new BodyPartHeight?(), new BodyPartDepth?())), this.equipmentDef); hitThing.TakeDamage(dinfo); } } else { SoundStarter.PlayOneShot(SoundDefOf.BulletImpactGround, (SoundInfo)this.Position); MoteThrower.ThrowStatic(this.ExactPosition, ThingDefOf.Mote_ShotHit_Dirt, 2f); } }
public override void Tick() { base.Tick(); if (--Burnticks == 0) { MoteThrower.ThrowSmoke(base.Position.ToVector3Shifted(), 1f); Burnticks = 3; } if (this.ticksToDetonation > 0) { this.ticksToDetonation--; if (this.ticksToDetonation <= 0) { this.Explode(); } } }
protected override void Impact(Thing hitThing) { if (hitThing != null) { if (hitThing.def.category == ThingCategory.Pawn) { MoteThrower.ThrowText(new Vector3((float)this.Position.x + 1f, (float)this.Position.y, (float)this.Position.z + 1f), Translator.Translate("Hit"), Color.red); } DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, this.def.projectile.damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(new BodyPartDamageInfo(new BodyPartHeight?(), new BodyPartDepth?())), this.equipmentDef); hitThing.TakeDamage(dinfo); this.Explode(); } else { this.Explode(); } }
private void LaunchMissile(DropPodIncoming dropPod) { const int ticksToImpactOffsetAverage = 40; bool targetWillBeHit = true; float landingDistanceCoefficient = 0f; Vector3 missPositionOffset; // Determine if drop pod will be hit. if (Rand.Value < 0.8f) { targetWillBeHit = true; missPositionOffset = new Vector3(0, 0, 0); } else { targetWillBeHit = false; missPositionOffset = new Vector3(5, 0, 5).RotatedBy(Rand.Range(0, 360)); } // Compute predicted target impact position and time. int dropPodTicksToLanding = (int)(typeof(DropPodIncoming).GetField("ticksToImpact", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(dropPod)); int ticksToImpactOffset = ticksToImpactOffsetAverage + Rand.RangeInclusive(-10, 10); int predictedTicksToImpact = dropPodTicksToLanding - ticksToImpactOffset; landingDistanceCoefficient = (float)(ticksToImpactOffset * ticksToImpactOffset) * 0.01f; Vector3 predictedImpactPosition = dropPod.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.FlyingItem) + new Vector3(-landingDistanceCoefficient * 0.4f, 0, +landingDistanceCoefficient * 0.6f) + missPositionOffset; Projectile_Sam sam = ThingMaker.MakeThing(ThingDef.Named("Sam")) as Projectile_Sam; sam.InitializeMissileData(this, dropPod, this.Position.ToVector3Shifted(), predictedImpactPosition, predictedTicksToImpact, targetWillBeHit); GenSpawn.Spawn(sam, this.Position); this.missilesLoadedNumber--; // Update turret rotation. this.patrolTicksToNextRotation = patrolRotationIntervalMin; this.turretRotation = (predictedImpactPosition - this.DrawPos).AngleFlat(); StopRotationSound(); // Throw smoke and play missile launch sound. MoteThrower.ThrowSmoke(this.DrawPos, 2f); SoundInfo infos = SoundInfo.InWorld(this); OG_Util.MissileLaunchSoundDef.PlayOneShot(infos); }
private void SteamTick() { if (sprayTicksLeft > 0) { sprayTicksLeft--; if (Rand.Value < 0.8f) { MoteThrower.ThrowAirPuffUp(this.TrueCenter()); } if (sprayTicksLeft <= 0) { sprayTicksLeft = Rand.RangeInclusive(1, 10); } } else { sprayTicksLeft = Rand.RangeInclusive(5, 10); } }
public override void CompTick() { base.CompTick(); //Apply decay once per second if (Gen.IsHashIntervalTick(this.parent, 60)) { //Decay global suppression if (this.currentSuppressionInt > suppressionDecayRate) { this.currentSuppressionInt -= suppressionDecayRate; //Check if pawn is still suppressed if (this.isSuppressed && this.currentSuppressionInt <= this.suppressionThreshold) { this.isSuppressed = false; } } else if (this.currentSuppressionInt > 0) { this.currentSuppressionInt = 0; this.isSuppressed = false; } //Decay location suppression if (this.locSuppressionAmount > suppressionDecayRate) { this.locSuppressionAmount -= suppressionDecayRate; } else if (this.locSuppressionAmount > 0) { this.locSuppressionAmount = 0; } } //Throw mote at set interval if (Gen.IsHashIntervalTick(this.parent, ticksPerMote)) { if (this.isSuppressed) { MoteThrower.ThrowText(this.parent.Position.ToVector3Shifted(), "CR_SuppressedMote".Translate()); } } }
protected override bool TryCastShot() { if (!base.TryCastShot()) { return(false); } var i = 1; while ( (i < pelletCount) && (base.TryCastShot()) ) { i++; } MoteThrower.ThrowStatic(caster.Position, ThingDefOf.Mote_ShotFlash, 9f); return(true); }
private static void ShortCircuit(Thing hitThing) { if (hitThing == null) { throw new NullReferenceException("hitThing"); } GenExplosion.DoExplosion(hitThing.Position, Rand.Range(1f, 3f), DamageDefOf.Flame, hitThing); if (hitThing != null) { hitThing.TryAttachFire(0.2f); } MoteThrower.ThrowStatic(hitThing.Position, ThingDefOf.Mote_ShotFlash, 6); MoteThrower.ThrowMicroSparks(hitThing.Position.ToVector3Shifted()); if (!hitThing.Destroyed) { hitThing.TakeDamage(new DamageInfo(DamageDefOf.Stun, Rand.Range(150, 500), hitThing, null)); } }
public override void Tick() { // If the pod is inflight, slight ending delay here to stop smoke motes covering the crash if (ticksToImpact > 8) { // Throw some smoke and fire glow trails MoteThrower.ThrowSmoke(DrawPos, 3f); MoteThrower.ThrowFireGlow(DrawPos.ToIntVec3(), 1.5f); } this.ticksToImpact--; if (ticksToImpact <= 0) { PodImpact(); } if (!soundPlayed && ticksToImpact < 100) { soundPlayed = true; SoundDefOf.DropPodFall.PlayOneShot(Position); } }
/// <summary> /// Impacts a pawn/object or the ground. /// </summary> protected override void Impact(Thing hitThing) { if (hitThing != null) { int damageAmountBase = this.def.projectile.damageAmountBase; BodyPartDamageInfo value = new BodyPartDamageInfo(null, null); DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.launcher, this.ExactRotation.eulerAngles.y, new BodyPartDamageInfo?(value), this.equipmentDef); hitThing.TakeDamage(dinfo); hitThing.def.soundImpactDefault.PlayOneShot(this.DestinationCell); Pawn pawn = hitThing as Pawn; if (pawn != null && !pawn.Downed && Rand.Value < Projectile_LaserRifle.stunChance) { hitThing.TakeDamage(new DamageInfo(DamageDefOf.Stun, 10, this.launcher, null, null)); } } else { MoteThrower.ThrowStatic(this.destination, ThingDefOf.Mote_MicroSparks); } }
private void Crash() { if (Crashed) { return; } lastCrashTime = Find.TickManager.TicksGame; if (mindState.breaker.TryDoMentalBreak(Defs.CrashedDef)) { return; } //if (jobs == null) return; // Recover insanity? if (BrokenStateDef != null && Rand.Value < 0.35f) { MoteThrower.ThrowStatic(Position, ThingDefOf.Mote_ShotFlash, Rand.Range(5f, 10f)); BrokenState.RecoverFromState(); } //if (jobs != null) //{ // if (jobs.curJob != null) // { // if (!InStandby) // { // jobs.StopAll(); // } // } // //jobs.StartJob(new Job(rebootJobDef, Position)); //} //MoteThrower.ThrowMetaPuffs(Position); //for (int i = 0; i < Rand.Range(1, 4); i++) //{ // MoteThrower.ThrowStatic(Position, ThingDefOf.Mote_ShotHit_Spark, Rand.Range(0.5f, 2.5f)); //} }
public override void Tick() { base.Tick(); if (!this.HasPower || !this.HasFissure) { return; } if (Find.TickManager.TicksGame % 200 == 0) { GenTemperature.PushHeat(this, 1f); } if (Find.TickManager.TicksGame % 90 == 0) { MoteThrower.ThrowDustPuff(this.TrueCenter(), 0.3f); } if (tickCount-- <= 0) { tickCount = availableList[resourceIndex].ticksToProduce; Dig(); } }