static bool CheckShieldCollision(ProjectileCE __instance, Vector2 ___origin, int ___ticksToImpact) { var current = __instance.ExactPosition; var last = current - __instance.ExactMinusLastPos; return(!TryBlockProjectileCE( __instance, last, current, ___ticksToImpact, ___origin, (shield, point) => { if (IsOverhead(__instance)) { ExplosionUtility.DoSmokeExplosion(__instance, GetExplosionSound(__instance)); __instance.Destroy(); } else { // check if it is an explosive projectile to impact if (!IsExplosive(__instance) || !Impact(__instance, shield, point)) { // this is a regular projectile, remove it __instance.Destroy(); } } })); }
private static bool CheckCollision(ProjectileCE projectile, IntVec3 cell, Thing launcher) { if (projectile.def.projectile.flyOverhead) { // All VFE shields are bullet shields. Don't block flying projectiles. return(false); } var map = projectile.Map; Vector3 exactPosition = projectile.ExactPosition; refreshShields(map); foreach (var building in shields) { var shield = building as Building_Shield; if (!ShieldInterceptsProjectile(shield, projectile, launcher)) { continue; } projectile.ExactPosition = BlockerRegistry.GetExactPosition(projectile.OriginIV3.ToVector3(), exactPosition, new Vector3(shield.Position.x, 0, shield.Position.z), shield.ShieldRadius * shield.ShieldRadius); if (!(projectile is ProjectileCE_Explosive)) { shield.AbsorbDamage(projectile.def.projectile.GetDamageAmount(launcher), projectile.def.projectile.damageDef, projectile.ExactRotation.eulerAngles.y); } return(true); } return(false); }
static bool CheckShieldCollision(ProjectileCE __instance, bool __result, Vector2 ___origin, int ___ticksToImpact) { var current = __instance.ExactPosition; var last = current - __instance.ExactMinusLastPos; var shouldBlock = TryBlockProjectileCE( __instance, last, current, ___ticksToImpact, ___origin); if (shouldBlock) { if (ShouldImpact(__instance)) { __instance.ExactPosition = last; impactMethod.Invoke(__instance, new object[] { null }); } else { __instance.Destroy(); } } return(!shouldBlock); }
// TryCastShotFrom(muzzlePos) public bool TryCastShotFrom(Vector3 muzzlePos) { if (!TryFindCEShootLineFromTo(caster.Position, currentTarget, out var shootLine)) { return(false); } if (projectilePropsCE.pelletCount < 1) { Log.Error(EquipmentSource.LabelCap + " tried firing with pelletCount less than 1."); return(false); } ShiftVecReport report = ShiftVecReportFor(currentTarget); bool pelletMechanicsOnly = false; numShotsFired = (int)AccessTools.Field(typeof(Verb_LaunchProjectileCE), "numShotsFired").GetValue(this); shotAngle = (float)AccessTools.Field(typeof(Verb_LaunchProjectileCE), "shotAngle").GetValue(this); shotRotation = (float)AccessTools.Field(typeof(Verb_LaunchProjectileCE), "shotRotation").GetValue(this); shotSpeed = (float)AccessTools.Field(typeof(Verb_LaunchProjectileCE), "shotSpeed").GetValue(this); for (int i = 0; i < projectilePropsCE.pelletCount; i++) { ProjectileCE projectile = (ProjectileCE)ThingMaker.MakeThing(Projectile, null); GenSpawn.Spawn(projectile, shootLine.Source, caster.Map); ShiftTarget(report, pelletMechanicsOnly); //New aiming algorithm projectile.canTargetSelf = false; var targDist = (muzzlePos.ToIntVec3().ToIntVec2.ToVector2Shifted() - currentTarget.Cell.ToIntVec2.ToVector2Shifted()).magnitude; if (targDist <= 2) { targDist *= 2; // Double to account for divide by 4 in ProjectileCE minimum collision distance calculations } // projectile.minCollisionSqr = Mathf.Pow(targDist, 2); projectile.intendedTarget = currentTarget.Thing; projectile.mount = caster.Position.GetThingList(caster.Map).FirstOrDefault(t => t is Pawn && t != caster); projectile.AccuracyFactor = report.accuracyFactor * report.swayDegrees * ((numShotsFired + 1) * 0.75f); projectile.Launch( Shooter, //Shooter instead of caster to give turret operators' records the damage/kills obtained new Vector2(muzzlePos.x, muzzlePos.z), shotAngle, shotRotation, ShotHeight, ShotSpeed, EquipmentSource ); pelletMechanicsOnly = true; } /// Log.Message("Fired from "+caster.ThingID+" at "+ShotHeight); /// pelletMechanicsOnly = false; numShotsFired++; if (CompAmmo != null && !CompAmmo.CanBeFiredNow) { CompAmmo?.TryStartReload(); } if (CompReloadable != null) { CompReloadable.UsedOnce(); } return(true); }
public static void Arc(ProjectileCE __instance, Thing ___launcher, Pawn hitPawn, float radius = 5f) { Map map = hitPawn.Map; if (hitPawn.Faction != null) { if (Find.CurrentMap.mapPawns.AllPawns.Any(x => x.Position.InBounds(map) && x.Position.InHorDistOf(hitPawn.Position, radius) && x != hitPawn)) { IEnumerable <Pawn> pawns = Find.CurrentMap.mapPawns.AllPawns.Where(x => x.Position.InBounds(map) && x.Position.InHorDistOf(hitPawn.Position, radius) && x != hitPawn); int t = Math.Min(pawns.Count(), 3); List <Pawn> alreadyhit = new List <Pawn>(); for (int i = 0; i < t; i++) { Pawn target = pawns.Where(x => !alreadyhit.Contains(x)).RandomElement(); if (target != null) { Projectile projectile = (Projectile)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("OGN_Bullet_TeslaCarbine_Arc"), null); GenSpawn.Spawn(projectile, hitPawn.Position, hitPawn.Map, 0); // Log.Message(string.Format("Launch projectile2 {0} at {1}", projectile, OriginalPawn)); projectile.Launch(___launcher, hitPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.Projectile), target, target, ProjectileHitFlags.All); alreadyhit.Add(target); } else { break; } } } } return; }
private static bool TryBlockProjectileCE( ProjectileCE projectile, Vector3 currentPosition, Vector3 nextPosition, int ticksToImpact, Vector2 origin) { var ap = projectile.def.projectile.GetArmorPenetration(1f); var damages = new ShieldDamages( new ShieldDamage( projectile.def.projectile.damageDef, projectile.def.projectile.GetDamageAmount(ap))); (projectile.def.projectile as ProjectilePropertiesCE)?.secondaryDamage.ForEach(second => { damages.Add(new ShieldDamage( second.def, second.amount * ap)); }); var result = TryBlock( projectile, currentPosition, nextPosition, ticksToImpact, Common.ToVector3(origin), // TODO might be able to calculate the exact path with 3d CE projectiles projectile.def.projectile.flyOverhead, damages) != null; return(result); }
public static bool CheckForCollisionCallback(ProjectileCE projectile, IntVec3 cell, Thing launcher) { /* Check if an active shield can block this projectile, we don't check if the projectile flies overhead, as those projectiles don't call this function */ Map map = projectile.Map; Vector3 exactPosition = projectile.ExactPosition; IntVec3 origin = projectile.OriginIV3; getShields(map); foreach (Building building in shields) { var shield = building as Building_Shield; var generator = shield.GetComp <Comp_ShieldGenerator>(); bool isActive = generator.IsActive(); if (!isActive) { continue; } bool blockDirect = generator.BlockDirect_Active(); if (!blockDirect) { continue; } int fieldRadius = (int)generator.FieldRadius_Active(); int fieldRadiusSq = fieldRadius * fieldRadius; float DistanceSq = projectile.Position.DistanceToSquared(shield.Position) - fieldRadiusSq; float originDistanceSq = origin.DistanceToSquared(shield.Position) - fieldRadiusSq; if (DistanceSq > 0) { continue; } if (originDistanceSq < 0) { continue; } Vector3 shieldPosition2D = new Vector3(shield.Position.x, 0, shield.Position.z); Quaternion targetAngle = projectile.ExactRotation; Quaternion shieldProjAng = Quaternion.LookRotation(exactPosition - shieldPosition2D); if ((Quaternion.Angle(targetAngle, shieldProjAng) > 90)) { HitSoundDef.PlayOneShot((SoundInfo) new TargetInfo(shield.Position, map, false)); int damage = (projectile.def.projectile.GetDamageAmount(launcher)); generator.FieldIntegrity_Current -= damage; exactPosition = getExactPosition(origin.ToVector3(), projectile.ExactPosition, shield.Position.ToVector3(), (fieldRadius - 1) * (fieldRadius - 1)); MoteMaker.ThrowLightningGlow(exactPosition, map, 0.5f); projectile.ExactPosition = exactPosition; return(true); } } return(false); }
public static bool BlockableByShield(this ProjectileCE proj, Building_Shield shieldGen) { if (!proj.def.projectile.flyOverhead) { return(true); } return(!shieldGen.coveredCells.Contains(((Vector3)VFESecurity.NonPublicFields.Projectile_origin.GetValue(proj)).ToIntVec3()) && NonPublicProperties.CombatExtended.ProjectileCE_get_IntTicksToImpact(proj) / NonPublicProperties.CombatExtended.ProjectileCE_get_StartingTicksToImpact(proj) <= 0.5f); }
// [HarmonyPrefix] public static void Prefix(ref ProjectileCE __instance, Thing hitThing) { Vector3 vector = __instance.ExactPosition; if (__instance.def.HasModExtension <EffectProjectileExtension>()) { EffectProjectileExtension(__instance, vector, hitThing); } }
private static bool ShouldImpact(ProjectileCE projectile) { if (projectile.def.projectile.flyOverhead) { return(false); } var type = projectile.GetType(); return(typeof(ProjectileCE_Explosive).IsAssignableFrom(type)); }
private static Vector2 Vec2Position(ProjectileCE __instance, Vector2 origin, Vector2 Destination, int StartingTicksToImpact, int ticksToImpact, int intTicksToImpact, float ticks = -1f) { bool flag = ticks < 0f; if (flag) { ticks = fTicks(StartingTicksToImpact, ticksToImpact, intTicksToImpact); } return(Vector2.Lerp(origin, Destination, ticks / StartingTicksToImpact)); }
private static void LogImpact(ProjectileCE __instance, Thing launcher, ThingDef equipmentDef, Thing hitThing, out LogEntry_DamageResult logEntry) { logEntry = new BattleLogEntry_RangedImpact(launcher, hitThing, __instance.intendedTarget.Thing, equipmentDef, __instance.def, null); bool flag = !(launcher is AmmoThing); if (flag) { Find.BattleLog.Add(logEntry); } }
private static void EffectProjectileExtension(ProjectileCE __instance, Vector3 vector, Thing hitThing) { EffectProjectileExtension effects = __instance.def.GetModExtension <EffectProjectileExtension>(); if (effects != null) { // effects.ThrowMote(vector, __instance.Map, __instance.def.projectile.damageDef.explosionCellMote, effects.explosionMoteSize, __instance.def.projectile.damageDef.explosionColorCenter, __instance.def.projectile.damageDef.soundExplosion, ThingDef.Named(effects.ImpactMoteDef) ?? null, effects.ImpactMoteSizeRange?.RandomInRange ?? effects.ImpactMoteSize, ThingDef.Named(effects.ImpactGlowMoteDef) ?? null, effects.ImpactGlowMoteSizeRange?.RandomInRange ?? effects.ImpactGlowMoteSize, hitThing); effects.ThrowMote(vector, __instance.Map, __instance.def.projectile.damageDef.explosionCellMote, __instance.def.projectile.damageDef.explosionColorCenter, __instance.def.projectile.damageDef.soundExplosion, effects, hitThing); } }
private static Bullet GenerateVanillaBullet(ProjectileCE __instance, Thing launcher) { Bullet bullet = new Bullet { def = __instance.def, intendedTarget = __instance.intendedTarget }; Traverse.Create(bullet).Field("launcher").SetValue(launcher); return(bullet); }
private static bool ImpactSomething(ProjectileCE projectile, Thing launcher) { var map = projectile.Map; Vector3 exactPosition = projectile.ExactPosition; refreshShields(map); var blocked = shields.Any(building => ShieldInterceptsProjectile(building as Building_Shield, projectile, launcher)); CELogger.Message($"Blocked {projectile}? -- {blocked}"); return(blocked); }
public bool WillTargetLandInRange(ProjectileCE projectile) { Vector3 targetLocation = GetTargetLocationFromProjectile(projectile); if (Vector3.Distance(this.Position.ToVector3(), targetLocation) > this.m_Field_Radius) { return(false); } else { return(true); } }
public static bool CheckForCollisionCallback(ProjectileCE projectile, IntVec3 cell, Thing launcher) { /* Check if an active shield can block this projectile, we don't check if the projectile flies overhead, as those projectiles don't call this function */ Map map = projectile.Map; Vector3 exactPosition = projectile.ExactPosition; getShields(map); foreach (Building shield in shields) { var generator = GetShieldGenerator.Invoke(shield, null); bool isActive = (bool)IsActive.Invoke(generator, null); if (!isActive) { continue; } bool blockDirect = (bool)BlockDirect_Active.Invoke(generator, null); if (!blockDirect) { continue; } int fieldRadius = (int)FieldRadius.Invoke(generator, null); float Distance = Vector3.Distance(projectile.Position.ToVector3(), shield.Position.ToVector3()) - fieldRadius; if (Distance > 0) { continue; } if (Distance < -2) { continue; } Vector3 shieldPosition2D = new Vector3(shield.Position.x, 0, shield.Position.z); Quaternion targetAngle = projectile.ExactRotation; Quaternion shieldProjAng = Quaternion.LookRotation(exactPosition - shieldPosition2D); if ((Quaternion.Angle(targetAngle, shieldProjAng) > 90)) { MoteMaker.ThrowLightningGlow(exactPosition, map, 0.5f); HitSoundDef.PlayOneShot((SoundInfo) new TargetInfo(shield.Position, map, false)); int damage = (projectile.def.projectile.GetDamageAmount(launcher)); int fic = (int)FieldIntegrity_Current.GetValue(generator); FieldIntegrity_Current.SetValue(generator, fic - damage); projectile.ExactPosition = cell.ToVector3(); return(true); } } return(false); }
private static SoundDef GetExplosionSound(ProjectileCE projectile) { switch (projectile) { case ProjectileCE_Explosive explosive: return(GetExplosionSound(explosive.def.projectile)); default: return(projectile.AllComps .OfType <CompExplosiveCE>() .Select(compExplosive => GetExplosionSound((CompProperties_ExplosiveCE)compExplosive.props)) .FirstOrDefault()); } }
public static bool CheckCellForCollisionCallback(ProjectileCE projectile, IntVec3 cell, Thing launcher) { if (!enabled) { return(false); } foreach (var cb in checkCellForCollisionCallbacks) { if (cb(projectile, cell, launcher)) { return(true); } } return(false); }
public static bool ImpactSomethingCallback(ProjectileCE projectile, Thing launcher) { if (!enabled) { return(false); } foreach (var cb in impactSomethingCallbacks) { if (cb(projectile, launcher)) { return(true); } } return(false); }
static bool BlockMortarImpacts(ProjectileCE __instance, int ___ticksToImpact, Vector2 ___origin) { if (!__instance.def.projectile.flyOverhead) { return(true); } var shouldBlock = TryBlockOverheadProjectileCE(__instance, __instance.ExactPosition, ___ticksToImpact, ___origin); if (shouldBlock) { __instance.Destroy(); } return(!shouldBlock); }
private static bool TryBlockOverheadProjectileCE( ProjectileCE projectile, Vector3 currentPosition, int ticksToImpact, Vector2 origin) { return(TryBlock( projectile, currentPosition, ticksToImpact, PositionUtility.ToVector3(origin), // TODO might be able to calculate the exact path with 3d CE projectiles projectile.def.projectile.flyOverhead, CalculateDamages(projectile)) != null); }
private static ShieldDamages CalculateDamages(ProjectileCE projectile) { var ap = projectile.def.projectile.GetArmorPenetration(1f); var damages = new ShieldDamages( new ShieldDamage( projectile.def.projectile.damageDef, projectile.def.projectile.GetDamageAmount(ap))); (projectile.def.projectile as ProjectilePropertiesCE)?.secondaryDamage.ForEach(second => { damages.Add(new ShieldDamage( second.def, second.amount * ap)); }); return(damages); }
public static void WarpRift(ProjectileCE __instance, Thing ___launcher, Pawn hitPawn) { Map map = hitPawn.Map; if (__instance.def.projectile.explosionEffect != null) { Effecter effecter = __instance.def.projectile.explosionEffect.Spawn(); effecter.Trigger(new TargetInfo(hitPawn.Position, map, false), new TargetInfo(hitPawn.Position, map, false)); effecter.Cleanup(); } IntVec3 position = hitPawn.Position; Map map2 = map; float explosionRadius = __instance.def.projectile.explosionRadius; DamageDef damageDef = __instance.def.projectile.damageDef; int DamageAmount = __instance.def.projectile.GetDamageAmount(___launcher, null); DamageArmorCategoryDef armorCategory = damageDef.armorCategory; StatDef armorcatdef = armorCategory.armorRatingStat; float ArmorPenetration = hitPawn.GetStatValue(armorcatdef, true); SoundDef soundExplode = __instance.def.projectile.soundExplode; ThingDef postExplosionSpawnThingDef = __instance.def.projectile.postExplosionSpawnThingDef; float postExplosionSpawnChance = __instance.def.projectile.postExplosionSpawnChance; int postExplosionSpawnThingCount = __instance.def.projectile.postExplosionSpawnThingCount; float y = __instance.ExactRotation.eulerAngles.y; ThingDef preExplosionSpawnThingDef = __instance.def.projectile.preExplosionSpawnThingDef; damageDef = AdeptusDamageDefOf.OG_E_Distortion_Damage_Blast; GenExplosion.DoExplosion(position, map2, explosionRadius, damageDef, ___launcher, DamageAmount, ArmorPenetration, soundExplode);//, equipmentDef, def, thing, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, EquipmentSource.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, EquipmentSource.def.projectile.preExplosionSpawnChance, EquipmentSource.def.projectile.preExplosionSpawnThingCount, EquipmentSource.def.projectile.explosionChanceToStartFire, EquipmentSource.def.projectile.explosionDamageFalloff); DamageInfo dinfo = new DamageInfo(damageDef, DamageAmount, ArmorPenetration, y, ___launcher, null, ___launcher.def, DamageInfo.SourceCategory.ThingOrUnknown, hitPawn); hitPawn.TakeDamage(dinfo); string msg = string.Format("{0} was lost to the warp", hitPawn.LabelCap); if (!hitPawn.Dead) { hitPawn.Kill(dinfo); } if (hitPawn.Faction == Faction.OfPlayer) { Messages.Message(msg, MessageTypeDefOf.PawnDeath); } if (hitPawn.Dead) { hitPawn.Corpse.Destroy(DestroyMode.KillFinalize); } }
private static void EffectProjectileExtension(ProjectileCE __instance, Vector3 vector, Thing hitThing) { if (__instance is LaserBeamCE beam) { return; /* * bool shielded = hitThing.IsShielded() && beam.def.IsWeakToShields; * * LaserGunDef defWeapon = beam.EquipmentDef as LaserGunDef; * Vector3 dir = (beam.destination - beam.origin).normalized; * dir.y = 0; * * Vector3 a = beam.origin + dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); * Vector3 b; * if (hitThing == null) * { * b = beam.destination; * } * else if (shielded) * { * Rand.PushState(); * b = hitThing.TrueCenter() - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f; * Rand.PopState(); * } * else if ((beam.destination - hitThing.TrueCenter()).magnitude < 1) * { * b = beam.destination; * } * else * { * Rand.PushState(); * b = hitThing.TrueCenter(); * b.x += Rand.Range(-0.5f, 0.5f); * b.z += Rand.Range(-0.5f, 0.5f); * Rand.PopState(); * } * vector = b; */ } if (__instance.def.HasModExtension <ProjectileVFX>()) { ProjectileVFX effects = __instance.def.GetModExtension <ProjectileVFX>(); effects.ImpactEffects(vector, __instance.Map, effects.ExplosionMoteDef ?? __instance.def.projectile.damageDef.explosionCellMote, effects.ExplosionMoteSize, __instance.def.projectile.damageDef.explosionColorCenter, __instance.def.projectile.damageDef.soundExplosion, effects.ImpactMoteDef, effects.ImpactMoteSize, effects.ImpactGlowMoteDef, effects.ImpactGlowMoteSize, hitThing); } }
private static void ApplySuppression(ProjectileCE __instance, IntVec3 OriginIV3, Pawn pawn, Thing launcher, ref float suppressionAmount) { ShieldBelt shieldBelt = null; bool humanlike = pawn.RaceProps.Humanlike; if (humanlike) { List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int i = 0; i < wornApparel.Count; i++) { ShieldBelt shieldBelt2 = wornApparel[i] as ShieldBelt; bool flag = shieldBelt2 != null; if (flag) { shieldBelt = shieldBelt2; break; } } } CompSuppressable compSuppressable = pawn.TryGetCompFast <CompSuppressable>(); bool flag2; if (compSuppressable != null) { Faction faction = pawn.Faction; Thing thing = launcher; if (faction != ((thing != null) ? thing.Faction : null)) { flag2 = (shieldBelt == null || shieldBelt.ShieldState == ShieldState.Resetting); goto IL_93; } } flag2 = false; IL_93: bool flag3 = flag2; if (flag3) { suppressionAmount = (float)__instance.def.projectile.GetDamageAmount(1f, null); ProjectilePropertiesCE projectilePropertiesCE = __instance.def.projectile as ProjectilePropertiesCE; float num = (projectilePropertiesCE != null) ? projectilePropertiesCE.armorPenetrationSharp : 0f; float num2 = (num <= 0f) ? 0f : (1f - Mathf.Clamp(pawn.GetStatValue(CE_StatDefOf.AverageSharpArmor, true) * 0.5f / num, 0f, 1f)); suppressionAmount *= num2; compSuppressable.AddSuppression(suppressionAmount, OriginIV3); } }
private static bool TryBlockProjectileCE( ProjectileCE projectile, Vector3 currentPosition, Vector3 nextPosition, int ticksToImpact, Vector2 origin, Action <IShieldField, Vector3> onBlock = null) { return(TryBlock( projectile, currentPosition, nextPosition, ticksToImpact, PositionUtility.ToVector3(origin), false, // not needed since CE mortars are calculated in 3D CalculateDamages(projectile.def), onBlock)); }
// [HarmonyPostfix] public static void Postfix(ProjectileCE __instance) { if (__instance != null) { if (__instance.def.HasModExtension <GlowerProjectileExtension>()) { GlowerProjectileExtension glower = __instance.def.GetModExtension <GlowerProjectileExtension>(); if (glower != null) { glower.Glow(__instance, __instance.ExactRotation); /* * Mesh mesh2 = MeshPool.GridPlane(glower.GlowMoteDef.graphicData.drawSize * glower.GlowMoteSize); * Graphics.DrawMesh(mesh2, __instance.DrawPos, __instance.ExactRotation, glower.GlowMoteDef.graphic.MatSingle, 0); */ } } } }
public static bool ImpactSomethingCallback(ProjectileCE projectile, Thing launcher) { bool flyOverhead = projectile.def.projectile.flyOverhead; if (!flyOverhead) { return(false); } Map map = projectile.Map; getShields(map); Vector3 destination = projectile.ExactPosition; foreach (Building building in shields) { var shield = building as Building_Shield; var generator = shield.GetComp <Comp_ShieldGenerator>(); bool isActive = (bool)generator.IsActive(); if (!isActive) { continue; } bool blockIndirect = (bool)generator.BlockIndirect_Active(); if (!blockIndirect) { continue; } int fieldRadius = (int)generator.FieldRadius_Active(); int fieldRadiusSq = fieldRadius * fieldRadius; float DistanceSq = projectile.Position.DistanceToSquared(shield.Position) - fieldRadiusSq; if (DistanceSq > 0) { continue; } HitSoundDef.PlayOneShot((SoundInfo) new TargetInfo(shield.Position, map, false)); MoteMaker.ThrowLightningGlow(destination, map, 0.5f); int damage = (projectile.def.projectile.GetDamageAmount(launcher)); generator.FieldIntegrity_Current -= damage; return(true); } return(false); }
private static bool ShieldInterceptsProjectile(Building building, ProjectileCE projectile, Thing launcher) { var shield = building as Building_Shield; if (!shield.active || !(bool)CanFunctionPropertyGetter.Invoke(shield, null) || shield.Energy == 0) { // Shield inactive, don't intercept. return(false); } if (shield.coveredCells.Contains(launcher.Position)) { return(false); } if (!shield.coveredCells.Contains(projectile.Position)) { return(false); } return(true); }