public static void ThrowSmokeRed(Vector3 loc, float size) { if (!loc.ShouldSpawnMotesAt() || MoteCounter.SaturatedLowPriority) { return; } MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_SmokeRed"), null); moteThrown.ScaleUniform = Rand.Range(1.5f, 2.5f) * size; moteThrown.exactRotationRate = Rand.Range(-0.5f, 0.5f); moteThrown.exactPosition = loc; moteThrown.SetVelocityAngleSpeed((float)Rand.Range(30, 40), Rand.Range(0.008f, 0.012f)); GenSpawn.Spawn(moteThrown, loc.ToIntVec3()); }
public static void ThrowLightningGlowGreen(Vector3 loc, float size) { if (!loc.ShouldSpawnMotesAt()) { return; } MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(DefDatabase<ThingDef>.GetNamed("Mote_LightningGlowGreen", true), null); moteThrown.ScaleUniform = 6f * size; moteThrown.exactRotationRate = 0f; moteThrown.exactPosition = loc; moteThrown.exactPosition += new Vector3(0.5f, 0f, 0.5f); //moteThrown.SetVelocityAngleSpeed((float)Rand.Range(0, 0), Rand.Range(0.0002f, 0.0002f)); GenSpawn.Spawn(moteThrown, loc.ToIntVec3()); }
public static void ThrowMicroSparksRed(Vector3 loc) { if (!loc.ShouldSpawnMotesAt() || MoteCounter.Saturated) { return; } MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_MicroSparksRed"), null); moteThrown.ScaleUniform = Rand.Range(0.8f, 1.2f); moteThrown.exactRotationRate = Rand.Range(-0.2f, 0.2f); moteThrown.exactPosition = loc; moteThrown.exactPosition -= new Vector3(0.5f, 0f, 0.5f); moteThrown.exactPosition += new Vector3(Rand.Value, 0f, Rand.Value); moteThrown.SetVelocityAngleSpeed((float)Rand.Range(35, 45), Rand.Range(0.02f, 0.02f)); GenSpawn.Spawn(moteThrown, loc.ToIntVec3()); }
protected override bool TryCastShot() { bool flag10 = 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); } for (int i = 0; i < this.TargetsAoE.Count; i++) { bool?flag3 = this.TryLaunchProjectile(this.verbProps.defaultProjectile, this.TargetsAoE[i]); bool hasValue = flag3.HasValue; if (hasValue) { bool flag4 = flag3 == true; if (flag4) { flag10 = true; } bool flag5 = flag3 == false; if (flag5) { flag10 = false; } } } CellRect cellRect = CellRect.CenteredOn(this.currentTarget.Cell, 1); Map map = caster.Map; cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; Thing summonableThing = new Thing(); FlyingObject summonablePawn = new FlyingObject(); dinfo.SetAmount(10); dinfo.SetWeaponHediff(TorannMagicDefOf.TM_GrapplingHook); bool pflag = true; summonableThing = centerCell.GetFirstPawn(map); if (summonableThing == null) { pflag = false; //miss } else { pVect = summonableThing.TrueCenter(); pVect.x = base.caster.TrueCenter().x; pVect.z = base.caster.TrueCenter().z; pVect.y = 0f; Pawn victim = summonableThing as Pawn; if (victim != null) { if (!victim.IsColonist && !victim.IsPrisoner && !victim.Faction.HostileTo(this.CasterPawn.Faction) && victim.Faction != null && victim.RaceProps.Humanlike) { Faction faction = victim.Faction; faction.TrySetRelationKind(this.CasterPawn.Faction, FactionRelationKind.Ally, false, null); } } summonablePawn = (FlyingObject)GenSpawn.Spawn(ThingDef.Named("TM_SummonedPawn"), summonableThing.Position, summonableThing.Map); } bool result = false; bool arg_40_0; if (this.currentTarget != null && base.caster != null) { IntVec3 arg_29_0 = this.currentTarget.Cell; arg_40_0 = this.caster.Position.IsValid; } else { arg_40_0 = false; } bool flag = arg_40_0; if (flag) { if (summonableThing != null) { if (pflag) { summonablePawn.impactDamage = dinfo; summonablePawn.Launch(base.caster, new LocalTargetInfo(pVect.ToIntVec3()), summonableThing); } else { //miss } result = true; } } else { Log.Warning("failed to TryCastShot"); } //this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; this.PostCastShot(flag10, out flag10); return(flag); }
public override void DoWindowContents(Rect inRect) { var style = new GUIStyle(Text.CurFontStyle) { fontSize = 16, alignment = TextAnchor.MiddleCenter }; var moveRect = new Rect(4f, 4f, 18f, 18f); DSGUI.Elements.DrawIconFitted(moveRect, DragHash, Color.white, 1.1f); var titleX = moveRect.x + moveRect.width + 32f; var titleWidth = inRect.width - 60f - titleX; var titleRect = new Rect(titleX, 1f, titleWidth, 25f); if (DSGUI.Elements.ButtonInvisibleLabeledFree(Color.white, GameFont.Medium, titleRect, _self.Label.CapitalizeFirst(), style)) { if (_pawn.Map != _self.Map) { return; } Find.Selector.ClearSelection(); Find.Selector.Select(_self); Find.WindowStack.TryRemove(typeof(DSGUI_ListModal)); } if (Mouse.IsOver(titleRect)) { Widgets.DrawHighlight(titleRect); } DSGUI.Elements.SeparatorVertical(moveRect.x + moveRect.width + 32f, 0f, titleRect.height + 3f); DSGUI.Elements.SeparatorVertical(inRect.width - 28f - 32f, 0f, titleRect.height + 3f); inRect = inRect.ContractedBy(16f); var innerRect = inRect; innerRect.y += 8f; innerRect.height -= 16f; gizmoListRect = innerRect.AtZero(); gizmoListRect.y += _scrollPosition.y; // Scrollable List var scrollRect = new Rect(innerRect); scrollRect.y += 3f; scrollRect.x += 8f; scrollRect.height -= 50f; scrollRect.width -= 16f; var viewRect = new Rect(0.0f, 0.0f, scrollRect.width, _recipesScrollHeight); Widgets.BeginScrollView(scrollRect, ref _scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < _thingList.Count; i++) { var viewElement = new Rect(0.0f, _boxHeight * i, inRect.width, _boxHeight); if (!viewElement.Overlaps(gizmoListRect)) { continue; } if (rows[i] == null) { try { // TODO: Move the entire ThingList trickery into its own function var index = _pawn.Map.cellIndices.CellToIndex(cpos.ToIntVec3()); var listArray = (List <Thing>[])ThingListTG.GetValue(_pawn.Map.thingGrid); var origList = new List <Thing>(listArray[index]); listArray[index] = new List <Thing> { _thingList[i] }; rows[i] = new DSGUI_ListItem(_pawn, _thingList[i], cpos, _boxHeight); listArray[index] = origList; } catch (Exception ex) { var rect5 = scrollRect.ContractedBy(-4f); Widgets.Label(rect5, "Oops, something went wrong!"); Log.Warning(ex.ToString()); } } if (_searchString.NullOrEmpty()) { rows[i].DoDraw(viewRect, i); } else { if (!(rows[i].Label.IndexOf(_searchString, StringComparison.OrdinalIgnoreCase) >= 0)) { continue; } rows[i].DoDraw(viewRect, i); } } _recipesScrollHeight = _boxHeight * _thingList.Count; GUI.EndGroup(); Widgets.EndScrollView(); Widgets.DrawBox(scrollRect); var bottomToolRect = new Rect(scrollRect); bottomToolRect.y += scrollRect.height + 16f; bottomToolRect.height = 28f; // Search var clearRect = new Rect(bottomToolRect) { width = 28f }; Text.Anchor = TextAnchor.MiddleLeft; if (DSGUI.Elements.ButtonImageFittedScaled(clearRect, Widgets.CheckboxOffTex, 0.9f)) { _searchString = ""; } var searchFieldRect = new Rect(bottomToolRect); searchFieldRect.x += 28f + SearchClearPadding; searchFieldRect.width -= 56f + SearchClearPadding * 2; DSGUI.Elements.InputField("Search", searchFieldRect, ref _searchString); var actionRect = new Rect(bottomToolRect) { x = bottomToolRect.x + bottomToolRect.width - 28f, width = 28f }; if (orders.Count > 0) { if (DSGUI.Elements.ButtonImageFittedScaled(actionRect, MenuIcon, 1.4f)) { DSGUI.Elements.TryMakeFloatMenu(orders, "DSGUI_List_Tile".TranslateSimple()); } } else { DSGUI.Elements.DrawIconFitted(actionRect, MenuIcon, Color.gray, 1.4f); TooltipHandler.TipRegion(actionRect, "No Orders Available"); } if (Mouse.IsOver(actionRect)) { Widgets.DrawHighlight(actionRect); } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; }
private void Dig(IntVec3 start, float dir, float width, List <IntVec3> group, Map map, bool closed, HashSet <IntVec3> visited = null) { Vector3 vector = start.ToVector3Shifted(); IntVec3 intVec = start; float num = 0f; MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid caves = MapGenerator.Caves; bool flag = false; bool flag2 = false; if (visited == null) { visited = new HashSet <IntVec3>(); } GenStep_Caves.tmpGroupSet.Clear(); GenStep_Caves.tmpGroupSet.AddRange(group); int num2 = 0; while (true) { if (closed) { int num3 = GenRadial.NumCellsInRadius((float)(width / 2.0 + 1.5)); for (int i = 0; i < num3; i++) { IntVec3 intVec2 = intVec + GenRadial.RadialPattern[i]; if (!visited.Contains(intVec2)) { if (!GenStep_Caves.tmpGroupSet.Contains(intVec2)) { return; } if (caves[intVec2] > 0.0) { return; } } } } if (num2 >= 15) { float num4 = width; FloatRange branchedTunnelWidthOffset = GenStep_Caves.BranchedTunnelWidthOffset; if (num4 > 1.3999999761581421 + branchedTunnelWidthOffset.max) { if (!flag && Rand.Chance(0.1f)) { this.DigInBestDirection(intVec, dir, new FloatRange(40f, 90f), width - GenStep_Caves.BranchedTunnelWidthOffset.RandomInRange, group, map, closed, visited); flag = true; } if (!flag2 && Rand.Chance(0.1f)) { this.DigInBestDirection(intVec, dir, new FloatRange(-90f, -40f), width - GenStep_Caves.BranchedTunnelWidthOffset.RandomInRange, group, map, closed, visited); flag2 = true; } } } bool flag3 = default(bool); this.SetCaveAround(intVec, width, map, visited, out flag3); if (!flag3) { while (vector.ToIntVec3() == intVec) { vector += Vector3Utility.FromAngleFlat(dir) * 0.5f; num = (float)(num + 0.5); } if (GenStep_Caves.tmpGroupSet.Contains(vector.ToIntVec3())) { int x = intVec.x; IntVec3 intVec3 = vector.ToIntVec3(); IntVec3 intVec4 = new IntVec3(x, 0, intVec3.z); if (this.IsRock(intVec4, elevation, map)) { caves[intVec4] = Mathf.Max(caves[intVec4], width); visited.Add(intVec4); } intVec = vector.ToIntVec3(); dir = (float)(dir + (float)this.directionNoise.GetValue(num * 60.0, (float)start.x * 200.0, (float)start.z * 200.0) * 8.0); width = (float)(width - 0.034000001847743988); if (!(width < 1.3999999761581421)) { num2++; continue; } } } break; } }
public static bool AllowedMoteSpawn(this Vector3 vector3, Map map) { return(vector3.ToIntVec3().ShouldSpawnMotesAt(map) && !map.moteCounter.SaturatedLowPriority); }
public void NotifyLevelDown() { // Do text message on screen on level down. if (Settings.allowLevelDownTextMessage) { Color color = Color.red; string pawn = CurrentPawn.LabelShortCap.Bold(); string skill = SkillRecord.def.skillLabel.Italic(); string level = SkillRecord.levelInt.ToString().Bold().Colored(color); string levelDesc = SkillRecord.LevelDescriptor; string label; if (Settings.levelDescLevelDownLabel) { label = "LevelDownLabelLong".Translate(pawn, level, skill, levelDesc); } else { label = "LevelDownLabel".Translate(pawn, level, skill); } LookTargets lookTargets = new LookTargets(CurrentPawn); Messages.Message(label, lookTargets, MessageTypeDefOf.SilentInput); } if (Settings.allowLevelDownLetter) { string pawn = CurrentPawn.LabelShortCap; string skill = SkillRecord.def.skillLabel; string level = SkillRecord.levelInt.ToString(); string labelShort = "LevelDownLabelShort".Translate(pawn); string label = "LevelDownLabel".Translate(pawn, level, skill); LookTargets lookTargets = new LookTargets(CurrentPawn); Find.LetterStack.ReceiveLetter(labelShort, label, LetterDefOf.NegativeEvent, lookTargets); } // Do sound effect on level down. if (Settings.allowLevelDownSoundEffect) { DefHandler.LevelDown.PlayOneShot(SoundInfo.InMap(new TargetInfo(CurrentPawn))); } // Do animation on pawn levelling down. if (!Settings.allowLevelDownAnimation) { return; } // Animation motes. Vector3 pawnPosition = CurrentPawn.Drawer.DrawPos; Map map = CurrentPawn.Map; if (!pawnPosition.ToIntVec3().ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority) { return; } MoteThrown topMote = (MoteThrown)ThingMaker.MakeThing(DefHandler.Mote_LevelDownBeamTop); topMote.Attach(new TargetInfo(CurrentPawn)); topMote.Scale = 1.5f; topMote.exactPosition = CurrentPawn.Drawer.DrawPos; topMote.SetVelocity(180, 0.1f); GenSpawn.Spawn(topMote, pawnPosition.ToIntVec3(), map); MoteThrown bottomMote = (MoteThrown)ThingMaker.MakeThing(DefHandler.Mote_LevelDownBeamBottom); bottomMote.Attach(new TargetInfo(CurrentPawn)); bottomMote.Scale = 1.5f; bottomMote.exactPosition = CurrentPawn.Drawer.DrawPos; bottomMote.SetVelocity(180, 0.1f); GenSpawn.Spawn(bottomMote, pawnPosition.ToIntVec3(), map); }
private static void Impact(ProjectileCE __instance, Thing launcher, ThingDef equipmentDef, Thing hitThing, IntVec3 OriginIV3, Vector2 origin, Vector2 Destination, int StartingTicksToImpact, int ticksToImpact, int IntTicksToImpact, ref float suppressionAmount) { List <Thing> list = new List <Thing>(); if (__instance.Position.IsValid && __instance.def.projectile.preExplosionSpawnChance > 0f && __instance.def.projectile.preExplosionSpawnThingDef != null && (Controller.settings.EnableAmmoSystem || !(__instance.def.projectile.preExplosionSpawnThingDef is AmmoDef)) && Rand.Value < __instance.def.projectile.preExplosionSpawnChance) { ThingDef preExplosionSpawnThingDef = __instance.def.projectile.preExplosionSpawnThingDef; if (preExplosionSpawnThingDef.IsFilth && __instance.Position.Walkable(__instance.Map)) { FilthMaker.TryMakeFilth(__instance.Position, __instance.Map, preExplosionSpawnThingDef, 1, FilthSourceFlags.None); } else { bool reuseNeolithicProjectiles = Controller.settings.ReuseNeolithicProjectiles; if (reuseNeolithicProjectiles) { Thing thing = ThingMaker.MakeThing(preExplosionSpawnThingDef, null); thing.stackCount = 1; thing.SetForbidden(true, false); GenPlace.TryPlaceThing(thing, __instance.Position, __instance.Map, ThingPlaceMode.Near, null, null, default(Rot4)); LessonAutoActivator.TeachOpportunity(CE_ConceptDefOf.CE_ReusableNeolithicProjectiles, thing, OpportunityType.GoodToKnow); list.Add(thing); } } } Vector3 vector = (hitThing != null) ? hitThing.DrawPos : __instance.ExactPosition; bool flag3 = !vector.ToIntVec3().IsValid; if (flag3) { __instance.Destroy(DestroyMode.Vanish); } else { CompExplosiveCE compExplosiveCE = __instance.TryGetCompFast <CompExplosiveCE>(); if (compExplosiveCE == null) { CompFragments compFragments = __instance.TryGetCompFast <CompFragments>(); if (compFragments != null) { compFragments.Throw(vector, __instance.Map, launcher, 1f); } } if (compExplosiveCE != null || __instance.def.projectile.explosionRadius > 0f) { if (hitThing is Pawn && (hitThing as Pawn).Dead) { list.Add((hitThing as Pawn).Corpse); } List <Pawn> list2 = new List <Pawn>(); float? direction = new float?(origin.AngleTo(Vec2Position(__instance, origin, Destination, StartingTicksToImpact, ticksToImpact, IntTicksToImpact, -1f))); bool flag7 = __instance.def.projectile.explosionRadius > 0f; if (flag7) { GenExplosionCE.DoExplosion(vector.ToIntVec3(), __instance.Map, __instance.def.projectile.explosionRadius, __instance.def.projectile.damageDef, launcher, __instance.def.projectile.GetDamageAmount(1f, null), GenExplosionCE.GetExplosionAP(__instance.def.projectile), __instance.def.projectile.soundExplode, equipmentDef, __instance.def, null, __instance.def.projectile.postExplosionSpawnThingDef, __instance.def.projectile.postExplosionSpawnChance, __instance.def.projectile.postExplosionSpawnThingCount, __instance.def.projectile.applyDamageToExplosionCellsNeighbors, __instance.def.projectile.preExplosionSpawnThingDef, __instance.def.projectile.preExplosionSpawnChance, __instance.def.projectile.preExplosionSpawnThingCount, __instance.def.projectile.explosionChanceToStartFire, __instance.def.projectile.explosionDamageFalloff, direction, list, vector.y, 1f, false, null); bool flag8 = vector.y < 3f; if (flag8) { list2.AddRange(from x in GenRadial.RadialDistinctThingsAround(vector.ToIntVec3(), __instance.Map, 3f + __instance.def.projectile.explosionRadius, true) where x is Pawn select x as Pawn); } } bool flag9 = compExplosiveCE != null; if (flag9) { compExplosiveCE.Explode(__instance, vector, __instance.Map, 1f, direction, list); bool flag10 = vector.y < 3f; if (flag10) { list2.AddRange(from x in GenRadial.RadialDistinctThingsAround(vector.ToIntVec3(), __instance.Map, 3f + (compExplosiveCE.props as CompProperties_ExplosiveCE).explosiveRadius, true) where x is Pawn select x as Pawn); } } foreach (Pawn pawn in list2) { ApplySuppression(__instance, OriginIV3, pawn, launcher, ref suppressionAmount); } } __instance.Destroy(DestroyMode.Vanish); } }
public void ActivateMatrixAbsorbtionEffect(Vector3 absorbtionPosition) { if ((absorbtionPosition.ToIntVec3() == this.coveredCells[0]) || (absorbtionPosition.ToIntVec3() == this.coveredCells[1])) { this.matrixIsStartingAbsorbion[0] = true; } else if ((absorbtionPosition.ToIntVec3() == this.coveredCells[2]) || (absorbtionPosition.ToIntVec3() == this.coveredCells[3])) { this.matrixIsStartingAbsorbion[1] = true; } else if ((absorbtionPosition.ToIntVec3() == this.coveredCells[4]) || (absorbtionPosition.ToIntVec3() == this.coveredCells[5])) { this.matrixIsStartingAbsorbion[2] = true; } else if ((absorbtionPosition.ToIntVec3() == this.coveredCells[6]) || (absorbtionPosition.ToIntVec3() == this.coveredCells[7])) { this.matrixIsStartingAbsorbion[3] = true; } else if ((absorbtionPosition.ToIntVec3() == this.coveredCells[8]) || (absorbtionPosition.ToIntVec3() == this.coveredCells[9])) { this.matrixIsStartingAbsorbion[4] = true; } }
public override void Tick() { base.Tick(); age++; var unused = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { ticksToImpact++; Position = ExactPosition.ToIntVec3(); Destroy(); } else if (!ExactPosition.ToIntVec3().Walkable(Map)) { earlyImpact = true; impactForce = (DestinationCell - ExactPosition.ToIntVec3()).LengthHorizontal + (speed * .2f); ImpactSomething(); } else { Position = ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % 3 == 0) { FleckMaker.ThrowDustPuff(Position, Map, Rand.Range(0.8f, 1f)); rotation++; if (rotation >= 4) { rotation = 0; } var comp = pawn.GetComp <CompWizardry>(); if (comp.SecondTarget != null && !secondTarget) { origin = ExactPosition; if (comp.SecondTarget.Thing != null) { destination = comp.SecondTarget.Thing.Position.ToVector3Shifted(); assignedTarget = comp.SecondTarget.Thing; } else { destination = comp.SecondTarget.CenterVector3; } speed = 22f; ticksToImpact = StartingTicksToImpact; flyingDirection = GetVector(origin.ToIntVec3(), destination.ToIntVec3()); comp.SecondTarget = null; secondTarget = true; } } if (Find.TickManager.TicksGame % 12 == 0 && secondTarget) { DoFlyingObjectDamage(); } if (ticksToImpact > 0) { return; } if (age > duration || secondTarget) { if (DestinationCell.InBounds(Map)) { Position = DestinationCell; } ImpactSomething(); } else { origin = destination; speed = 5f; if (floatDir == 0) { destination.x += -.25f; destination.z += .25f; } else if (floatDir == 1) { destination.x += .25f; destination.z += .25f; } else if (floatDir == 2) { destination.x += .25f; destination.z += -.25f; } else { destination.x += -.25f; destination.z += -.25f; } floatDir++; if (floatDir > 3) { floatDir = 0; } ticksToImpact = StartingTicksToImpact; } } }
private void UpdateLord() { IntVec3 rallyPoint = IntVec3.Invalid; // Check there is no already existing defense lord. if ((Find.LordManager.lords != null) && (Find.LordManager.lords.Count > 0)) { foreach (Lord lord in Find.LordManager.lords) { if ((lord.faction != null) && (lord.faction == OG_Util.FactionOfMiningCo)) { return; } } } // Look for hostile in outpost perimeter. IntVec3 hostilePosition = FindHostileInPerimeter(); if (hostilePosition.IsValid) { Area outpostArea = OG_Util.FindOutpostArea(); if ((outpostArea != null) && (outpostArea.ActiveCells.Contains(hostilePosition))) { // Ennemy is inside outpost area. rallyPoint = hostilePosition; } else { const int sectionsNumber = 100; Vector3 sectionVector = (this.outpostCenter - hostilePosition).ToVector3(); sectionVector = sectionVector / sectionsNumber; // Default value if OutpostArea does not exist (should not occur, just a safety...). rallyPoint = (hostilePosition.ToVector3() + sectionVector * 0.2f * (float)sectionsNumber).ToIntVec3(); for (int i = 1; i <= sectionsNumber; i++) { Vector3 potentialRallyPoint = hostilePosition.ToVector3() + sectionVector * i; if ((outpostArea != null) && (outpostArea.ActiveCells.Contains(potentialRallyPoint.ToIntVec3()))) { // Ensure rallyPoint is completely inside the outpost area. rallyPoint = (potentialRallyPoint + sectionVector * 0.1f * (float)sectionsNumber).ToIntVec3(); break; } } } } else { // Look for damaged turret to defend. Rot4 turretRotation = Rot4.Invalid; IntVec3 turretPosition = IntVec3.Invalid; FindDamagedTurret(out turretPosition, out turretRotation); if (turretPosition.IsValid) { if (OG_Util.IsModActive("MiningCo. ForceField")) { // Look for nearest force field to cover behind. foreach (Thing thing in Find.ListerThings.ThingsOfDef(OG_Util.ForceFieldGeneratorDef)) { if (thing.Position.InHorDistOf(turretPosition, 23f)) { rallyPoint = thing.Position + new IntVec3(0, 0, -2).RotatedBy(thing.Rotation); break; } } } else { // Just go near the attacked turret. rallyPoint = turretPosition + new IntVec3(0, 0, -5).RotatedBy(turretRotation); } } } if (rallyPoint.IsValid) { // Generate defense lord. LordJob_Joinable_DefendOutpost lordJob = new LordJob_Joinable_DefendOutpost(rallyPoint); LordMaker.MakeNewLord(OG_Util.FactionOfMiningCo, lordJob); SoundDef soundDef = SoundDefOf.MessageSeriousAlert; // TODO: add a siren like in alert speaker! soundDef.PlayOneShot(rallyPoint); // Stop all pawns job. foreach (Pawn pawn in Find.MapPawns.AllPawns) { if ((pawn.Faction != null) && (pawn.Faction == OG_Util.FactionOfMiningCo) && (pawn.kindDef != OG_Util.OutpostTechnicianDef)) { pawn.ClearMind(); } } } }
public static bool ShouldSpawnMotesAt(this Vector3 loc, Map map) { return(loc.ToIntVec3().ShouldSpawnMotesAt(map)); }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); if (intVec2 == intVec) { return(false); } if (intVec.InBounds(base.Map) && intVec2.InBounds(base.Map)) { if (intVec2.AdjacentToCardinal(intVec)) { bool flag = this.CheckForFreeIntercept(intVec2); if (DebugViewSettings.drawInterceptChecks) { if (flag) { MoteMaker.ThrowText(intVec2.ToVector3Shifted(), base.Map, "x", -1f); } else { MoteMaker.ThrowText(intVec2.ToVector3Shifted(), base.Map, "o", -1f); } } return(flag); } if ((float)this.origin.ToIntVec3().DistanceToSquared(intVec2) > 16.0) { Vector3 vector = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 b = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.20000000298023224); Projectile.checkedCells.Clear(); int num2 = 0; while (true) { vector += b; IntVec3 intVec3 = vector.ToIntVec3(); if (!Projectile.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { if (DebugViewSettings.drawInterceptChecks) { MoteMaker.ThrowText(vector, base.Map, "x", -1f); } return(true); } Projectile.checkedCells.Add(intVec3); } if (DebugViewSettings.drawInterceptChecks) { MoteMaker.ThrowText(vector, base.Map, "o", -1f); } num2++; if (num2 > num) { return(false); } if (intVec3 == intVec2) { break; } } return(false); } return(false); } return(false); }
private bool CheckForFreeIntercept(IntVec3 c) { if (destination.ToIntVec3() == c) { return(false); } float num = VerbUtility.InterceptChanceFactorFromDistance(origin, c); if (num <= 0f) { return(false); } bool flag = false; List <Thing> thingList = c.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (!CanHit(thing)) { continue; } bool flag2 = false; if (thing.def.Fillage == FillCategory.Full) { Building_Door building_Door = thing as Building_Door; if (building_Door == null || !building_Door.Open) { ThrowDebugText("int-wall", c); Impact(thing); return(true); } flag2 = true; } float num2 = 0f; Pawn pawn = thing as Pawn; if (pawn != null) { num2 = 0.4f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != 0) { num2 *= 0.1f; } if (launcher != null && pawn.Faction != null && launcher.Faction != null && !pawn.Faction.HostileTo(launcher.Faction)) { num2 *= 0.4f; } } else if (thing.def.fillPercent > 0.2f) { num2 = (flag2 ? 0.05f : ((!DestinationCell.AdjacentTo8Way(c)) ? (thing.def.fillPercent * 0.15f) : (thing.def.fillPercent * 1f))); } num2 *= num; if (num2 > 1E-05f) { if (Rand.Chance(num2)) { ThrowDebugText("int-" + num2.ToStringPercent(), c); Impact(thing); return(true); } flag = true; ThrowDebugText(num2.ToStringPercent(), c); } } if (!flag) { ThrowDebugText("o", c); } return(false); }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { if (lastExactPos == newExactPos) { return(false); } List <Thing> list = base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ProjectileInterceptor); for (int i = 0; i < list.Count; i++) { if (list[i].TryGetComp <CompProjectileInterceptor>().CheckIntercept(this, lastExactPos, newExactPos)) { Destroy(); return(true); } } IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); if (intVec2 == intVec) { return(false); } if (!intVec.InBounds(base.Map) || !intVec2.InBounds(base.Map)) { return(false); } if (intVec2.AdjacentToCardinal(intVec)) { return(CheckForFreeIntercept(intVec2)); } if (VerbUtility.InterceptChanceFactorFromDistance(origin, intVec2) <= 0f) { return(false); } Vector3 vect = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 vector = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.2f); checkedCells.Clear(); int num2 = 0; IntVec3 intVec3; do { vect += vector; intVec3 = vect.ToIntVec3(); if (!checkedCells.Contains(intVec3)) { if (CheckForFreeIntercept(intVec3)) { return(true); } checkedCells.Add(intVec3); } num2++; if (num2 > num) { return(false); } }while (!(intVec3 == intVec2)); return(false); }
private void Dig(IntVec3 start, float dir, float width, List <IntVec3> group, Map map, bool closed, HashSet <IntVec3> visited = null) { Vector3 vector = start.ToVector3Shifted(); IntVec3 intVec = start; float num = 0f; MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid caves = MapGenerator.Caves; bool flag = false; bool flag2 = false; if (visited == null) { visited = new HashSet <IntVec3>(); } GenStep_Caves.tmpGroupSet.Clear(); GenStep_Caves.tmpGroupSet.AddRange(group); int num2 = 0; while (true) { if (closed) { int num3 = GenRadial.NumCellsInRadius(width / 2f + 1.5f); for (int i = 0; i < num3; i++) { IntVec3 intVec2 = intVec + GenRadial.RadialPattern[i]; if (!visited.Contains(intVec2)) { if (!GenStep_Caves.tmpGroupSet.Contains(intVec2) || caves[intVec2] > 0f) { return; } } } } if (num2 >= 15 && width > 1.4f + GenStep_Caves.BranchedTunnelWidthOffset.max) { if (!flag && Rand.Chance(0.1f)) { this.DigInBestDirection(intVec, dir, new FloatRange(40f, 90f), width - GenStep_Caves.BranchedTunnelWidthOffset.RandomInRange, group, map, closed, visited); flag = true; } if (!flag2 && Rand.Chance(0.1f)) { this.DigInBestDirection(intVec, dir, new FloatRange(-90f, -40f), width - GenStep_Caves.BranchedTunnelWidthOffset.RandomInRange, group, map, closed, visited); flag2 = true; } } bool flag3; this.SetCaveAround(intVec, width, map, visited, out flag3); if (flag3) { return; } while (vector.ToIntVec3() == intVec) { vector += Vector3Utility.FromAngleFlat(dir) * 0.5f; num += 0.5f; } if (!GenStep_Caves.tmpGroupSet.Contains(vector.ToIntVec3())) { return; } IntVec3 intVec3 = new IntVec3(intVec.x, 0, vector.ToIntVec3().z); if (this.IsRock(intVec3, elevation, map)) { caves[intVec3] = Mathf.Max(caves[intVec3], width); visited.Add(intVec3); } intVec = vector.ToIntVec3(); dir += (float)this.directionNoise.GetValue((double)(num * 60f), (double)((float)start.x * 200f), (double)((float)start.z * 200f)) * 8f; width -= 0.034f; if (width < 1.4f) { return; } num2++; } }
public override void Spawn(Map map, Vector3 position, float angle) { sound.PlayOneShot(new TargetInfo(position.ToIntVec3(), map, false)); }
public void ImpactEffects(Vector3 pos, Map map, ThingDef explosionMoteDef, float ExplosionMoteSize, Color?color, SoundDef sound, FleckDef ImpactMoteDef, float ImpactMoteSize, FleckDef ImpactGlowMoteDef, float ImpactGlowMoteSize, Thing hitThing = null, Thing projectile = null, int OverrideSolidTime = -1) { Rand.PushState(); FleckDef impactMoteDef = ImpactMoteDef ?? this.ImpactMoteDef; float rotationRate = Rand.Range(-30f, 30f); float VelocityAngel = (float)Rand.Range(0, 360); float VelocitySpeed = Rand.Range(0.48f, 0.72f); Rand.PopState(); if (ImpactGlowMoteDef != null) { try { AdeptusFleckMaker.ThrowGlow(pos, map, ImpactGlowMoteSize, ImpactGlowMoteDef); /* * mote.instanceColor.r = color.Value.r * 0.25f; * mote.instanceColor.g = color.Value.g * 0.25f; * mote.instanceColor.b = color.Value.b * 0.25f; */ } catch (System.Exception) { // Log.Message("Waaah "+ projectile + " ImpactGlowMoteDef broke Vs " + hitThing); } } if (explosionMoteDef != null) { try { Vector3 loc = pos; loc.y = explosionMoteDef.Altitude; MoteThrown moteThrown; moteThrown = (MoteThrown)ThingMaker.MakeThing(explosionMoteDef, null); moteThrown.Scale = ExplosionMoteSize; Rand.PushState(); moteThrown.rotationRate = Rand.Range(-30f, 30f); Rand.PopState(); moteThrown.exactPosition = loc; moteThrown.instanceColor = color.Value; moteThrown.SetVelocity(VelocityAngel, VelocitySpeed); if (OverrideSolidTime > -1) { moteThrown.solidTimeOverride = OverrideSolidTime; } GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish); } catch (System.Exception) { // Log.Message("Waaah " + projectile + " explosionMoteDef broke Vs " + hitThing); } } if (ImpactMoteDef != null) { try { Vector3 loc = pos; if (hitThing != null && hitThing is Pawn pawn) { impactMoteDef = DefDatabase <FleckDef> .GetNamedSilentFail("AdeptusMechanicus_Mote_Blood_Puff"); if (sound != null) { sound.PlayOneShot(new TargetInfo(loc.ToIntVec3(), map, false)); } AdeptusFleckMaker.Thrown(loc, map, impactMoteDef, ImpactMoteSize, pawn.RaceProps.BloodDef?.graphic.color, null, Rand.Range(-30f, 30f), OverrideSolidTime > -1 ? (float?)OverrideSolidTime : null, VelocityAngel, VelocitySpeed); } else { Color c = Color.white; if (color.HasValue) { c.r = color.Value.r * 0.25f; c.g = color.Value.g * 0.25f; c.b = color.Value.b * 0.25f; } AdeptusFleckMaker.Thrown(loc, map, impactMoteDef, ImpactGlowMoteSize, c, null, Rand.Range(-30f, 30f), OverrideSolidTime > -1 ? (float?)OverrideSolidTime : null, VelocityAngel, VelocitySpeed); } } catch (System.Exception) { // Log.Message("Waaah " + projectile + " ImpactMoteDef broke Vs "+hitThing); } } }
private static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { var cell = clickPos.ToIntVec3(); if (pawn.equipment != null) { foreach (var equipment in cell.GetThingList(pawn.Map).OfType <ThingWithComps>().Where(t => t.TryGetComp <CompEquippable>() != null).Skip(1)) { var labelShort = equipment.LabelShort; FloatMenuOption option; if (equipment.def.IsWeapon && pawn.WorkTagIsDisabled(WorkTags.Violent)) { option = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort, pawn) + ")", null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly)) { option = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { option = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null); } else if (equipment.IsBurning()) { option = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "BurningLower".Translate() + ")", null); } else { string text5 = "Equip".Translate(labelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text5 = text5 + " " + "EquipWarningBrawler".Translate(); } option = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text5, delegate { equipment.SetForbidden(false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Equip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High), pawn, equipment); } opts.Add(option); } } if (pawn.apparel != null) { foreach (var apparel in cell.GetThingList(pawn.Map).OfType <Apparel>().Skip(1)) { FloatMenuOption option; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly)) { option = new FloatMenuOption("CannotWear".Translate(apparel.Label, apparel) + " (" + "NoPath".Translate() + ")", null); } else if (apparel.IsBurning()) { option = new FloatMenuOption("CannotWear".Translate(apparel.Label, apparel) + " (" + "BurningLower".Translate() + ")", null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { option = new FloatMenuOption("CannotWear".Translate(apparel.Label, apparel) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null); } else { option = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("ForceWear".Translate(apparel.LabelShort, apparel), delegate { apparel.SetForbidden(false); var job = JobMaker.MakeJob(JobDefOf.Wear, apparel); pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High), pawn, apparel); } opts.Add(option); } } }
public void ImpactEffects(Vector3 pos, Map map, ThingDef explosionMoteDef, float ExplosionMoteSize, Color?color, SoundDef sound, ThingDef ImpactMoteDef, float ImpactMoteSize, ThingDef ImpactGlowMoteDef, float ImpactGlowMoteSize, Thing hitThing = null, Thing projectile = null, int OverrideSolidTime = -1) { Rand.PushState(); ThingDef impactMoteDef = ImpactMoteDef ?? this.ImpactMoteDef; float rotationRate = Rand.Range(-30f, 30f); float VelocityAngel = (float)Rand.Range(0, 360); float VelocitySpeed = Rand.Range(0.48f, 0.72f); Rand.PopState(); if (ImpactGlowMoteDef != null) { try { Vector3 loc = pos; // loc.y = ImpactGlowMoteDef.Altitude; loc.y -= 0.001f; Mote mote = (Mote)ThingMaker.MakeThing(ImpactGlowMoteDef, null); mote.exactPosition = loc; mote.Scale = ImpactGlowMoteSize; /* * mote.instanceColor.r = color.Value.r * 0.25f; * mote.instanceColor.g = color.Value.g * 0.25f; * mote.instanceColor.b = color.Value.b * 0.25f; */ GenSpawn.Spawn(mote, loc.ToIntVec3(), map, WipeMode.Vanish); } catch (System.Exception) { Log.Message("Waaah " + projectile + " ImpactGlowMoteDef broke Vs " + hitThing); } } if (explosionMoteDef != null) { try { Vector3 loc = pos; loc.y = explosionMoteDef.Altitude; MoteThrown moteThrown; moteThrown = (MoteThrown)ThingMaker.MakeThing(explosionMoteDef, null); moteThrown.Scale = ExplosionMoteSize; Rand.PushState(); moteThrown.rotationRate = Rand.Range(-30f, 30f); Rand.PopState(); moteThrown.exactPosition = loc; moteThrown.instanceColor = color.Value; moteThrown.SetVelocity(VelocityAngel, VelocitySpeed); if (OverrideSolidTime > -1) { moteThrown.solidTimeOverride = OverrideSolidTime; } GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish); } catch (System.Exception) { Log.Message("Waaah " + projectile + " explosionMoteDef broke Vs " + hitThing); } } if (ImpactMoteDef != null) { try { Vector3 loc = pos; if (hitThing != null && hitThing is Pawn pawn) { impactMoteDef = ThingDef.Named("AdeptusMechanicus_Mote_Blood_Puff"); if (sound != null) { sound.PlayOneShot(new TargetInfo(loc.ToIntVec3(), map, false)); } loc.y = impactMoteDef.Altitude; MoteThrown moteThrown; moteThrown = (MoteThrown)ThingMaker.MakeThing(impactMoteDef, null); moteThrown.Scale = ImpactMoteSize; Rand.PushState(); moteThrown.rotationRate = Rand.Range(-30f, 30f); Rand.PopState(); moteThrown.exactPosition = loc; if (OverrideSolidTime > -1) { moteThrown.solidTimeOverride = OverrideSolidTime; } if (pawn.RaceProps.BloodDef != null) { moteThrown.instanceColor = pawn.RaceProps.BloodDef.graphic.color; } moteThrown.SetVelocity(VelocityAngel, VelocitySpeed); GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish); } else { loc.y = impactMoteDef.Altitude; Mote mote = (Mote)ThingMaker.MakeThing(impactMoteDef, null); mote.exactPosition = loc; mote.Scale = ImpactGlowMoteSize; mote.instanceColor.r = color.Value.r * 0.25f; mote.instanceColor.g = color.Value.g * 0.25f; mote.instanceColor.b = color.Value.b * 0.25f; if (OverrideSolidTime > -1) { mote.solidTimeOverride = OverrideSolidTime; } GenSpawn.Spawn(mote, loc.ToIntVec3(), map, WipeMode.Vanish); } } catch (System.Exception) { Log.Message("Waaah " + projectile + " ImpactMoteDef broke Vs " + hitThing); } } }
protected override bool TryCastShot() { CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>(); MightPowerSkill ver = comp.MightData.MightPowerSkill_SeismicSlash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SeismicSlash_ver"); pwrVal = TM_Calc.GetMightSkillLevel(this.CasterPawn, comp.MightData.MightPowerSkill_SeismicSlash, "TM_SeismicSlash", "_pwr", true); CellRect cellRect = CellRect.CenteredOn(base.CasterPawn.Position, 1); Map map = base.CasterPawn.Map; cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; this.origin = base.CasterPawn.Position.ToVector3(); this.destination = this.currentTarget.Cell.ToVector3Shifted(); this.ticksToImpact = Mathf.RoundToInt((this.origin - this.destination).magnitude); if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon) { TMAbilityDef ad = (TMAbilityDef)this.Ability.Def; int dmgNum = Mathf.RoundToInt(comp.weaponDamage * ad.weaponDamageFactor * (1 + (.1f * pwrVal))); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode) { dmgNum += 10; } Vector3 strikeVec = this.origin; DrawBlade(strikeVec, 0); for (int i = 0; i < this.StartingTicksToImpact; i++) { strikeVec = this.ExactPosition; Pawn victim = strikeVec.ToIntVec3().GetFirstPawn(map); if (victim != null && victim.Faction != base.CasterPawn.Faction) { DrawStrike(strikeVec.ToIntVec3(), strikeVec, map); damageEntities(victim, null, dmgNum, DamageDefOf.Cut); } float angle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.CasterPawn.DrawPos, this.currentTarget.CenterVector3)).ToAngleFlat(); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_DirectionalDirt"), strikeVec, this.CasterPawn.Map, .3f + (.08f * i), .05f, .15f, .38f, 0, 5f - (.2f * i), angle, angle); if (i == 2) { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Cleave"), strikeVec, this.CasterPawn.Map, .6f + (.05f * i), .05f, .04f + (.03f * i), .15f, -10000, 30, angle, angle); } //MoteMaker.ThrowTornadoDustPuff(strikeVec, map, .6f, Color.white); for (int j = 0; j < 2 + (2 * verVal); j++) { IntVec3 searchCell = strikeVec.ToIntVec3() + GenAdj.AdjacentCells8WayRandomized()[j]; TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_DirectionalDirt"), searchCell.ToVector3Shifted(), this.CasterPawn.Map, .1f + (.04f * i), .05f, .04f, .28f, 0, 4f - (.2f * i), angle, angle); //MoteMaker.ThrowTornadoDustPuff(searchCell.ToVector3(), map, .4f, Color.gray); victim = searchCell.GetFirstPawn(map); if (victim != null && victim.Faction != base.CasterPawn.Faction) { DrawStrike(searchCell, searchCell.ToVector3(), map); damageEntities(victim, null, dmgNum, DamageDefOf.Cut); } } this.ticksToImpact--; } } else { Messages.Message("MustHaveMeleeWeapon".Translate( this.CasterPawn.LabelCap ), MessageTypeDefOf.RejectInput); return(false); } this.burstShotsLeft = 0; this.PostCastShot(flag10, out flag10); return(flag10); }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); bool result; if (intVec2 == intVec) { result = false; } else if (!intVec.InBounds(base.Map) || !intVec2.InBounds(base.Map)) { result = false; } else if (intVec2.AdjacentToCardinal(intVec)) { result = this.CheckForFreeIntercept(intVec2); } else if (VerbUtility.DistanceInterceptChance(this.origin, intVec2, this.intendedTarget.Cell) > 0f) { Vector3 vector = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 b = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.2f); Projectile.checkedCells.Clear(); int num2 = 0; for (;;) { vector += b; IntVec3 intVec3 = vector.ToIntVec3(); if (!Projectile.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { break; } Projectile.checkedCells.Add(intVec3); } num2++; if (num2 > num) { goto Block_7; } if (intVec3 == intVec2) { goto Block_8; } } return(true); Block_7: return(false); Block_8: result = false; } else { result = false; } return(result); }
public void NotifyLevelUp() { // Do text message on screen on level up. if (Settings.allowLevelUpTextMessage) { Color color = Color.yellow; string pawn = CurrentPawn.LabelShortCap.Bold(); string skill = SkillRecord.def.skillLabel.Italic(); string level = SkillRecord.levelInt.ToString().Bold().Colored(color); string levelDesc = SkillRecord.LevelDescriptor; string label; if (Settings.levelDescLevelUpLabel) { label = "LevelUpLabelLong".Translate(pawn, level, skill, levelDesc); } else { label = "LevelUpLabel".Translate(pawn, level, skill); } LookTargets lookTargets = new LookTargets(CurrentPawn); Messages.Message(label, lookTargets, MessageTypeDefOf.SilentInput); } if (Settings.allowLevelUpLetter) { string pawn = CurrentPawn.LabelShortCap; string skill = SkillRecord.def.skillLabel; string level = SkillRecord.levelInt.ToString(); string labelShort = "LevelUpLabelShort".Translate(pawn); string label = "LevelUpLabel".Translate(pawn, level, skill); LookTargets lookTargets = new LookTargets(CurrentPawn); Find.LetterStack.ReceiveLetter(labelShort, label, LetterDefOf.PositiveEvent, lookTargets); } // Do sound effect on level up. if (Settings.allowLevelUpSoundEffect) { DefHandler.GetSound(Settings.LvlUpSound).PlayOneShot(SoundInfo.InMap(new TargetInfo(CurrentPawn))); } // Do animation on pawn levelling up. if (!Settings.allowLevelUpAnimation) { return; } // Animation motes. Using three similar ones on top of each other to achieve stretch effect. Vector3 pawnPosition = CurrentPawn.Drawer.DrawPos; Map map = CurrentPawn.Map; if (!pawnPosition.ToIntVec3().ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority) { return; } MoteThrown innerMote = MakeMote(DefHandler.Mote_LevelUpBeamInner, CurrentPawn); innerMote.SetVelocity(0, 0.6f); GenSpawn.Spawn(innerMote, pawnPosition.ToIntVec3(), map); MoteThrown middleMote1 = MakeMote(DefHandler.Mote_LevelUpBeamMiddle, CurrentPawn); middleMote1.SetVelocity(0, 0.3f); GenSpawn.Spawn(middleMote1, pawnPosition.ToIntVec3(), map); MoteThrown middleMote2 = MakeMote(DefHandler.Mote_LevelUpBeamMiddle, CurrentPawn); middleMote2.SetVelocity(0, 0.5f); GenSpawn.Spawn(middleMote2, pawnPosition.ToIntVec3(), map); MoteThrown outerMote1 = MakeMote(DefHandler.Mote_LevelUpBeamOuter, CurrentPawn); outerMote1.SetVelocity(0, 0.15f); GenSpawn.Spawn(outerMote1, pawnPosition.ToIntVec3(), map); MoteThrown outerMote2 = MakeMote(DefHandler.Mote_LevelUpBeamOuter, CurrentPawn); outerMote2.SetVelocity(0, 0.25f); GenSpawn.Spawn(outerMote2, pawnPosition.ToIntVec3(), map); }
public override void DrawAt(Vector3 drawLoc, bool flip = false) { DrawGhost_NewTmp(drawLoc.ToIntVec3(), placingMode: false, base.Rotation); }
// Token: 0x06000142 RID: 322 RVA: 0x0000B97C File Offset: 0x00009B7C public void WeaponTick(int weaponIndex, WeaponDef weaponDef) { bool flag = weaponDef.ammoDef != null && this.weaponRemainingRounds[weaponIndex] == -1 && this.shipToTargetDistance <= weaponDef.startShootingDistance; if (flag) { this.weaponRemainingRounds[weaponIndex] = weaponDef.ammoQuantity; this.weaponNextShotTick[weaponIndex] = Find.TickManager.TicksGame; int num = Rand.RangeInclusive(0, 1); bool flag2 = num == 1; if (flag2) { this.weaponShootRight[weaponIndex] = true; } else { this.weaponShootRight[weaponIndex] = false; } bool flag3 = weaponDef.disableRainDurationInTicks > 0; if (flag3) { base.Map.weatherDecider.DisableRainFor(weaponDef.disableRainDurationInTicks); } } bool flag4 = this.weaponRemainingRounds[weaponIndex] > 0 && Find.TickManager.TicksGame >= this.weaponNextShotTick[weaponIndex]; if (flag4) { bool flag5 = !weaponDef.isTwinGun || this.weaponShootRight[weaponIndex]; float num2; if (flag5) { num2 = 1f; } else { num2 = -1f; } Vector3 vector = this.spaceshipExactPosition + new Vector3(num2 * weaponDef.horizontalPositionOffset, 0f, weaponDef.verticalPositionOffset).RotatedBy(this.spaceshipExactRotation); Vector3 vector2 = vector + new Vector3(0f, 0f, weaponDef.ammoTravelDistance).RotatedBy(this.spaceshipExactRotation); bool flag6 = vector.InBounds(base.Map) && vector2.InBounds(base.Map); if (flag6) { Projectile projectile = GenSpawn.Spawn(weaponDef.ammoDef, vector.ToIntVec3(), base.Map, WipeMode.Vanish) as Projectile; bool flag7 = weaponDef.soundCastDef != null; if (flag7) { weaponDef.soundCastDef.PlayOneShot(new TargetInfo(vector.ToIntVec3(), base.Map, false)); } AdeptusMoteMaker.MakeStaticMote(vector, base.Map, ThingDefOf.Mote_ShotFlash, 10f); Pawn pawn = null; bool flag8 = weaponDef.targetAcquireRange > 0f; if (flag8) { pawn = this.GetRandomeHostilePawnAround(vector2, weaponDef.targetAcquireRange); } bool flag9 = pawn != null; if (flag9) { projectile.Launch(this, vector, pawn, pawn, ProjectileHitFlags.IntendedTarget, this, null); } else { vector2 += new Vector3(Rand.Range(-weaponDef.targetAcquireRange, weaponDef.targetAcquireRange), 0f, 0f).RotatedBy(this.spaceshipExactRotation); projectile.Launch(this, vector, vector2.ToIntVec3(), vector2.ToIntVec3(), ProjectileHitFlags.None, this, null); } } List <int> list = this.weaponRemainingRounds; int num3 = list[weaponIndex]; list[weaponIndex] = num3 - 1; this.weaponNextShotTick[weaponIndex] = Find.TickManager.TicksGame + weaponDef.ticksBetweenShots; this.weaponShootRight[weaponIndex] = !this.weaponShootRight[weaponIndex]; } }
// Token: 0x06002080 RID: 8320 RVA: 0x000C6E58 File Offset: 0x000C5058 protected void MakeMote(CompTurretGun A, TargetInfo B) { Vector3 vector = Vector3.zero; switch (this.def.spawnLocType) { case MoteSpawnLocType.OnSource: vector = A.TurretPos; break; case MoteSpawnLocType.BetweenPositions: { Vector3 vector2 = A.IsOperated ? A.TurretPos : A.parent.DrawPos; Vector3 vector3 = B.HasThing ? B.Thing.DrawPos : B.Cell.ToVector3Shifted(); if (A.IsOperated && !A.Operator.Spawned) { vector = vector3; } else if (B.HasThing && !B.Thing.Spawned) { vector = vector2; } else { vector = vector2 * this.def.positionLerpFactor + vector3 * (1f - this.def.positionLerpFactor); } break; } case MoteSpawnLocType.BetweenTouchingCells: vector = A.Operator.Position.ToVector3Shifted() + (B.Cell - A.Operator.Position).ToVector3().normalized * 0.5f; break; case MoteSpawnLocType.RandomCellOnTarget: { CellRect cellRect; if (B.HasThing) { cellRect = B.Thing.OccupiedRect(); } else { cellRect = CellRect.CenteredOn(B.Cell, 0); } vector = cellRect.RandomCell.ToVector3Shifted(); break; } } if (this.parent != null) { Rand.PushState(this.parent.GetHashCode()); if (A.TurretPos != B.CenterVector3) { vector += (B.CenterVector3 - A.TurretPos).normalized * this.parent.def.offsetTowardsTarget.RandomInRange; } vector += Gen.RandomHorizontalVector(this.parent.def.positionRadius) + this.parent.offset; Rand.PopState(); } Map map = A.Operator.Map ?? B.Map; float num = this.def.absoluteAngle ? 0f : (B.Cell - A.Operator.Position).AngleFlat; float num2 = (this.parent != null) ? this.parent.scale : 1f; if (map != null && vector.ShouldSpawnMotesAt(map)) { int randomInRange = this.def.burstCount.RandomInRange; for (int i = 0; i < randomInRange; i++) { Mote mote = (Mote)ThingMaker.MakeThing(this.def.moteDef, null); GenSpawn.Spawn(mote, vector.ToIntVec3(), map, WipeMode.Vanish); mote.Scale = this.def.scale.RandomInRange * num2; mote.exactPosition = vector + this.def.positionOffset * num2 + Gen.RandomHorizontalVector(this.def.positionRadius) * num2; mote.rotationRate = this.def.rotationRate.RandomInRange; mote.exactRotation = this.def.rotation.RandomInRange + num; mote.instanceColor = this.def.color; MoteThrown moteThrown = mote as MoteThrown; if (moteThrown != null) { moteThrown.airTimeLeft = this.def.airTime.RandomInRange; moteThrown.SetVelocity(this.def.angle.RandomInRange + num, this.def.speed.RandomInRange); } } } }
/// <summary> /// Produces a secondary explosion on impact using the explosion values from the projectile's projectile def. Requires the projectile's launcher to be passed on due to protection level. /// Intended use is for HEAT and similar weapons that spawn secondary explosions while also penetrating, NOT explosive ammo of anti-materiel rifles as the explosion just spawns /// on top of the pawn, not inside the hit body part. /// /// Additionally handles fragmentation effects if defined. /// </summary> /// <param name="instigator">Launcher of the projectile calling the method</param> public virtual void Explode(Thing instigator, Vector3 pos, Map map, float scaleFactor = 1) { var posIV = pos.ToIntVec3(); if (map == null) { Log.Warning("Tried to do explodeCE in a null map."); return; } if (!posIV.InBounds(map)) { Log.Warning("Tried to explodeCE out of bounds"); return; } var projCE = parent as ProjectileCE; #region Fragmentation if (!Props.fragments.NullOrEmpty()) { float edificeHeight = (new CollisionVertical(posIV.GetEdifice(map))).Max; Vector2 exactOrigin = new Vector2(pos.x, pos.z); float height; //Fragments fly from a 0 to 45 degree angle away from the explosion var range = new FloatRange(0, Mathf.PI / 8f); if (projCE != null) { height = Mathf.Max(edificeHeight, pos.y); if (edificeHeight < height) { //If the projectile exploded above the ground, they can fly 45 degree away at the bottom as well range.min = -Mathf.PI / 8f; } // TODO : Check for hitting the bottom or top of a roof } else { //Height is not tracked on non-CE projectiles, so we assume this one's on top of the edifice height = edificeHeight; } foreach (ThingCountClass fragment in Props.fragments) { for (int i = 0; i < fragment.count; i++) { ProjectileCE projectile = (ProjectileCE)ThingMaker.MakeThing(fragment.thingDef, null); GenSpawn.Spawn(projectile, posIV, map); projectile.canTargetSelf = true; projectile.minCollisionSqr = 1f; //TODO : Don't hardcode at FragmentShadowChance, make XML-modifiable projectile.castShadow = (UnityEngine.Random.value < FragmentShadowChance); projectile.logMisses = false; projectile.Launch( instigator, exactOrigin, range.RandomInRange, UnityEngine.Random.Range(0, 360), height, Props.fragSpeedFactor * projectile.def.projectile.speed, projCE ); } } } #endregion // Regular explosion stuff if (Props.explosionRadius > 0 && Props.explosionDamage > 0 && parent.def != null && GenGrid.InBounds(posIV, map)) { // Copy-paste from GenExplosion ExplosionCE explosion = GenSpawn.Spawn(CE_ThingDefOf.ExplosionCE, posIV, map) as ExplosionCE; explosion.height = pos.y; explosion.radius = Props.explosionRadius * scaleFactor; explosion.damType = Props.explosionDamageDef; explosion.instigator = instigator; explosion.damAmount = GenMath.RoundRandom(Props.explosionDamage * scaleFactor); explosion.weapon = null; explosion.projectile = parent.def; explosion.preExplosionSpawnThingDef = Props.preExplosionSpawnThingDef; explosion.preExplosionSpawnChance = Props.preExplosionSpawnChance; explosion.preExplosionSpawnThingCount = Props.preExplosionSpawnThingCount; explosion.postExplosionSpawnThingDef = Props.postExplosionSpawnThingDef; explosion.postExplosionSpawnChance = Props.postExplosionSpawnChance; explosion.postExplosionSpawnThingCount = Props.postExplosionSpawnThingCount; explosion.applyDamageToExplosionCellsNeighbors = Props.applyDamageToExplosionCellsNeighbors; explosion.chanceToStartFire = parent.def.projectile.explosionChanceToStartFire; explosion.dealMoreDamageAtCenter = parent.def.projectile.explosionDealMoreDamageAtCenter; explosion.StartExplosion(Props.explosionDamageDef.soundExplosion); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; if (!this.initialized) { caster = this.launcher as Pawn; GetSecondTarget(); this.initialized = true; } CompWizardry comp = caster.GetComp <CompWizardry>(); if (!this.wallActive && comp.SecondTarget != null) { this.age = 0; this.duration = 1200; this.wallActive = true; this.wallPos = base.Position.ToVector3Shifted(); this.wallDir = GetVector(base.Position.ToVector3Shifted(), comp.SecondTarget.Cell.ToVector3Shifted()); this.wallEnd = comp.SecondTarget.Cell; comp.SecondTarget = null; } if (!wallActive) { if (Find.TickManager.TicksGame % 6 == 0) { MoteMaker.ThrowDustPuff(base.Position, caster.Map, Rand.Range(.6f, .9f)); } } else { if (Find.TickManager.TicksGame % 3 == 0) { if (wallLength < wallLengthMax) { List <Thing> cellList = this.wallPos.ToIntVec3().GetThingList(caster.Map); bool hasWall = false; for (int i = 0; i < cellList.Count(); i++) { if (cellList[i].def.defName == "LotRW_WindWall") { hasWall = true; } } if (!hasWall) { bool spawnWall = true; for (int i = 0; i < cellList.Count(); i++) { if (!cellList[i].def.EverHaulable) { if (cellList[i].def.altitudeLayer == AltitudeLayer.Building || cellList[i].def.altitudeLayer == AltitudeLayer.Item || cellList[i].def.altitudeLayer == AltitudeLayer.ItemImportant) { //Log.Message("bypassing object and setting wall spawn to false"); spawnWall = false; } else { if (cellList[i].def.defName.Contains("Mote") || (cellList[i].def.defName == "LotRW_Projectile_AirWall")) { //Log.Message("avoided storing " + cellList[i].def.defName); } else { this.despawnedThingList.Add(cellList[i]); cellList[i].DeSpawn(); } } } else { int launchDir = -90; if (Rand.Chance(.5f)) { launchDir = 90; } LaunchFlyingObect(cellList[i].Position + (Quaternion.AngleAxis(launchDir, Vector3.up) * wallDir).ToIntVec3(), cellList[i]); } } if (spawnWall) { AbilityUser.SpawnThings tempSpawn = new SpawnThings() { def = ThingDef.Named("LotRW_WindWall"), spawnCount = 1 }; SingleSpawnLoop(tempSpawn, wallPos.ToIntVec3(), caster.Map); this.wallLength++; this.wallPositions.Add(wallPos.ToIntVec3()); } } this.wallPos += this.wallDir; if (!this.wallPos.ToIntVec3().Walkable(caster.Map) || this.wallPos.ToIntVec3() == this.wallEnd) { this.wallPos -= this.wallDir; this.wallLength = this.wallLengthMax; } } for (int j = 0; j < this.wallPositions.Count(); j++) { int launchDir = Rand.Range(-100, -80); if (Rand.Chance(.5f)) { launchDir = Rand.Range(80, 100); } EffectMaker.MakeEffect(ThingDef.Named("Mote_DustPuff"), this.wallPositions.RandomElement().ToVector3Shifted(), caster.Map, Rand.Range(.6f, .8f), (Quaternion.AngleAxis(launchDir, Vector3.up) * wallDir).ToAngleFlat(), Rand.Range(2f, 5f), Rand.Range(100, 200), .04f, .03f, .8f, false); } } } }
public override void Tick() { base.Tick(); timer++; if (timer % 60 == 0) { isBlocked = false; blockedBy = null; foreach (var cell in GetLaunchCells()) { if (IsCellBlocked(cell, out blockedBy)) { isBlocked = true; break; } } } var comp = GetComp <CompRefuelable>(); comp.Props.fuelLabel = CurrentShellDef.LabelCap; comp.Props.fuelGizmoLabel = CurrentShellDef.LabelCap; if (isFlying) { bool spawnSmoke = false; bool spawnFire = false; ticksFlying++; if (ticksFlying <= TicksToLeave) { Vector3 start = GetDroneIdlePos(); Vector3 end = GetDroneIdlePos() + GetDroneTravelDirection() * 350; float p = Mathf.Clamp01((float)ticksFlying / TicksToLeave); float t = launchCurve.Evaluate(p); droneDrawPos = Vector3.Lerp(start, end, t); spawnSmoke = true; spawnFire = true; } else if (ticksFlying >= TicksToLeave + TicksInMiddle) { if (ticksFlying > TicksToLeave + TicksInMiddle + TicksToReturn) { isFlying = false; } else { Vector3 start = GetDroneIdlePos() + GetDroneReturnDirection() * 350; Vector3 end = GetDroneIdlePos(); float p = Mathf.Clamp01((float)(ticksFlying - TicksToLeave - TicksInMiddle) / TicksToReturn); float t = launchCurve.Evaluate(p); droneDrawPos = Vector3.Lerp(start, end, t); spawnSmoke = true; } } Map map = Map; if (spawnFire) { Vector3 pos2 = droneDrawPos + Rand.InsideUnitCircleVec3 * 0.5f; if (pos2.ToIntVec3().InBounds(map)) { #if V13 FleckMaker.ThrowFireGlow(pos2, map, 1f); #else MoteThrown moteThrown2 = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_FireGlow); moteThrown2.Scale = Rand.Range(4f, 6f) * 1f; moteThrown2.rotationRate = Rand.Range(-3f, 3f); moteThrown2.exactPosition = pos2; moteThrown2.SetVelocity(Rand.Range(0, 360), 0.12f); GenSpawn.Spawn(moteThrown2, pos2.ToIntVec3(), map); #endif } } if (spawnSmoke) { for (int i = 0; i < 3; i++) { Vector3 pos = droneDrawPos + Rand.InsideUnitCircleVec3 * 2f; if (pos.ToIntVec3().InBounds(map)) { #if V13 FleckCreationData dataStatic = FleckMaker.GetDataStatic(pos, map, FleckDefOf.Smoke, Rand.Range(1.5f, 2.5f) * 1f); dataStatic.spawnPosition = pos; dataStatic.rotationRate = Rand.Range(-30f, 30f); dataStatic.velocityAngle = (float)Rand.Range(30, 40); dataStatic.velocitySpeed = Rand.Range(0.5f, 0.7f); map.flecks.CreateFleck(dataStatic); #else MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Smoke); moteThrown.Scale = Rand.Range(1.5f, 2.5f) * 1f; moteThrown.rotationRate = Rand.Range(-30f, 30f); moteThrown.exactPosition = pos; moteThrown.SetVelocity(Rand.Range(30, 40), Rand.Range(0.5f, 0.7f)); GenSpawn.Spawn(moteThrown, pos.ToIntVec3(), map); #endif } } } } else { droneDrawPos = GetDroneIdlePos(); } }
// Added targetThing to parameters so we can calculate its height private bool CanHitCellFromCellIgnoringRange(Vector3 shotSource, IntVec3 targetLoc, Thing targetThing = null) { // Vanilla checks if (verbProps.mustCastOnOpenGround && (!targetLoc.Standable(caster.Map) || caster.Map.thingGrid.CellContains(targetLoc, ThingCategory.Pawn))) { return(false); } if (verbProps.requireLineOfSight) { // Calculate shot vector Vector3 targetPos; if (targetThing != null) { Vector3 targDrawPos = targetThing.DrawPos; targetPos = new Vector3(targDrawPos.x, new CollisionVertical(targetThing).Max, targDrawPos.z); var targPawn = targetThing as Pawn; if (targPawn != null) { targetPos += targPawn.Drawer.leaner.LeanOffset * 0.6f; } } else { targetPos = targetLoc.ToVector3Shifted(); } Ray shotLine = new Ray(shotSource, (targetPos - shotSource)); // Create validator to check for intersection with partial cover var aimMode = CompFireModes?.CurrentAimMode; bool CanShootThroughCell(IntVec3 cell) { Thing cover = cell.GetFirstPawn(caster.Map) ?? cell.GetCover(caster.Map); if (cover != null && cover != ShooterPawn && cover != caster && cover != targetThing && !cover.IsPlant() && !(cover is Pawn && cover.HostileTo(caster))) { // Skip this check entirely if we're doing suppressive fire and cell is adjacent to target if ((VerbPropsCE.ignorePartialLoSBlocker || aimMode == AimMode.SuppressFire) && cover.def.Fillage != FillCategory.Full) { return(true); } Bounds bounds = CE_Utility.GetBoundsFor(cover); // Simplified calculations for adjacent cover for gameplay purposes if (cover.def.Fillage != FillCategory.Full && cover.AdjacentTo8WayOrInside(caster)) { // Sanity check to prevent stuff behind us blocking LoS var cellTargDist = cell.DistanceTo(targetLoc); var shotTargDist = shotSource.ToIntVec3().DistanceTo(targetLoc); if (shotTargDist > cellTargDist) { return(cover is Pawn || bounds.size.y < shotSource.y); } } // Check for intersect if (bounds.IntersectRay(shotLine)) { if (Controller.settings.DebugDrawPartialLoSChecks) { caster.Map.debugDrawer.FlashCell(cell, 0, bounds.extents.y.ToString()); } return(false); } if (Controller.settings.DebugDrawPartialLoSChecks) { caster.Map.debugDrawer.FlashCell(cell, 0.7f, bounds.extents.y.ToString()); } } return(true); } // Add validator to parameters foreach (IntVec3 curCell in SightUtility.GetCellsOnLine(shotSource, targetLoc.ToVector3())) { if (Controller.settings.DebugDrawPartialLoSChecks) { caster.Map.debugDrawer.FlashCell(curCell, 0.4f); } if (curCell != shotSource.ToIntVec3() && curCell != targetLoc && !CanShootThroughCell(curCell)) { return(false); } } } return(true); }
public override void DoWindowContents(Rect inRect) { var innerRect = inRect; innerRect.y += 8f; innerRect.height -= 16f; GizmoListRect = innerRect.AtZero(); GizmoListRect.y += scrollPosition.y; // Scrollable List var scrollRect = new Rect(innerRect); scrollRect.y += 3f; scrollRect.x += 8f; scrollRect.height -= 49f; scrollRect.width -= 16f; var viewRect = new Rect(0.0f, 0.0f, scrollRect.width, RecipesScrollHeight); Widgets.BeginScrollView(scrollRect, ref scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < thingList.Count; i++) { var viewElement = new Rect(0.0f, boxHeight * i, inRect.width, boxHeight); if (!viewElement.Overlaps(GizmoListRect)) { continue; } if (rows[i] == null) { try { var index = pawn.Map.cellIndices.CellToIndex(cpos.ToIntVec3()); var listArray = (List <Thing>[])thingListTG.GetValue(pawn.Map.thingGrid); var origList = new List <Thing>(listArray[index]); listArray[index] = new List <Thing> { thingList[i] }; rows[i] = new DSGUI_ListItem(pawn, thingList[i], cpos, boxHeight); listArray[index] = origList; } catch (Exception ex) { var rect5 = scrollRect.ContractedBy(-4f); Widgets.Label(rect5, "Oops, something went wrong!"); Log.Warning(ex.ToString()); } } if (searchString.NullOrEmpty()) { rows[i].DoDraw(viewRect, i); } else { if (!(rows[i].label.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)) { continue; } rows[i].DoDraw(viewRect, i); } } RecipesScrollHeight = boxHeight * thingList.Count; GUI.EndGroup(); Widgets.EndScrollView(); Widgets.DrawBox(scrollRect); // Search var searchRect = new Rect(innerRect); searchRect.y += scrollRect.height + 16f; searchRect.x += 8f; searchRect.height = 28f; searchRect.width -= 40f + searchClearPadding; // 16f for padding of 8f on each side + 28f for the clear button DSGUI.Elements.InputField("Search", searchRect, ref searchString); searchRect.x = searchRect.width + 6f + searchClearPadding; searchRect.width = 28f; Text.Anchor = TextAnchor.MiddleLeft; if (Widgets.ButtonImageFitted(searchRect, Widgets.CheckboxOffTex)) { searchString = ""; } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; }
private void DropStuff(Thing thing) { Vector3 VecOffset = new Vector3(0, 0,2); IntVec3 IntSquare= ClutterBeds.Position + VecOffset.ToIntVec3().RotatedBy(ClutterBeds.Rotation); ClutterBeds.GetContainer().TryDrop(thing, IntSquare, ThingPlaceMode.Direct, out thing); CompAffectedByFacilities Fcomp = ClutterBeds.GetComp<CompAffectedByFacilities>(); Fcomp.Notify_LinkRemoved(thing); }
/// <summary> /// Checks for cover along the flight path of the bullet, doesn't check for walls or plants, only intended for cover with partial fillPercent /// </summary> private bool GetPartialCoverBetween(Vector3 sourceLoc, Vector3 targetLoc, out Thing cover) { //Sanity check if (this.verbProps.projectileDef.projectile.flyOverhead) { cover = null; return false; } sourceLoc.Scale(new Vector3(1, 0, 1)); targetLoc.Scale(new Vector3(1, 0, 1)); //Calculate segment vector and segment amount Vector3 shotVec = sourceLoc - targetLoc; //Vector from target to source Vector3 segmentVec = shotVec.normalized * segmentLength; float distToCheck = Mathf.Min(distToCheckForCover, shotVec.magnitude); //The distance to raycast float numSegments = distToCheck / segmentLength; //Raycast accross all segments to check for cover List<IntVec3> checkedCells = new List<IntVec3>(); Thing targetThing = GridsUtility.GetEdifice(targetLoc.ToIntVec3()); Thing newCover = null; for (int i = 0; i <= numSegments; i++) { IntVec3 cell = (targetLoc + segmentVec * i).ToIntVec3(); if (!checkedCells.Contains(cell)) { //Cover check, if cell has cover compare fillPercent and get the highest piece of cover, ignore if cover is the target (e.g. solar panels, crashed ship, etc) Thing coverAtCell = GridsUtility.GetCover(cell); if (coverAtCell != null && (targetThing == null || !coverAtCell.Equals(targetThing)) && (newCover == null || newCover.def.fillPercent < coverAtCell.def.fillPercent)) { newCover = coverAtCell; } } } cover = newCover; //Report success if found cover that is not a wall or plant return (cover != null && cover.def.Fillage != FillCategory.Full && cover.def.category != ThingCategory.Plant); //Don't care about trees }
protected void MakeMote(TargetInfo A, TargetInfo B) { Vector3 vector = Vector3.zero; switch (def.spawnLocType) { case MoteSpawnLocType.OnSource: vector = A.CenterVector3; break; case MoteSpawnLocType.BetweenPositions: { Vector3 vector2 = (A.HasThing ? A.Thing.DrawPos : A.Cell.ToVector3Shifted()); Vector3 vector3 = (B.HasThing ? B.Thing.DrawPos : B.Cell.ToVector3Shifted()); vector = ((A.HasThing && !A.Thing.Spawned) ? vector3 : ((!B.HasThing || B.Thing.Spawned) ? (vector2 * def.positionLerpFactor + vector3 * (1f - def.positionLerpFactor)) : vector2)); break; } case MoteSpawnLocType.RandomCellOnTarget: vector = ((!B.HasThing) ? CellRect.CenteredOn(B.Cell, 0) : B.Thing.OccupiedRect()).RandomCell.ToVector3Shifted(); break; case MoteSpawnLocType.BetweenTouchingCells: vector = A.Cell.ToVector3Shifted() + (B.Cell - A.Cell).ToVector3().normalized * 0.5f; break; } if (parent != null) { Rand.PushState(parent.GetHashCode()); if (A.CenterVector3 != B.CenterVector3) { vector += (B.CenterVector3 - A.CenterVector3).normalized * parent.def.offsetTowardsTarget.RandomInRange; } vector += Gen.RandomHorizontalVector(parent.def.positionRadius) + parent.offset; Rand.PopState(); } Map map = A.Map ?? B.Map; float num = (def.absoluteAngle ? 0f : (B.Cell - A.Cell).AngleFlat); float num2 = ((parent != null) ? parent.scale : 1f); if (map == null || !vector.ShouldSpawnMotesAt(map)) { return; } int randomInRange = def.burstCount.RandomInRange; for (int i = 0; i < randomInRange; i++) { Mote obj = (Mote)ThingMaker.MakeThing(def.moteDef); GenSpawn.Spawn(obj, vector.ToIntVec3(), map); obj.Scale = def.scale.RandomInRange * num2; obj.exactPosition = vector + def.positionOffset * num2 + Gen.RandomHorizontalVector(def.positionRadius) * num2; obj.rotationRate = def.rotationRate.RandomInRange; obj.exactRotation = def.rotation.RandomInRange + num; obj.instanceColor = def.color; MoteThrown moteThrown = obj as MoteThrown; if (moteThrown != null) { moteThrown.airTimeLeft = def.airTime.RandomInRange; moteThrown.SetVelocity(def.angle.RandomInRange + num, def.speed.RandomInRange); } } }
/// <summary> /// Checks for colateral targets (cover, neutral animal, pawn) along the trajectory. /// </summary> protected void DetermineImpactExactPosition() { // We split the trajectory into small segments of approximatively 1 cell size. Vector3 trajectory = (this.destination - this.origin); int numberOfSegments = (int)trajectory.magnitude; Vector3 trajectorySegment = (trajectory / trajectory.magnitude); Vector3 temporaryDestination = this.origin; // Last valid tested position in case of an out of boundaries shot. Vector3 exactTestedPosition = this.origin; IntVec3 testedPosition = exactTestedPosition.ToIntVec3(); for (int segmentIndex = 1; segmentIndex <= numberOfSegments; segmentIndex++) { exactTestedPosition += trajectorySegment; testedPosition = exactTestedPosition.ToIntVec3(); if (!exactTestedPosition.InBounds(this.Map)) { this.destination = temporaryDestination; break; } if (!this.def.projectile.flyOverhead && segmentIndex >= 5) { List <Thing> list = this.Map.thingGrid.ThingsListAt(base.Position); for (int i = 0; i < list.Count; i++) { Thing current = list[i]; // Check impact on a wall. if (current.def.Fillage == FillCategory.Full) { this.destination = testedPosition.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f)); this.hitThing = current; break; } // Check impact on a pawn. if (current.def.category == ThingCategory.Pawn) { Pawn pawn = current as Pawn; float chanceToHitCollateralTarget = 0.45f; if (pawn.Downed) { chanceToHitCollateralTarget *= 0.1f; } float targetDistanceFromShooter = (this.ExactPosition - this.origin).MagnitudeHorizontal(); if (targetDistanceFromShooter < 4f) { chanceToHitCollateralTarget *= 0f; } else { if (targetDistanceFromShooter < 7f) { chanceToHitCollateralTarget *= 0.5f; } else { if (targetDistanceFromShooter < 10f) { chanceToHitCollateralTarget *= 0.75f; } } } chanceToHitCollateralTarget *= pawn.RaceProps.baseBodySize; if (Rand.Value < chanceToHitCollateralTarget) { this.destination = testedPosition.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f)); this.hitThing = (Thing)pawn; break; } } } } temporaryDestination = exactTestedPosition; } }
//Removed minimum collision distance private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { IntVec3 lastPos = lastExactPos.ToIntVec3(); IntVec3 newPos = newExactPos.ToIntVec3(); if (newPos == lastPos) { return false; } if (!lastPos.InBounds() || !newPos.InBounds()) { return false; } if ((newPos - lastPos).LengthManhattan == 1) { return this.CheckForFreeIntercept(newPos); } //Check for minimum collision distance float distToTarget = this.assignedTarget != null ? (this.assignedTarget.DrawPos - this.origin).MagnitudeHorizontal() : (this.destination - this.origin).MagnitudeHorizontal(); if (this.def.projectile.alwaysFreeIntercept || distToTarget <= 1f ? this.origin.ToIntVec3().DistanceToSquared(newPos) > 1f : this.origin.ToIntVec3().DistanceToSquared(newPos) > Mathf.Min(12f, distToTarget / 2)) { Vector3 currentExactPos = lastExactPos; Vector3 flightVec = newExactPos - lastExactPos; Vector3 sectionVec = flightVec.normalized * 0.2f; int numSections = (int)(flightVec.MagnitudeHorizontal() / 0.2f); ProjectileCR.checkedCells.Clear(); int currentSection = 0; while (true) { currentExactPos += sectionVec; IntVec3 intVec3 = currentExactPos.ToIntVec3(); if (!ProjectileCR.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { break; } ProjectileCR.checkedCells.Add(intVec3); } currentSection++; if (currentSection > numSections) { return false; } if (intVec3 == newPos) { return false; } } return true; } return false; }