Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
CompShieldBubble - Sound NRE fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KylianB committed Feb 17, 2022
1 parent c650605 commit 29f7f38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Binary file modified 1.3/Assemblies/VFECore.dll
Binary file not shown.
23 changes: 17 additions & 6 deletions Source/VFECore/VFECore/Comps/ThingComps/CompShieldBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public CompProperties_ShieldBubble()
public Color shieldColor = Color.white;
public float EnergyLossPerDamage = 1f;
public bool disableRotation;
public SoundDef absorbDamageSound = SoundDefOf.EnergyShield_AbsorbDamage;
public SoundDef brokenSound = SoundDefOf.EnergyShield_Broken;
public SoundDef resetSound = SoundDefOf.EnergyShield_Reset;
public SoundDef absorbDamageSound;
public SoundDef brokenSound;
public SoundDef resetSound;
}

[StaticConstructorOnStartup]
Expand Down Expand Up @@ -290,7 +290,11 @@ public void KeepDisplaying()
}
private void AbsorbedDamage(DamageInfo dinfo)
{
Props.absorbDamageSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
if (Props.absorbDamageSound != null)
Props.absorbDamageSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
else
SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));

impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
Vector3 loc = this.Pawn.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;
float num = Mathf.Min(10f, 2f + dinfo.Amount / 10f);
Expand All @@ -310,7 +314,10 @@ protected virtual void Break()
{
if (this.Pawn?.Map != null && this.Pawn.Position.InBounds(this.Pawn.Map))
{
Props.brokenSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
if (Props.brokenSound != null)
Props.brokenSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
else
SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));

FleckMaker.Static(this.Pawn.TrueCenter(), this.Pawn.Map, FleckDefOf.ExplosionFlash, 12f);
for (int i = 0; i < 6; i++)
Expand All @@ -327,7 +334,11 @@ protected virtual void Reset()
{
if (this.Pawn.Spawned)
{
Props.resetSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
if (Props.resetSound != null)
Props.resetSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
else
SoundDefOf.EnergyShield_Reset.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));

FleckMaker.ThrowLightningGlow(this.Pawn.TrueCenter(), this.Pawn.Map, 3f);
}

Expand Down

0 comments on commit 29f7f38

Please sign in to comment.