public bool WillProjectileBeBlocked(Verse.Projectile projectile) { IEnumerable <Building_Shield> _ShieldBuildings = map.listerBuildings.AllBuildingsColonistOfClass <Building_Shield>(); Building_Shield _BlockingShield = _ShieldBuildings.FirstOrFallback(x => x.WillProjectileBeBlocked(projectile)); if (_BlockingShield != null) { //全部转移到hit函数里去处理 _BlockingShield.GetComp <Comp_ShieldGenerator>().HitShield(projectile); //_BlockingShield.TakeDamageFromProjectile(projectile); //On hit effects //MoteMaker.ThrowLightningGlow(projectile.ExactPosition, this.map, 0.5f); //On hit sound //HitSoundDef.PlayOneShot((SoundInfo)new TargetInfo(projectile.Position, projectile.Map, false)); //projectile.Destroy(); return(true); } return(false); }
public bool WillProjectileBeBlocked(Verse.Projectile projectile) { // Dont intercept projectiles without a Damage Def - Fire Spread if (projectile.def.projectile.damageDef == null) { return(false); } IEnumerable <Building_Shield> _ShieldBuildings = map.listerBuildings.AllBuildingsColonistOfClass <Building_Shield>(); Building_Shield _BlockingShield = _ShieldBuildings.FirstOrFallback(x => x.WillProjectileBeBlocked(projectile)); if (_BlockingShield != null) { _BlockingShield.TakeDamageFromProjectile(projectile); //On hit effects MoteMaker.ThrowLightningGlow(projectile.ExactPosition, this.map, 0.5f); //On hit sound HitSoundDef.PlayOneShot((SoundInfo) new TargetInfo(projectile.Position, projectile.Map, false)); projectile.Destroy(); return(true); } return(false); }
public bool WillProjectileBeBlocked(Verse.Projectile projectile) { //Check if online if (this.CurrentStatus == EnumShieldStatus.Offline || this.CurrentStatus == EnumShieldStatus.Initilising) { return(false); } //Check if can and wants to intercept if (projectile.def.projectile.flyOverhead) { if (!this.BlockIndirect_Active()) { return(false); } } else { if (!this.BlockDirect_Active()) { return(false); } } //Check Distance float _Distance = Vector3.Distance(projectile.Position.ToVector3(), this.parent.Position.ToVector3()); if (_Distance > this.FieldRadius_Active()) { return(false); } //Check Angle if (!Comp_ShieldGenerator.CorrectAngleToIntercept(projectile, this.parent)) { return(false); } //Check IFF if (this.IdentifyFriendFoe_Active()) { FieldInfo _LauncherFieldInfo = typeof(Projectile).GetField("launcher", BindingFlags.NonPublic | BindingFlags.Instance); Patch.Patcher.LogNULL(_LauncherFieldInfo, "_LauncherFieldInfo"); Thing _Launcher = (Thing)_LauncherFieldInfo.GetValue(projectile); //Patch.Patcher.LogNULL(_Launcher, "_Launcher"); if (_Launcher == null) { return(false); } if (_Launcher.Faction.IsPlayer) { return(false); } } return(true); }
public bool WillProjectileBeBlocked(Verse.Projectile projectile) { IEnumerable<Building_Shield> _ShieldBuildings = map.listerBuildings.AllBuildingsColonistOfClass<Building_Shield>(); Building_Shield _BlockingShield = _ShieldBuildings.FirstOrFallback(x => x.WillProjectileBeBlocked(projectile)); if (_BlockingShield != null) { _BlockingShield.TakeDamageFromProjectile(projectile); //On hit effects FleckMaker.ThrowLightningGlow(projectile.ExactPosition, this.map, 0.5f); //On hit sound HitSoundDef.PlayOneShot((SoundInfo)new TargetInfo(projectile.Position, projectile.Map, false)); projectile.Destroy(); return true; } return false; }