private void DrawWavesOnHit(ICollection <ForceFieldEffectInstanceNode> effects, Vector3 hitPosition, bool playSound) { foreach (ForceFieldEffectInstanceNode node in effects) { ForceFieldEffect component = node.effectInstance.GameObject.GetComponent <ForceFieldEffect>(); MeshCollider outerMeshCollider = component.outerMeshCollider; if (Vector3.Distance(hitPosition, outerMeshCollider.ClosestPointOnBounds(hitPosition)) < 0.1f) { component.DrawWave(hitPosition, playSound); } } }
public void CreateVisualEffect(NodeAddedEvent e, SingleNode <PreloadedModuleEffectsComponent> mapEffect, [Combine] ForceFieldEffectTransformNode effect) { GameObject original = mapEffect.component.PreloadedEffects["forcefield"]; if (original) { GameObject gameObject = Object.Instantiate <GameObject>(original, null); gameObject.SetActive(true); gameObject.transform.SetPositionSafe(effect.forceFieldTranform.Movement.Position); gameObject.transform.SetRotationSafe(effect.forceFieldTranform.Movement.Orientation); gameObject.GetComponent <EntityBehaviour>().BuildEntity(effect.Entity); gameObject.SetActive(true); ForceFieldEffect component = gameObject.GetComponent <ForceFieldEffect>(); component.Show(); component.SetLayer(Layers.VISUAL_STATIC); effect.Entity.AddComponent(new EffectInstanceComponent(gameObject)); gameObject.AddComponent <Rigidbody>().isKinematic = true; ForcefieldTargetBehaviour behaviour = gameObject.AddComponent <ForcefieldTargetBehaviour>(); behaviour.OwnerTeamCanShootThrough = effect.forceFieldEffect.OwnerTeamCanShootThrough; behaviour.Init(effect.Entity, null); } }