private void StopEffects() { if (drillFXinstance != null) { VFXLateTimeParticles component = drillFXinstance.GetComponent <VFXLateTimeParticles>(); component.Stop(); Destroy(drillFXinstance.gameObject, 1.6f); drillFXinstance = null; } if (fxControl.emitters[0].fxPS != null && fxControl.emitters[0].fxPS.emission.enabled) { fxControl.Stop(0); } loop.Stop(); loopHit.Stop(); }
public void OnHit() { if (Exosuit.CanPilot() && Exosuit.GetPilotingMode()) { Vector3 pos = Vector3.zero; GameObject hitObject = null; drillTarget = null; UWE.Utils.TraceFPSTargetPosition(Exosuit.gameObject, attackDist, ref hitObject, ref pos, true); if (hitObject == null) { InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>(); if (component != null && component.GetMostRecent() != null) { hitObject = component.GetMostRecent().gameObject; } } if (hitObject && drilling) { var drillable = hitObject.FindAncestor <Drillable>(); loopHit.Play(); if (drillable) { drillable.OnDrill(fxSpawnPoint.position, Exosuit, out GameObject gameObject2); if (!gameObject2) { StopEffects(); } drillTarget = gameObject2; if (fxControl.emitters[0].fxPS != null && !fxControl.emitters[0].fxPS.emission.enabled) { fxControl.Play(0); } } else { LiveMixin liveMixin = hitObject.FindAncestor <LiveMixin>(); if (liveMixin) { bool flag = liveMixin.IsAlive(); liveMixin.TakeDamage(4f, pos, DamageType.Drill, null); drillTarget = hitObject; } VFXSurface component2 = hitObject.GetComponent <VFXSurface>(); if (drillFXinstance == null) { drillFXinstance = VFXSurfaceTypeManager.main.Play(component2, vfxEventType, fxSpawnPoint.position, fxSpawnPoint.rotation, fxSpawnPoint); } else if (component2 != null && prevSurfaceType != component2.surfaceType) { VFXLateTimeParticles component3 = drillFXinstance.GetComponent <VFXLateTimeParticles>(); component3.Stop(); Destroy(drillFXinstance.gameObject, 1.6f); drillFXinstance = VFXSurfaceTypeManager.main.Play(component2, vfxEventType, fxSpawnPoint.position, fxSpawnPoint.rotation, fxSpawnPoint); prevSurfaceType = component2.surfaceType; } hitObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver); } } else { StopEffects(); } } }