public void Explode(ExploderObject.OnExplosion callback) { var settings = new ExploderSettings { Position = ExploderUtils.GetCentroid(exploder.gameObject), DontUseTag = exploder.DontUseTag, Radius = exploder.Radius, ForceVector = exploder.ForceVector, UseForceVector = exploder.UseForceVector, Force = exploder.Force, FrameBudget = exploder.FrameBudget, TargetFragments = exploder.TargetFragments, DeactivateOptions = exploder.DeactivateOptions, DeactivateTimeout = exploder.DeactivateTimeout, MeshColliders = exploder.MeshColliders, ExplodeSelf = exploder.ExplodeSelf, HideSelf = exploder.HideSelf, DestroyOriginalObject = exploder.DestroyOriginalObject, ExplodeFragments = exploder.ExplodeFragments, SplitMeshIslands = exploder.SplitMeshIslands, FragmentOptions = exploder.FragmentOptions.Clone(), Callback = callback, processing = false, }; queue.Enqueue(settings); ProcessQueue(); }
void Boom() { var centroid = ExploderUtils.GetCentroid(gameObject); // place the exploder object to centroid position exploder.transform.position = centroid; exploder.ExplodeSelf = false; // adjust force vector to be in direction from shotgun exploder.ForceVector = ForceVector; // Utils.Log("ForceVec: " + exploder.ForceVector); exploder.Force = force; exploder.UseForceVector = true; // fragment pieces exploder.TargetFragments = targetFragments; // set explosion radius to 5 meters exploder.Radius = radius; // run explosion exploder.Explode(); //Destroy (this); }
public ExploderParams(ExploderObject exploder) { Position = ExploderUtils.GetCentroid(exploder.gameObject); DontUseTag = exploder.DontUseTag; Radius = exploder.Radius; UseCubeRadius = exploder.UseCubeRadius; CubeRadius = exploder.CubeRadius; ForceVector = exploder.ForceVector; UseForceVector = exploder.UseForceVector; Force = exploder.Force; FrameBudget = exploder.FrameBudget; TargetFragments = exploder.TargetFragments; ExplodeSelf = exploder.ExplodeSelf; HideSelf = exploder.HideSelf; ThreadOptions = exploder.ThreadOption; DestroyOriginalObject = exploder.DestroyOriginalObject; SplitMeshIslands = exploder.SplitMeshIslands; FragmentOptions = exploder.FragmentOptions.Clone(); FragmentDeactivation = exploder.FragmentDeactivation.Clone(); FragmentSFX = exploder.FragmentSFX.Clone(); Use2DCollision = exploder.Use2DCollision; FragmentPoolSize = exploder.FragmentPoolSize; DisableRadiusScan = exploder.DisableRadiusScan; UniformFragmentDistribution = exploder.UniformFragmentDistribution; DisableTriangulation = exploder.DisableTriangulation; ExploderGameObject = exploder.gameObject; CuttingStyle = exploder.CuttingStyle; }
public ExploderParams(ExploderObject exploder) { this.Position = ExploderUtils.GetCentroid(((Component)exploder).get_gameObject()); this.DontUseTag = exploder.DontUseTag; this.Radius = exploder.Radius; this.UseCubeRadius = exploder.UseCubeRadius; this.CubeRadius = exploder.CubeRadius; this.ForceVector = exploder.ForceVector; this.UseForceVector = exploder.UseForceVector; this.Force = exploder.Force; this.FrameBudget = exploder.FrameBudget; this.TargetFragments = exploder.TargetFragments; this.ExplodeSelf = exploder.ExplodeSelf; this.HideSelf = exploder.HideSelf; this.ThreadOptions = exploder.ThreadOption; this.DestroyOriginalObject = exploder.DestroyOriginalObject; this.SplitMeshIslands = exploder.SplitMeshIslands; this.FragmentOptions = exploder.FragmentOptions.Clone(); this.FragmentDeactivation = exploder.FragmentDeactivation.Clone(); this.FragmentSFX = exploder.FragmentSFX.Clone(); this.Use2DCollision = exploder.Use2DCollision; this.FragmentPoolSize = exploder.FragmentPoolSize; this.DisableRadiusScan = exploder.DisableRadiusScan; this.UniformFragmentDistribution = exploder.UniformFragmentDistribution; this.DisableTriangulation = exploder.DisableTriangulation; this.ExploderGameObject = ((Component)exploder).get_gameObject(); this.CuttingStyle = exploder.CuttingStyle; }
public ExploderSettings(ExploderObject exploder) { Position = ExploderUtils.GetCentroid(exploder.gameObject); DontUseTag = exploder.DontUseTag; Radius = exploder.Radius; UseCubeRadius = exploder.UseCubeRadius; CubeRadius = exploder.CubeRadius; ForceVector = exploder.ForceVector; UseForceVector = exploder.UseForceVector; Force = exploder.Force; FrameBudget = exploder.FrameBudget; TargetFragments = exploder.TargetFragments; DeactivateOptions = exploder.DeactivateOptions; DeactivateTimeout = exploder.DeactivateTimeout; MeshColliders = exploder.MeshColliders; ExplodeSelf = exploder.ExplodeSelf; HideSelf = exploder.HideSelf; DestroyOriginalObject = exploder.DestroyOriginalObject; ExplodeFragments = exploder.ExplodeFragments; SplitMeshIslands = exploder.SplitMeshIslands; FragmentOptions = exploder.FragmentOptions.Clone(); SfxOptions = exploder.SFXOptions.Clone(); Use2DCollision = exploder.Use2DCollision; FragmentPoolSize = exploder.FragmentPoolSize; FragmentPrefab = exploder.FragmentPrefab; FadeoutOptions = exploder.FadeoutOptions; SFXOptions = exploder.SFXOptions; DisableRadiusScan = exploder.DisableRadiusScan; UniformFragmentDistribution = exploder.UniformFragmentDistribution; AllowOpenMeshCutting = exploder.AllowOpenMeshCutting; }
private bool IsInRadius(GameObject o) { var centroid = ExploderUtils.GetCentroid(o); if (core.parameters.UseCubeRadius) { var localP = core.parameters.ExploderGameObject.transform.InverseTransformPoint(centroid); var localC = core.parameters.ExploderGameObject.transform.InverseTransformPoint(core.parameters.Position); return(Mathf.Abs(localP.x - localC.x) < core.parameters.CubeRadius.x && Mathf.Abs(localP.y - localC.y) < core.parameters.CubeRadius.y && Mathf.Abs(localP.z - localC.z) < core.parameters.CubeRadius.z); } return(core.parameters.Radius * core.parameters.Radius > (centroid - core.parameters.Position).sqrMagnitude); }
void OnDrawGizmos() { if (enabled && !(ExplodeSelf && DisableRadiusScan)) { Gizmos.color = Color.red; if (UseCubeRadius) { var pos = ExploderUtils.GetCentroid(gameObject); Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawWireCube(transform.InverseTransformPoint(pos), CubeRadius); } else { Gizmos.DrawWireSphere(ExploderUtils.GetCentroid(gameObject), Radius); } } }
private void OnDrawGizmos() { if (!((Behaviour)this).get_enabled() || this.ExplodeSelf && this.DisableRadiusScan) { return; } Gizmos.set_color(Color.get_red()); if (this.UseCubeRadius) { Vector3 centroid = ExploderUtils.GetCentroid(((Component)this).get_gameObject()); Gizmos.set_matrix(((Component)this).get_transform().get_localToWorldMatrix()); Gizmos.DrawWireCube(((Component)this).get_transform().InverseTransformPoint(centroid), this.CubeRadius); } else { Gizmos.DrawWireSphere(ExploderUtils.GetCentroid(((Component)this).get_gameObject()), this.Radius); } }