Пример #1
0
        // ===================== 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();
            }
        }
Пример #2
0
 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();
     }
 }
Пример #3
0
        public override void Tick()
        {
            // Set supply ship position so it is visible above fog of war.
            if (SupplyShipIsInBoundsAndVisible())
            {
                this.Position = this.DrawPos.ToIntVec3();
            }
            else
            {
                this.Position = this.landingPadPosition;
            }

            if (this.ticksToLanding == horizontalTrajectoryDurationInTicks + rotationDurationInTicks + verticalTrajectoryDurationInTicks)
            {
                // TODO: remove this sound?
                SupplyShipLandingOn.preLandingSound.PlayOneShot(base.Position);
            }
            this.ticksToLanding--;
            if ((this.ticksToLanding == rotationDurationInTicks + verticalTrajectoryDurationInTicks) &&
                this.landingPadRotation == Rot4.East)
            {
                this.ticksToLanding -= rotationDurationInTicks;
            }
            if (this.ticksToLanding <= 0)
            {
                for (int dustMoteIndex = 0; dustMoteIndex < 40; dustMoteIndex++)
                {
                    Vector3 dustMotePosition = base.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead) + Gen.RandomHorizontalVector(6f);
                    MoteThrower.ThrowDustPuff(dustMotePosition, 1.6f);
                }
                Thing supplyShip = ThingMaker.MakeThing(OG_Util.SupplyShipDef);
                supplyShip.SetFactionDirect(OG_Util.FactionOfMAndCo);
                GenSpawn.Spawn(supplyShip, this.landingPadPosition, this.landingPadRotation);
                this.Destroy();
            }
            if (this.ticksToLanding == verticalTrajectoryDurationInTicks)
            {
                SupplyShipLandingOn.landingOnSound.PlayOneShot(base.Position);
            }
        }
        public override void Tick()
        {
            this.ticksToImpact--;
            if (this.ticksToImpact <= 0)
            {
                bool          pawnOrBuildingHasBeenCrushed = false;
                StringBuilder stringBuilder = new StringBuilder();
                foreach (IntVec3 landingCell in GenAdj.CellsOccupiedBy(this))
                {
                    foreach (Thing thing in Find.ThingGrid.ThingsAt(landingCell))
                    {
                        if ((thing is Mote) || (thing.Faction == null))
                        {
                            continue;
                        }
                        if ((thing != this) && (thing.Faction == Faction.OfColony))
                        {
                            if (((thing is Building) ||
                                 (thing is Pawn)) &&
                                (pawnOrBuildingHasBeenCrushed == false))
                            {
                                pawnOrBuildingHasBeenCrushed = true;
                                stringBuilder.AppendLine("This strange building has crushed anything under it upon landing.");
                                stringBuilder.AppendLine();
                                stringBuilder.AppendLine("The following things have been crushed:");
                                stringBuilder.AppendLine();
                            }
                            if (thing is Pawn)
                            {
                                Pawn   crushedPawn = thing as Pawn;
                                string herHimOrIt  = "it";
                                string sheHeOrIt   = "it";
                                if (crushedPawn.gender == Gender.Female)
                                {
                                    herHimOrIt = "her";
                                    sheHeOrIt  = "she";
                                }
                                else if (crushedPawn.gender == Gender.Male)
                                {
                                    herHimOrIt = "him";
                                    sheHeOrIt  = "he";
                                }
                                stringBuilder.AppendLine("- Poor " + crushedPawn.Name + "'. Don't bother looking for " + herHimOrIt + ", " + sheHeOrIt + " is already six feet under. RIP.");
                            }
                            else if (thing is Building)
                            {
                                Building crushedBuilding = thing as Building;
                                stringBuilder.AppendLine("- " + crushedBuilding.Label);
                            }
                            thing.Destroy(DestroyMode.Vanish);
                        }
                    }
                }
                if (pawnOrBuildingHasBeenCrushed)
                {
                    Find.LetterStack.ReceiveLetter("Hurting landing", stringBuilder.ToString(), LetterType.BadNonUrgent, this.Position);
                }

                Thing mechanoidTerraformer = ThingMaker.MakeThing(Util_MechanoidTerraformer.MechanoidTerraformerDef);
                mechanoidTerraformer.SetFactionDirect(Faction.OfMechanoids);
                GenSpawn.Spawn(mechanoidTerraformer, this.Position);
                this.Destroy();
            }
            else if (this.ticksToImpact <= verticalTrajectoryDurationInTicks)
            {
                for (int dustMoteIndex = 0; dustMoteIndex < 2; dustMoteIndex++)
                {
                    Vector3 dustMotePosition = base.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead) + Gen.RandomHorizontalVector(4f);
                    MoteThrower.ThrowDustPuff(dustMotePosition, 1.2f);
                }
            }
            if (this.ticksToImpact == soundAnticipationTicks + verticalTrajectoryDurationInTicks)
            {
                MechanoidTerraformerIncoming.preLandingSound.PlayOneShot(base.Position);
            }
            if (this.ticksToImpact == verticalTrajectoryDurationInTicks)
            {
                MechanoidTerraformerIncoming.landingSound.PlayOneShot(base.Position);
            }
        }
Пример #5
0
 public virtual void DoDustPuff()
 {
     MoteThrower.ThrowDustPuff(this.Position, 1f);
     sound.PlayOneShot(this.Position);
 }
Пример #6
0
        public void PerformDeployingPylonTreatment()
        {
            const int phasePeriodInTicks = 600;

            if (this.pylonConstructionIsInProgress == false)
            {
                if (this.pylonsList.Count == 8)
                {
                    // This case should not happen.
                    this.ticksCounter     = 0;
                    this.terraformerState = TerraformerState.Idle;
                    return;
                }

                // Find a random free pylon position.
                do
                {
                    this.currentPylonIndex = Rand.RangeInclusive(0, 7);
                } while (this.pylonIsConstructed[this.currentPylonIndex] != false);
                this.pylonConstructionIsInProgress = true;
                this.ticksCounter = 0;
            }
            if (this.ticksCounter == phasePeriodInTicks)
            {
                Find.TerrainGrid.SetTerrain(this.pylonsPositions[this.currentPylonIndex], TerrainDefOf.Concrete);
            }
            else if (this.ticksCounter == 2 * phasePeriodInTicks)
            {
                for (int cellIndex = 0; cellIndex < 5; cellIndex++)
                {
                    Find.TerrainGrid.SetTerrain(this.pylonsPositions[this.currentPylonIndex] + GenRadial.RadialPattern[cellIndex], TerrainDefOf.Concrete);
                }
            }
            else if (this.ticksCounter == 3 * phasePeriodInTicks)
            {
                for (int cellIndex = 0; cellIndex < 9; cellIndex++)
                {
                    Find.TerrainGrid.SetTerrain(this.pylonsPositions[this.currentPylonIndex] + GenRadial.RadialPattern[cellIndex], TerrainDefOf.Concrete);
                }
            }
            else if (this.ticksCounter == 4 * phasePeriodInTicks)
            {
                for (int cellIndex = 0; cellIndex < 13; cellIndex++)
                {
                    Find.TerrainGrid.SetTerrain(this.pylonsPositions[this.currentPylonIndex] + GenRadial.RadialPattern[cellIndex], TerrainDefOf.Concrete);
                }
            }
            else if (this.ticksCounter == 5 * phasePeriodInTicks)
            {
                Thing pylon = ThingMaker.MakeThing(Util_MechanoidTerraformer.MechanoidPylonDef);
                pylon.SetFactionDirect(Faction.OfMechanoids);
                GenSpawn.Spawn(pylon, this.pylonsPositions[this.currentPylonIndex]);
                this.pylonsList.Add(pylon);
                this.pylonIsConstructed[this.currentPylonIndex] = true;
            }
            else if (this.ticksCounter == 6 * phasePeriodInTicks)
            {
                this.pylonConstructionIsInProgress = false;
                this.ticksCounter     = 0;
                this.terraformerState = TerraformerState.Idle;
            }
            else
            {
                Vector3 dustMotePosition = this.pylonsPositions[this.currentPylonIndex].ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead) + Gen.RandomHorizontalVector(1.2f);
                MoteThrower.ThrowDustPuff(dustMotePosition, 0.8f);
            }
        }
Пример #7
0
        private void PodImpact()
        {
            // max side length of drawSize or actual size determine result crater radius
            var impactRadius = Mathf.Max(Mathf.Max(def.Size.x, def.Size.z), Mathf.Max(Graphic.drawSize.x, Graphic.drawSize.y)) * 1.5f;

            for (int i = 0; i < 6; i++)
            {
                Vector3 loc = Position.ToVector3Shifted() + Gen.RandomHorizontalVector(1f);
                MoteThrower.ThrowDustPuff(loc, 1.2f);
            }
            // Create a crashed drop pod
            DropPodCrashed dropPod = (DropPodCrashed)ThingMaker.MakeThing(ThingDef.Named("DropPodCrashed"), null);

            dropPod.info = contents;
            dropPod.SetFactionDirect(factionDirect);
            // Spawn the crater
            var crater = (Crater)ThingMaker.MakeThing(ThingDef.Named("Crater"));

            // adjust result crater size to the impact zone radius
            crater.impactRadius = impactRadius;
            // spawn the crater, rotated to the random angle, to provide visible variety
            GenSpawn.Spawn(crater, Position, Rot4.North);

            // Spawn the crashed drop pod
            GenSpawn.Spawn(dropPod, Position, Rotation);
            // For all cells around the crater centre point based on half its diameter (radius)
            foreach (IntVec3 current in GenRadial.RadialCellsAround(crater.Position, impactRadius, true))
            {
                // List all things found in these cells
                List <Thing> list = Find.ThingGrid.ThingsListAt(current);
                // Reverse iterate through the things so we can destroy without breaking the pointer
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    // If its a plant, filth, or an item
                    if (list[i].def.category == ThingCategory.Plant || list[i].def.category == ThingCategory.Filth || list[i].def.category == ThingCategory.Item)
                    {
                        // Destroy it
                        list[i].Destroy();
                    }
                }
            }
            RoofDef roof = Position.GetRoof();

            if (roof != null)
            {
                if (!roof.soundPunchThrough.NullOrUndefined())
                {
                    roof.soundPunchThrough.PlayOneShot(Position);
                }
                if (roof.filthLeaving != null)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        FilthMaker.MakeFilth(Position, roof.filthLeaving, 1);
                    }
                }
            }
            // Do a bit of camera shake for added effect
            CameraShaker.DoShake(0.020f);
            // Fire an explosion with motes
            GenExplosion.DoExplosion(Position, 0.5f, DamageDefOf.Bomb, this, null, null, null, null, 0f, false, null, 0f);
            CellRect cellRect = CellRect.CenteredOn(Position, 2);

            cellRect.ClipInsideMap();
            for (int i = 0; i < 5; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                MoteThrower.ThrowFireGlow(DrawPos.ToIntVec3(), 1.5f);
            }
            this.Destroy(DestroyMode.Vanish);
        }