/// <summary> /// Registers a surface def to the surface def catalog. /// </summary> /// <param name="surfaceDef">The surface def to register</param> public static void RegisterSurfaceDef(SurfaceDef surfaceDef) { //Check if the SurvivorDef has already been registered. if (SurfaceDefDefinitions.Contains(surfaceDef)) { LogCore.LogE(surfaceDef + " has already been registered, please do not register the same SurfaceDef twice."); return; } //If not, add it to our SurvivorDefinitions SurfaceDefDefinitions.Add(surfaceDef); }
private bool CheckForWaterOld(Vector3 position, bool below = true) { if (Physics.Raycast(new Ray(position + Vector3.up * 1.5f, below ? Vector3.down : Vector3.up), out RaycastHit raycastHit, below ? 4f : 8f, LayerIndex.world.mask | LayerIndex.water.mask, QueryTriggerInteraction.Collide)) { SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(raycastHit.collider, raycastHit.point); if (objectSurfaceDef) { if (objectSurfaceDef == waterSD) { return(true); } } } return(false); }
public static bool CheckForWater(Vector3 position, float castDistance = 8f) { var layerMask = LayerIndex.world.mask | LayerIndex.water.mask; if (Physics.Raycast(new Ray(position + Vector3.up * castDistance, Vector3.down), out RaycastHit raycastHit, castDistance, layerMask, QueryTriggerInteraction.Collide) || Physics.Raycast(new Ray(position + Vector3.down * castDistance, Vector3.up), out raycastHit, castDistance, layerMask, QueryTriggerInteraction.Collide)) { SurfaceDef objSurfDefDown = SurfaceDefProvider.GetObjectSurfaceDef(raycastHit.collider, raycastHit.point); if (objSurfDefDown && objSurfDefDown == waterSD) { return(true); } } return(false); }
/// <summary> /// Adds a SurfaceDef to your Mod's ContentPack /// <para>Requires the surfaceDef's impactEffect or footstepEffect prefabs to not be null</para> /// </summary> /// <param name="surfaceDef">The SurfaceDef to Add</param> /// <returns>true if valid and added, false if one of the requirements is not met</returns> public static bool AddSurfaceDef(SurfaceDef surfaceDef) { var asm = Assembly.GetCallingAssembly(); if (CatalogBlockers.GetAvailability <SurfaceDef>()) { if (surfaceDef.impactEffectPrefab == null || surfaceDef.footstepEffectPrefab == null) { RejectContent(surfaceDef, asm, "SurfaceDef", $"but one of it's effect prefabs are null! this is not allowed!"); return(false); } R2APIContentManager.HandleContentAddition(asm, surfaceDef); return(true); } RejectContent(surfaceDef, asm, "SurfaceDef", "but the SurfaceDefCatalog has already initialized!"); return(false); }
private void ProcessHits(List <ExtendedOverlapAttack.OverlapInfo> hitList) { if (hitList.Count == 0) { return; } Vector3 vector = Vector3.zero; float d = 1f / (float)hitList.Count; for (int i = 0; i < hitList.Count; i++) { ExtendedOverlapAttack.OverlapInfo overlapInfo = hitList[i]; if (this.hitEffectPrefab) { Vector3 forward = -hitList[i].pushDirection; EffectManager.SpawnEffect(this.hitEffectPrefab, new EffectData { origin = overlapInfo.hitPosition, rotation = Util.QuaternionSafeLookRotation(forward), }, true); Util.PlaySound("Play_MULT_shift_hit", this.hitEffectPrefab.gameObject); } vector += overlapInfo.hitPosition * d; SurfaceDefProvider component = hitList[i].hurtBox.GetComponent <SurfaceDefProvider>(); if (component && component.surfaceDef) { SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(hitList[i].hurtBox.collider, hitList[i].hitPosition); if (objectSurfaceDef) { if (objectSurfaceDef.impactEffectPrefab) { EffectManager.SpawnEffect(objectSurfaceDef.impactEffectPrefab, new EffectData { origin = overlapInfo.hitPosition, rotation = ((overlapInfo.pushDirection == Vector3.zero) ? Quaternion.identity : Util.QuaternionSafeLookRotation(overlapInfo.pushDirection)), color = objectSurfaceDef.approximateColor, scale = 2f }, true); } if (objectSurfaceDef.impactSoundString != null && objectSurfaceDef.impactSoundString.Length != 0) { Util.PlaySound(objectSurfaceDef.impactSoundString, hitList[i].hurtBox.gameObject); } } } } this.lastFireAverageHitPosition = vector; //Since we're the server, we can do damage pretty freely. if (NetworkServer.active) { ExtendedOverlapAttack.PerformDamage(this.attacker, this.inflictor, this.damage, this.isCrit, this.procChainMask, this.procCoefficient, this.damageColorIndex, this.damageType, this.forceVector, this.pushAwayForce, this.upwardsForce, hitList); return; } ExtendedOverlapAttack.outgoingMessage.attacker = this.attacker; ExtendedOverlapAttack.outgoingMessage.inflictor = this.inflictor; ExtendedOverlapAttack.outgoingMessage.damage = this.damage; ExtendedOverlapAttack.outgoingMessage.isCrit = this.isCrit; ExtendedOverlapAttack.outgoingMessage.procChainMask = this.procChainMask; ExtendedOverlapAttack.outgoingMessage.procCoefficient = this.procCoefficient; ExtendedOverlapAttack.outgoingMessage.damageColorIndex = this.damageColorIndex; ExtendedOverlapAttack.outgoingMessage.damageType = this.damageType; ExtendedOverlapAttack.outgoingMessage.forceVector = this.forceVector; ExtendedOverlapAttack.outgoingMessage.pushAwayForce = this.pushAwayForce; ExtendedOverlapAttack.outgoingMessage.upwardsForce = this.upwardsForce; Util.CopyList <ExtendedOverlapAttack.OverlapInfo>(hitList, ExtendedOverlapAttack.outgoingMessage.overlapInfoList); GameNetworkManager.singleton.client.connection.SendByChannel(7595, ExtendedOverlapAttack.outgoingMessage, QosChannelIndex.defaultReliable.intVal); }