public void OnHit() { #if DEBUG if (true) #else if (ThisSeamoth.CanPilot() && ThisSeamoth.GetPilotingMode()) #endif { Vector3 pos = Vector3.zero; GameObject hitObject = null; drillTarget = null; UWE.Utils.TraceFPSTargetPosition(ThisSeamoth.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 <SeamothDrillable>(); loopHit.Play(); if (drillable) { drillable.OnDrill(fxSpawnPoint.position, ThisSeamoth, 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(); } } }
public override void OnToolUseAnim(GUIHand hand) { Vector3 position = new Vector3(); GameObject closestObj = null; #if SUBNAUTICA_STABLE UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, this.attackDist, ref closestObj, ref position); #elif BELOWZERO Vector3 normal = new Vector3(); UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, this.attackDist, ref closestObj, ref position, out normal); #endif if (closestObj == null) { InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>(); if (component != null && component.GetMostRecent() != null) { closestObj = component.GetMostRecent().gameObject; } } if (closestObj != null) { LiveMixin ancestor = closestObj.FindAncestor <LiveMixin>(); if (Knife.IsValidTarget(ancestor)) { if (ancestor != null) { bool wasAlive = ancestor.IsAlive(); float thisDamage = this.damage * (closestObj.GetComponent <Creature>() != null ? FaunaDamageMultiplier : 1f); ancestor.TakeDamage(thisDamage, position, this.damageType); this.GiveResourceOnDamage(closestObj, ancestor.IsAlive(), wasAlive); } #if SUBNAUTICA_STABLE Utils.PlayFMODAsset(this.attackSound, this.transform); VFXSurface component = closestObj.GetComponent <VFXSurface>(); Vector3 euler = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0.0f); VFXSurfaceTypeManager.main.Play(component, this.vfxEventType, position, Quaternion.Euler(euler), Player.main.transform); } else { closestObj = (GameObject)null; } #elif BELOWZERO } VFXSurface component = closestObj.GetComponent <VFXSurface>(); Vector3 euler = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0.0f); VFXSurfaceTypeManager.main.Play(component, this.vfxEventType, position, Quaternion.Euler(euler), Player.main.transform); VFXSurfaceTypes vfxSurfaceTypes = Utils.GetObjectSurfaceType(closestObj); if (vfxSurfaceTypes == VFXSurfaceTypes.none) { vfxSurfaceTypes = Utils.GetTerrainSurfaceType(position, normal, VFXSurfaceTypes.sand); } EventInstance fmodEvent = Utils.GetFMODEvent(this.hitSound, this.transform.position); int num1 = (int)fmodEvent.setParameterValueByIndex(this.surfaceParamIndex, (float)vfxSurfaceTypes); int num2 = (int)fmodEvent.start(); int num3 = (int)fmodEvent.release(); #endif }