public object GetDestinationValue(object mappedObject) { return(DestinationProperty.GetValue(mappedObject)); return(UseDestinationValue ? DestinationProperty.GetValue(mappedObject) : null); }
static bool Prefix(ProjectileCE __instance) { if (!Enabled) { return(true); } var projectile = __instance; var flightTicks = (float)FTicksProperty.GetValue(projectile, null); var startingTicksToImpact = (float)StartingTicksToImpactProperty.GetValue(projectile, null); var origin = (Vector2)OriginField.GetValue(projectile); var destination = (Vector2)DestinationProperty.GetValue(projectile, null); var position3 = Common.ToVector3(Vector2.Lerp(origin, destination, flightTicks / startingTicksToImpact), projectile.Height); var origin3 = Common.ToVector3(origin); var destination3 = Common.ToVector3(destination); try { if (projectile.def.projectile.flyOverhead) { if (projectile.def.projectile.flyOverhead) { // the shield has blocked the projectile - invert to get if harmony should allow the original block return(!Mod.ShieldManager.ImpactShield(projectile.Map, position3, origin3, destination3, (shield, vector3) => { if (shield.Damage(projectile.def.projectile.damageAmountBase, position3)) { projectile.Destroy(); return true; } return false; })); } } else { var nextTick = flightTicks + 1; var nextHeight = (float)GetHeightAtTicksMethod.Invoke(projectile, new object[] { (int)nextTick }); var nextPosition = Common.ToVector3(Vector2.Lerp(origin, destination, nextTick / startingTicksToImpact), nextHeight); var ray = new Ray(position3, nextPosition - position3); // the shield has blocked the projectile - invert to get if harmony should allow the original block return(!Mod.ShieldManager.ImpactShield(projectile.Map, origin3, ray, 1, (shield, point) => { if (shield.Damage(projectile.def.projectile.damageAmountBase, point)) { projectile.GetComp <CompExplosiveCE>()?. Explode( (Thing)LauncherField.GetValue(projectile), new Vector3(point.x, 0, point.y), projectile.Map); projectile.Destroy(); return true; } return false; })); } } catch (InvalidOperationException) {} return(true); }