public static void MakeBaseGeometry(Section section, LayerSubMesh sm, AltitudeLayer altitudeLayer)
        {
            sm.Clear(MeshParts.Verts | MeshParts.Tris);
            CellRect cellRect = new CellRect(section.botLeft.x, section.botLeft.z, 17, 17);

            cellRect.ClipInsideMap(section.map);
            float y = Altitudes.AltitudeFor(altitudeLayer);

            sm.verts.Capacity = cellRect.Area * 9;
            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    sm.verts.Add(new Vector3((float)i, y, (float)j));
                    sm.verts.Add(new Vector3((float)i, y, (float)j + 0.5f));
                    sm.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                    sm.verts.Add(new Vector3((float)i + 0.5f, y, (float)(j + 1)));
                    sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                    sm.verts.Add(new Vector3((float)(i + 1), y, (float)j + 0.5f));
                    sm.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                    sm.verts.Add(new Vector3((float)i + 0.5f, y, (float)j));
                    sm.verts.Add(new Vector3((float)i + 0.5f, y, (float)j + 0.5f));
                }
            }
            int num = cellRect.Area * 8 * 3;

            sm.tris.Capacity = num;
            int num2 = 0;

            while (sm.tris.Count < num)
            {
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 2);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 4);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 6);
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 8);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 8);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 8);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2 + 8);
                num2 += 9;
            }
            sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris);
        }
Esempio n. 2
0
        protected virtual void Impact(Thing hitThing)
        {
            bool flag = hitThing == null;

            if (flag)
            {
                Pawn hitPawn;
                bool flag2 = (hitPawn = (base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn)) != null;
                if (flag2)
                {
                    hitThing = hitPawn;
                }
            }
            bool hasValue = this.impactDamage.HasValue;

            if (hasValue)
            {
                for (int i = 0; i < this.timesToDamage; i++)
                {
                    bool flag3 = this.damageLaunched;
                    if (flag3)
                    {
                        this.flyingThing.TakeDamage(this.impactDamage.Value);
                    }
                    else
                    {
                        hitThing.TakeDamage(this.impactDamage.Value);
                    }
                }
                bool flag4 = this.explosion;
                if (flag4)
                {
                    GenExplosion.DoExplosion(base.Position, base.Map, 0.9f, DamageDefOf.Stun, this, -1, 0, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                }
            }

            List <IntVec3> dissipationList = GenRadial.RadialCellsAround(this.ExactPosition.ToIntVec3(), 9, false).ToList();

            for (int i = 0; i < (10 + 3 * pwrVal); i++)
            {
                IntVec3 strikeCell = dissipationList.RandomElement();
                if (strikeCell.InBounds(base.Map) && strikeCell.IsValid && !strikeCell.Fogged(this.Map))
                {
                    DrawStrike(this.ExactPosition.ToIntVec3(), strikeCell.ToVector3Shifted());
                    for (int k = 0; k < Rand.Range(1, 8); k++)
                    {
                        CellRect cellRect = CellRect.CenteredOn(strikeCell, 1);
                        cellRect.ClipInsideMap(base.Map);
                        IntVec3 randomCell = cellRect.RandomCell;
                        GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.2f, .6f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(3 + 3 * pwrVal, 7 + 5 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);
                    }
                }
            }
            GenExplosion.DoExplosion(this.ExactPosition.ToIntVec3(), base.Map, 1f + verVal, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + 5 * pwrVal, 10 + 10 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true);


            this.Destroy(DestroyMode.Vanish);
        }
Esempio n. 3
0
        public override void Impact_Override(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact_Override(hitThing);
            Pawn pawn = this.launcher as Pawn;

            if (pawn != null)
            {
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                if (comp.IsMagicUser)
                {
                    this.arcaneDmg = comp.arcaneDmg;
                }
            }

            bool flag = hitThing != null;

            if (flag)
            {
                int        DamageAmount = Mathf.RoundToInt(this.def.projectile.GetDamageAmount(1, null) * this.arcaneDmg);
                DamageInfo dinfo        = new DamageInfo(this.def.projectile.damageDef, DamageAmount, 0, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(dinfo);

                bool flag2 = this.canStartFire && Rand.Range(0f, 1f) > this.startFireChance;
                if (flag2)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                Pawn hitTarget;
                bool flag3 = (hitTarget = (hitThing as Pawn)) != null;
                if (flag3)
                {
                    this.PostImpactEffects(this.launcher as Pawn, hitTarget);
                    MoteMaker.ThrowMicroSparks(this.destination, base.Map);
                    MoteMaker.MakeStaticMote(this.destination, base.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                }
            }
            else
            {
                MoteMaker.MakeStaticMote(this.ExactPosition, base.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                MoteMaker.ThrowMicroSparks(this.ExactPosition, base.Map);
            }
            for (int i = 0; i <= 1; i++)
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None);
                //SoundDef.Named("TM_Thunder_OnMap");
            }
            CellRect cellRect = CellRect.CenteredOn(hitThing.Position, 2);

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < Rand.Range(1, 3); i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                this.StaticExplosion(randomCell, map, 0.4f);
            }
        }
Esempio n. 4
0
        protected override void ScatterAt(IntVec3 c, Map map, int stackCount = 1)
        {
            int      randomInRange1 = SettlementSizeRange.RandomInRange;
            int      randomInRange2 = SettlementSizeRange.RandomInRange;
            CellRect cellRect       = new CellRect(map.Center.x - (randomInRange1 / 2), map.Center.z - (randomInRange2 / 2), randomInRange1, randomInRange2);

            cellRect.ClipInsideMap(map);

            BaseGen.globalSettings.minBuildings = 1;
            BaseGen.globalSettings.minBarracks  = 1;
            BaseGen.symbolStack.Push("settlement", new ResolveParams
            {
                rect    = cellRect,
                faction = map.ParentFaction == null || map.ParentFaction == Faction.OfPlayer ? Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined) : map.ParentFaction
            });

            for (int i = 0; i < 3; i++)
            {
                if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(map.AllCells.Where(x => x.Walkable(map) && !x.Fogged(map)).RandomElement(), map, 25, out IntVec3 v))
                {
                    Log.Error("genstep: didnt find random cell " + i + "index");
                    return;
                }
                CellRect var  = CellRect.CenteredOn(v, 8, 8).ClipInsideMap(map);
                Pawn     pawn = map.Parent.GetComponent <PrisonerWillingToJoinComp>() == null || !map.Parent.GetComponent <PrisonerWillingToJoinComp>().pawn.Any ? PrisonerWillingToJoinQuestUtility.GeneratePrisoner(map.Tile, map.ParentFaction) : map.Parent.GetComponent <PrisonerWillingToJoinComp>().pawn.Take(map.Parent.GetComponent <PrisonerWillingToJoinComp>().pawn[0]);
                if (pawn.equipment != null && pawn.equipment.AllEquipmentListForReading.Count > 0)
                {
                    pawn.equipment.DestroyAllEquipment();
                }
                BaseGen.globalSettings.map = map;
                BaseGen.symbolStack.Push("prisonCell", new ResolveParams
                {
                    rect    = var,
                    faction = map.ParentFaction
                });
                BaseGen.Generate();
                pawn.guest.SetGuestStatus(map.ParentFaction, true);
                BaseGen.globalSettings.map = map;
                BaseGen.symbolStack.Push("pawn", new ResolveParams
                {
                    rect              = new CellRect(var.CenterCell.x, var.CenterCell.z, 1, 1).ClipInsideMap(map),
                    faction           = map.ParentFaction,
                    singlePawnToSpawn = pawn,
                    postThingSpawn    = x =>
                    {
                        MapGenerator.rootsToUnfog.Add(x.Position);
                        ((Pawn)x).mindState.WillJoinColonyIfRescued = true;
                    }
                });
                BaseGen.Generate();
                MapGenerator.SetVar("RectOfInterest", var);
                RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(x =>
                                                                       !x.Roofed(map) && x.IsValid, map, out IntVec3 k);
                k.ClampInsideMap(map);
                MapGenerator.rootsToUnfog.Add(k);
            }
        }
Esempio n. 5
0
        private static void CreateTrigger(Map map, string signalTag, CellRect notificationArea)
        {
            var rectTrigger = (RectTrigger)ThingMaker.MakeThing(ThingDefOf.RectTrigger);

            rectTrigger.signalTag         = signalTag;
            rectTrigger.Rect              = notificationArea.ClipInsideMap(map);
            rectTrigger.destroyIfUnfogged = false;
            GenSpawn.Spawn(rectTrigger, notificationArea.CenterCell, map);
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);

            Pawn pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningStorm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningStorm_pwr");
            MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningStorm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningStorm_ver");

            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
            pwrVal = pwr.level;
            verVal = ver.level;
            if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mpwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                MightPowerSkill mver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                pwrVal = mpwr.level;
                verVal = mver.level;
            }
            this.arcaneDmg = comp.arcaneDmg;
            if (settingsRef.AIHardMode && !pawn.IsColonist)
            {
                pwrVal = 3;
                verVal = 3;
            }

            duration = 480 + (verVal * 60);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 8);

            cellRect.ClipInsideMap(map);

            if (this.primed == true)
            {
                if (((this.boltDelay + this.lastStrike) < this.age))
                {
                    IntVec3 randomCell = cellRect.RandomCell;
                    if (randomCell.IsValid && randomCell.InBounds(base.Map))
                    {
                        Map.weatherManager.eventHandler.AddEvent(new WeatherEvent_LightningStrike(map, randomCell));
                        this.LightningBlast(pwrVal, randomCell, map, 2.2f);
                        strikeInt++;
                        this.lastStrike = this.age;
                        this.boltDelay  = Rand.Range(8 - (pwrVal), 40 - (pwrVal * 4));

                        bool flag1 = this.age <= duration;
                        if (!flag1)
                        {
                            this.primed = false;
                            map.weatherDecider.DisableRainFor(0);
                            map.weatherDecider.StartNextWeather();
                        }
                    }
                }
            }
        }
        protected override void ScatterAt(IntVec3 loc, Map map, int stackCount = 1)
        {
            int      randomInRange             = GenStep_ScatterShrines.ShrinesCountX.RandomInRange;
            int      randomInRange2            = GenStep_ScatterShrines.ShrinesCountZ.RandomInRange;
            int      randomInRange3            = GenStep_ScatterShrines.ExtraHeightRange.RandomInRange;
            IntVec2  standardAncientShrineSize = SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize;
            int      num  = 1;
            int      num2 = randomInRange * standardAncientShrineSize.x + (randomInRange - 1) * num;
            int      num3 = randomInRange2 * standardAncientShrineSize.z + (randomInRange2 - 1) * num;
            int      num4 = num2 + 2;
            int      num5 = num3 + 2 + randomInRange3;
            CellRect rect = new CellRect(loc.x, loc.z, num4, num5);

            rect.ClipInsideMap(map);
            if (rect.Width != num4 || rect.Height != num5)
            {
                return;
            }
            foreach (IntVec3 current in rect.Cells)
            {
                List <Thing> list = map.thingGrid.ThingsListAt(current);
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].def == ThingDefOf.AncientCryptosleepCasket)
                    {
                        return;
                    }
                }
            }
            if (!base.CanPlaceAncientBuildingInRange(rect, map))
            {
                return;
            }
            ResolveParams resolveParams = default(ResolveParams);

            resolveParams.rect = rect;
            resolveParams.disableSinglePawn           = new bool?(true);
            resolveParams.disableHives                = new bool?(true);
            resolveParams.ancientTempleEntranceHeight = new int?(randomInRange3);
            BaseGen.globalSettings.map                = map;
            BaseGen.symbolStack.Push("ancientTemple", resolveParams);
            BaseGen.Generate();
            int    nextSignalTagID = Find.UniqueIDsManager.GetNextSignalTagID();
            string signalTag       = "ancientTempleApproached-" + nextSignalTagID;
            SignalAction_Letter signalAction_Letter = (SignalAction_Letter)ThingMaker.MakeThing(ThingDefOf.SignalAction_Letter, null);

            signalAction_Letter.signalTag = signalTag;
            signalAction_Letter.letter    = LetterMaker.MakeLetter("LetterLabelAncientShrineWarning".Translate(), "AncientShrineWarning".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(rect.CenterCell, map, false));
            GenSpawn.Spawn(signalAction_Letter, rect.CenterCell, map);
            RectTrigger rectTrigger = (RectTrigger)ThingMaker.MakeThing(ThingDefOf.RectTrigger, null);

            rectTrigger.signalTag         = signalTag;
            rectTrigger.Rect              = rect.ExpandedBy(1).ClipInsideMap(map);
            rectTrigger.destroyIfUnfogged = true;
            GenSpawn.Spawn(rectTrigger, rect.CenterCell, map);
        }
Esempio n. 8
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            GenClamor.DoClamor(this, 5.1f, ClamorDefOf.Impact);
            if (initialized)
            {
                Destroy();
            }

            if (!initialized)
            {
                this.initialized = true;
                SpawnThings spawnThing = new SpawnThings();
                pawn = this.launcher as Pawn;
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonPoppi.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonPoppi_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonPoppi.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonPoppi_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal         = pwr.level;
                verVal         = ver.level;
                this.arcaneDmg = pawn.GetComp <CompAbilityUserMagic>().arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 1;
                    verVal = 1;
                }
                CellRect cellRect = CellRect.CenteredOn(this.Position, 4);
                cellRect.ClipInsideMap(map);

                IntVec3       centerCell = cellRect.CenterCell;
                System.Random random     = new System.Random();
                random = new System.Random();

                for (int i = 0; i < 4 + pwrVal; i++)
                {
                    centerCell = cellRect.RandomCell;
                    if (centerCell.IsValid && centerCell.InBounds(pawn.Map) && centerCell.Standable(pawn.Map) && !centerCell.Fogged(pawn.Map))
                    {
                        spawnThing.factionDef = TorannMagicDefOf.TM_ElementalFaction;
                        spawnThing.spawnCount = 1;
                        spawnThing.temporary  = false;

                        spawnThing.def     = TorannMagicDefOf.TM_Poppi;
                        spawnThing.kindDef = PawnKindDef.Named("TM_Poppi");

                        MoteMaker.ThrowSmoke(centerCell.ToVector3(), map, 1 + pwrVal);
                        SingleSpawnLoop(spawnThing, centerCell, map);
                    }
                    else
                    {
                        i--;
                    }
                }
            }
        }
Esempio n. 9
0
        public static bool DrawDynamicThings(DynamicDrawManager __instance)
        {
            if (!DebugViewSettings.drawThingsDynamic || null == map(__instance))
            {
                return(false);
            }
            drawingNow(__instance) = true;
            try
            {
                bool[]   fogGrid  = map(__instance).fogGrid.fogGrid;
                CellRect cellRect = Find.CameraDriver.CurrentViewRect;
                cellRect.ClipInsideMap(map(__instance));
                cellRect = cellRect.ExpandedBy(1);
                CellIndices cellIndices = map(__instance).cellIndices;
                SnowGrid    snowGrid    = map(__instance).snowGrid;

                /*
                 * RimThreaded.fogGrid = map(__instance).fogGrid.fogGrid;
                 * RimThreaded.cellRect = Find.CameraDriver.CurrentViewRect;
                 * RimThreaded.cellRect.ClipInsideMap(map(__instance));
                 * RimThreaded.cellRect = RimThreaded.cellRect.ExpandedBy(1);
                 * RimThreaded.cellIndices = map(__instance).cellIndices;
                 * RimThreaded.snowGrid = map(__instance).snowGrid;
                 * RimThreaded.drawQueue = new ConcurrentQueue<Thing>(drawThings(__instance));
                 * RimThreaded.startWorkerThreads();
                 */
                //Thing drawThing;
                //Thing[] drawThingsArray;

                //for (int index = 0; index < drawThingsArray.Length; index++)
                foreach (Thing drawThing in drawThings(__instance).ToList())
                {
                    //drawThing = drawThingsArray[index];
                    IntVec3 position = drawThing.Position;
                    if ((cellRect.Contains(position) || drawThing.def.drawOffscreen) && (!fogGrid[cellIndices.CellToIndex(position)] || drawThing.def.seeThroughFog) && ((double)drawThing.def.hideAtSnowDepth >= 1.0 || (double)snowGrid.GetDepth(position) <= (double)drawThing.def.hideAtSnowDepth))
                    {
                        try
                        {
                            drawThing.Draw();
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Exception drawing " + (object)drawThing + ": " + ex.ToString(), false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Exception drawing dynamic things: " + (object)ex, false);
            }
            drawingNow(__instance) = false;
            return(false);
        }
Esempio n. 10
0
        public static bool Prefix(ref CompPower __result, ref IntVec3 connectorPos, ref Map map, ref List <PowerNet> disallowedNets)
        {
            CellRect cellRect = CellRect.SingleCell(connectorPos).ExpandedBy(6).ClipInsideMap(map);
            float    num      = 999999f;

            cellRect.ClipInsideMap(map);
            __result = null;
            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3  c           = new IntVec3(j, 0, i);
                    Building transmitter = c.GetTransmitter(map);
                    if (transmitter != null && !transmitter.Destroyed)
                    {
                        CompPower powerComp = transmitter.PowerComp;
                        if (powerComp != null && powerComp.TransmitsPowerNow && (transmitter.def.building == null || transmitter.def.building.allowWireConnection))
                        {
                            if (disallowedNets == null || !disallowedNets.Contains(powerComp.transNet))
                            {
                                float num2 = (float)(transmitter.Position - connectorPos).LengthHorizontalSquared;
                                if (num2 < num)
                                {
                                    num      = num2;
                                    __result = powerComp;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (Thing thing in c.GetThingList(map))
                        {
                            if (thing.GetType() == typeof(Building_Steam))
                            {
                                Building  building  = (Building)thing;
                                CompPower powerComp = building.PowerComp;
                                if (powerComp != null &&
                                    (disallowedNets == null || !disallowedNets.Contains(powerComp.transNet)))
                                {
                                    float num2 = (building.Position - connectorPos).LengthHorizontalSquared;
                                    if (num2 < num)
                                    {
                                        num      = num2;
                                        __result = powerComp;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 11
0
        public void GetSmites(IntVec3 center, Map map)
        {
            CellRect cellRect = CellRect.CenteredOn(center, Mathf.RoundToInt(this.def.projectile.explosionRadius - 1));

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < this.strikeNum; i++)
            {
                this.smitePos.Add(cellRect.RandomCell);
                this.wrathAge.Add(Rand.Range(-(i * this.timeToSmite / (2 * strikeNum)), -(i * this.timeToSmite / strikeNum)));
            }
        }
Esempio n. 12
0
 public static void MarkHomeAroundThing(Thing t)
 {
     if (ShouldAdd())
     {
         CellRect cellRect = new CellRect(t.Position.x - t.RotatedSize.x / 2 - 4, t.Position.z - t.RotatedSize.z / 2 - 4, t.RotatedSize.x + 8, t.RotatedSize.z + 8);
         cellRect.ClipInsideMap(t.Map);
         foreach (IntVec3 item in cellRect)
         {
             t.Map.areaManager.Home[item] = true;
         }
     }
 }
Esempio n. 13
0
        public void Initialize(Map map)
        {
            pawn = this.launcher as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwr      = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Blizzard.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Blizzard_pwr");
            ver      = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Blizzard.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Blizzard_ver");
            cellRect = CellRect.CenteredOn(base.Position, (int)(base.def.projectile.explosionRadius + (.75 * (ver.level + pwr.level))));
            cellRect.ClipInsideMap(map);
            duration    = duration + (90 * ver.level);
            initialized = true;
        }
Esempio n. 14
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.damageAmountBase, SoundDefOf.ArtilleryShellLoaded, def, this.equipmentDef, null, 0f, 1, false, null, 0f, 1, 0f, true);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 6);

            cellRect.ClipInsideMap(map);
        }
Esempio n. 15
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def      = this.def;
            CellRect cellRect = CellRect.CenteredOn(base.Position, 1);

            cellRect.ClipInsideMap(map);

            IntVec3    c = cellRect.CenterCell;
            TerrainDef terrain;
            float      radius = this.def.projectile.explosionRadius;
            IntVec3    curCell;

            if (map.Biome != BiomeDefOf.SeaIce)
            {
                IEnumerable <IntVec3> cells = GenRadial.RadialCellsAround(c, radius, true);
                for (int i = 0; i < cells.Count(); i++)
                {
                    curCell = cells.ToArray <IntVec3>()[i];
                    terrain = curCell.GetTerrain(map);
                    if (curCell.InBounds(map) && curCell.IsValid && terrain.driesTo != null)
                    {
                        if (terrain.defName == "MarshyTerrain" || terrain.defName == "Mud" || terrain.defName == "Marsh")
                        {
                            map.terrainGrid.SetTerrain(curCell, terrain.driesTo);
                        }
                        else if (terrain.defName == "WaterShallow")
                        {
                            map.terrainGrid.SetTerrain(curCell, TerrainDef.Named("Marsh"));
                        }
                        else if (terrain.defName == "Ice")
                        {
                            map.terrainGrid.SetTerrain(curCell, TerrainDef.Named("Mud"));
                        }
                        else
                        {
                            //Messages.Message("TerraformFailed".Translate(), MessageTypeDefOf.RejectInput);
                        }
                        for (int m = 0; m < 4; m++)
                        {
                            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), curCell.ToVector3Shifted(), map, Rand.Range(.3f, .5f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(.5f, 1f), Rand.Range(0, 360), Rand.Range(0, 360));
                        }
                    }
                }
            }
            else
            {
                Messages.Message("NotRightTerrainType".Translate(), MessageTypeDefOf.RejectInput);
            }
        }
        // Token: 0x06000028 RID: 40 RVA: 0x00005058 File Offset: 0x00003258
        private void ScatterRuinAt(IntVec3 loc, bool placeWell, Map map, ref ThingDef wallStuff)
        {
            var randomInRange  = ruinOffsetHorizontalRange.RandomInRange;
            var randomInRange2 = ruinOffsetVerticalRange.RandomInRange;
            var num            = randomInRange + 2;
            var num2           = randomInRange2 + 2;
            var mapRect        = new CellRect(loc.x, loc.z, num, num2);

            mapRect.ClipInsideMap(map);
            if (mapRect.Width != num || mapRect.Height != num2)
            {
                return;
            }

            foreach (var intVec in mapRect.Cells)
            {
                var list = map.thingGrid.ThingsListAt(intVec);
                foreach (var thing in list)
                {
                    if (thing.def == ThingDefOf.AncientCryptosleepCasket)
                    {
                        return;
                    }
                }

                usedCells.Add(intVec);
                usedSpots.Add(intVec);
            }

            if (wallStuff == null)
            {
                wallStuff = RandomWallStuff();
            }

            if (placeWell)
            {
                MakeWell(mapRect, wallStuff, map);
            }
            else
            {
                if (ruinsHaveBigHoles)
                {
                    MakeShed(mapRect, wallStuff, map, true, true);
                }
                else
                {
                    MakeShed(mapRect, wallStuff, map, Rand.Value > 0.5f);
                }
            }
        }
Esempio n. 17
0
        public static void Notify_BuildingSpawned(Thing b)
        {
            if (!AutoHomeAreaMaker.ShouldAdd() || !b.def.building.expandHomeArea || b.Faction != Faction.OfPlayer)
            {
                return;
            }
            CellRect cellRect = new CellRect(b.Position.x - b.RotatedSize.x / 2 - 4, b.Position.z - b.RotatedSize.z / 2 - 4, b.RotatedSize.x + 8, b.RotatedSize.z + 8);

            cellRect.ClipInsideMap(b.Map);
            foreach (IntVec3 current in cellRect)
            {
                b.Map.areaManager.Home[current] = true;
            }
        }
Esempio n. 18
0
        public override void WindowOnGUI()
        {
            base.WindowOnGUI();

            if (FloodThing != null && Input.GetKeyDown(KeyCode.Mouse0))
            {
                CellRect cellRect2 = CellRect.CenteredOn(UI.MouseCell(), BrushSize);
                cellRect2.ClipInsideMap(Find.CurrentMap);
                foreach (IntVec3 item7 in cellRect2)
                {
                    GenSpawn.Spawn(FloodThing, item7, Find.CurrentMap);
                }
            }
        }
Esempio n. 19
0
        public override void WindowOnGUI()
        {
            base.WindowOnGUI();

            if (FloodTerrain != null && Input.GetKeyDown(KeyCode.Mouse0))
            {
                CellRect cellRect2 = CellRect.CenteredOn(UI.MouseCell(), BrushSize);
                cellRect2.ClipInsideMap(Find.CurrentMap);
                foreach (IntVec3 item7 in cellRect2)
                {
                    Find.CurrentMap.terrainGrid.SetTerrain(item7, FloodTerrain);
                }
            }
        }
Esempio n. 20
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def    = this.def;
            Pawn     victim = hitThing as Pawn;
            Thing    item   = hitThing as Thing;
            IntVec3  arg_pos_1;
            IntVec3  arg_pos_2;
            IntVec3  arg_pos_3;

            Pawn pawn = this.launcher as Pawn;

            comp = pawn.GetComp <CompAbilityUserMagic>();

            CellRect cellRect = CellRect.CenteredOn(base.Position, 1);

            cellRect.ClipInsideMap(map);
            IntVec3 centerCell = cellRect.CenterCell;

            if (!this.primed)
            {
                arg_pos_1 = centerCell;
                if ((arg_pos_1.IsValid && arg_pos_1.Standable(map)))
                {
                    AbilityUser.SpawnThings tempPod = new SpawnThings();
                    IntVec3 shiftPos = centerCell;
                    centerCell.x++;
                    tempPod.def        = ThingDef.Named("TM_Sunlight");
                    tempPod.spawnCount = 1;
                    try
                    {
                        this.SingleSpawnLoop(tempPod, shiftPos, map);
                    }
                    catch
                    {
                        Log.Message("Attempted to create a sunlight but threw an unknown exception - recovering and ending attempt");
                        return;
                    }

                    this.primed = true;
                }
                else
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_Sunlight));
                }
            }
        }
Esempio n. 21
0
        protected override void Impact(Thing hitThing)
        {
            Pawn caster = this.launcher as Pawn;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, (int)(this.def.projectile.GetDamageAmount(1, null) * comp.arcaneDmg), 0, SoundDefOf.Artillery_ShellLoaded, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 6);

            cellRect.ClipInsideMap(map);
        }
Esempio n. 22
0
        public static void MarkHomeAroundThing(Thing t)
        {
            if (!AutoHomeAreaMaker.ShouldAdd())
            {
                return;
            }
            CellRect cellRect = new CellRect(t.Position.x - t.RotatedSize.x / 2 - 4, t.Position.z - t.RotatedSize.z / 2 - 4, t.RotatedSize.x + 8, t.RotatedSize.z + 8);

            cellRect.ClipInsideMap(t.Map);
            foreach (IntVec3 current in cellRect)
            {
                t.Map.areaManager.Home[current] = true;
            }
        }
Esempio n. 23
0
        public static IEnumerable <IntVec3> GetRandomCellSampleAround(Thing t, int numberOfSamples, int distance)
        {
            IntVec3  center = t.Position;
            CellRect area   = new CellRect(center.x - distance, center.z - distance, distance * 2, distance * 2);

            if (!area.InBounds(t.Map))
            {
                area = area.ClipInsideMap(t.Map);
            }
            for (int i = 0; i < numberOfSamples; i++)
            {
                yield return(area.RandomCell);
            }
        }
Esempio n. 24
0
        public override void Impact_Override(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact_Override(hitThing);
            Pawn pawn = this.launcher as Pawn;


            bool flag = hitThing != null;

            if (flag)
            {
                int        DamageAmount = this.def.projectile.GetDamageAmount(1, null);
                DamageInfo dinfo        = new DamageInfo(this.def.projectile.damageDef, DamageAmount, .25f, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(dinfo);

                bool flag2 = this.canStartFire && Rand.Range(0f, 1f) > this.startFireChance;
                if (flag2)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                Pawn hitTarget;
                bool flag3 = (hitTarget = (hitThing as Pawn)) != null;
                if (flag3)
                {
                    this.PostImpactEffects(this.launcher as Pawn, hitTarget);
                    FleckMaker.Static(this.destination, base.Map, FleckDefOf.MicroSparks);
                    FleckMaker.Static(this.destination, base.Map, FleckDefOf.ShotHit_Dirt);
                }
            }
            else
            {
                FleckMaker.Static(this.ExactPosition, base.Map, FleckDefOf.ShotHit_Dirt);
                FleckMaker.Static(this.ExactPosition, base.Map, FleckDefOf.MicroSparks);
            }
            for (int i = 0; i <= 1; i++)
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None);
                SoundDefOf.Thunder_OnMap.PlayOneShot(info);
            }
            CellRect cellRect = CellRect.CenteredOn(hitThing.Position, 2);

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < Rand.Range(1, 8); i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                this.StaticExplosion(randomCell, map, 0.4f);
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            GenExplosion.DoExplosion(base.Position, map, base.def.projectile.explosionRadius, DamageDefOf.Bomb, base.launcher, base.DamageAmount, base.ArmorPenetration, null, base.equipmentDef, base.def, postExplosionSpawnThingDef: ThingDefOf.Filth_Fuel, intendedTarget: intendedTarget.Thing, postExplosionSpawnChance: 0.2f, postExplosionSpawnThingCount: 1, applyDamageToExplosionCellsNeighbors: false, preExplosionSpawnThingDef: null, preExplosionSpawnChance: 0f, preExplosionSpawnThingCount: 1, chanceToStartFire: 0.4f);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 5);

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < 3; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                DoFireExplosion(randomCell, map, 3.9f);
            }
        }
        public static bool TryFindRandomCellNearWith(IntVec3 near, Predicate <IntVec3> validator, Map map, out IntVec3 result, int startingSearchRadius = 5, int maxSearchRadius = 2147483647)
        {
            int      num      = startingSearchRadius;
            CellRect cellRect = CellRect.CenteredOn(near, num);

            cellRect.ClipInsideMap(map);
            int     num2 = 0;
            IntVec3 randomCell;

            while (true)
            {
                num2++;
                if (num2 > 30)
                {
                    if (num >= maxSearchRadius || (num > map.Size.x * 2 && num > map.Size.z * 2))
                    {
                        break;
                    }
                    num      = Mathf.Min((int)((float)num * 1.5f), maxSearchRadius);
                    cellRect = CellRect.CenteredOn(near, num);
                    cellRect.ClipInsideMap(map);
                    num2 = 0;
                }
                randomCell = cellRect.RandomCell;
                if (validator(randomCell))
                {
                    goto IL_9B;
                }
            }
            result = near;
            return(false);

IL_9B:
            result = randomCell;
            return(true);
        }
        // Token: 0x060000DE RID: 222 RVA: 0x00006F5C File Offset: 0x0000515C
        public static bool CanBuildOnTerrain(BuildableDef entDef, IntVec3 c, Map map, Rot4 rot, Thing thingToIgnore = null, ThingDef stuffDef = null)
        {
            bool flag = entDef is TerrainDef && !c.GetTerrain(map).changeable;
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                TerrainAffordanceDef terrainAffordanceNeed = entDef.GetTerrainAffordanceNeed(stuffDef);
                bool flag2 = terrainAffordanceNeed != null;
                if (flag2)
                {
                    CellRect cellRect = GenAdj.OccupiedRect(c, rot, entDef.Size);
                    cellRect.ClipInsideMap(map);
                    foreach (IntVec3 c2 in cellRect)
                    {
                        bool flag3 = !map.terrainGrid.TerrainAt(c2).affordances.Contains(terrainAffordanceNeed);
                        if (flag3)
                        {
                            return(false);
                        }
                        List <Thing> thingList = c2.GetThingList(map);
                        for (int i = 0; i < thingList.Count; i++)
                        {
                            bool flag4 = thingList[i] != thingToIgnore;
                            if (flag4)
                            {
                                TerrainDef terrainDef = thingList[i].def.entityDefToBuild as TerrainDef;
                                bool       flag5      = terrainDef != null && !terrainDef.affordances.Contains(terrainAffordanceNeed);
                                if (flag5)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    result = true;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);

            ThingDef def = this.def;

            GenExplosion.DoExplosion(Position, Map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, launcher, -1, -1, null, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 3);

            cellRect.ClipInsideMap(base.Map);
            for (int i = 0; i < 5; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                this.IceExplosion(randomCell, 2.9f);
            }
        }
Esempio n. 29
0
        protected override void Impact(Thing hitThing)
        {
            GenExplosion.DoExplosion(base.Position, this.Map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, def.projectile.GetDamageAmount(1f),
                                     -1, null, this.def, this.equipmentDef, null);
            SnowCreation(base.Position, this.def.projectile.explosionRadius, this.Map);
            CellRect cellRect = CellRect.CenteredOn(base.Position, 3);

            cellRect.ClipInsideMap(this.Map);
            for (int i = 0; i < Rand.RangeInclusive(3, 6); i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                IceExplosion(randomCell, 2.9f, this.Map);
            }

            base.Impact(hitThing);
        }
Esempio n. 30
0
        private static IntVec3 FindSandbagRoot(Map map)
        {
            CellRect cellRect = CellRect.CenteredOn(SiegeBlueprintPlacer.center, 13);

            cellRect.ClipInsideMap(map);
            CellRect cellRect2 = CellRect.CenteredOn(SiegeBlueprintPlacer.center, 8);

            cellRect2.ClipInsideMap(map);
            int     num = 0;
            IntVec3 randomCell;

            for (;;)
            {
                num++;
                if (num > 200)
                {
                    break;
                }
                randomCell = cellRect.RandomCell;
                if (!cellRect2.Contains(randomCell))
                {
                    if (map.reachability.CanReach(randomCell, SiegeBlueprintPlacer.center, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Deadly))
                    {
                        if (SiegeBlueprintPlacer.CanPlaceBlueprintAt(randomCell, Rot4.North, ThingDefOf.Sandbags, map))
                        {
                            bool flag = false;
                            for (int i = 0; i < SiegeBlueprintPlacer.placedSandbagLocs.Count; i++)
                            {
                                float num2 = (float)(SiegeBlueprintPlacer.placedSandbagLocs[i] - randomCell).LengthHorizontalSquared;
                                if (num2 < 36f)
                                {
                                    flag = true;
                                }
                            }
                            if (!flag)
                            {
                                goto IL_104;
                            }
                        }
                    }
                }
            }
            return(IntVec3.Invalid);

IL_104:
            return(randomCell);
        }