private void Sweep() { while (tempColliders.Count > 0) { DestroyableHelper.Destroy(tempColliders.Pop()); } }
public void UpdateFixtures() { if (Fixtures.Count > 0) { for (var i = Fixtures.Count - 1; i >= 0; i--) { var fixture = Fixtures[i]; if (FixtureIsConnected(fixture) == false) { Fixtures.RemoveAt(i); } } if (Fixtures.Count == 0) { if (OnAllFixturesRemoved != null) { OnAllFixturesRemoved.Invoke(); } if (AutoDestroy == true) { DestroyableHelper.Destroy(this); } } } }
protected virtual void OnDisable() { destructible.OnAlphaDataReplaced.RemoveListener(OnAlphaDataReplaced); destructible.OnAlphaDataModified.RemoveListener(OnAlphaDataModified); destructible.OnAlphaDataSubset.RemoveListener(OnAlphaDataSubset); destructible.OnStartSplit.RemoveListener(OnStartSplit); destructible.OnEndSplit.RemoveListener(OnEndSplit); if (child != null) { child.SetActive(false); } if (destructible.IsOnStartSplit == true) { if (child != null) { child.transform.SetParent(null, false); child = DestroyableHelper.Destroy(child); } if (tempChild != null) { tempChild = DestroyableHelper.Destroy(tempChild); } } }
public void CombineData(byte[] prevData, int prevWidth, int prevHeight) { var dataX = Rect.MinX; var dataY = Rect.MinY; var dataWidth = Rect.SizeX; var dataHeight = Rect.SizeY; if (Data != null && Data.Length >= dataWidth * dataHeight && prevData != null && prevData.Length >= prevWidth * prevHeight) { for (var y = 0; y < dataHeight; y++) { for (var x = 0; x < dataWidth; x++) { var prevX = x + dataX; var prevY = y + dataY; var dataI = x + y * dataWidth; if (prevX >= 0 && prevY >= 0 && prevX < prevWidth && prevY < prevHeight) { var prevI = prevX + prevY * prevWidth; var dataA = DestroyableHelper.ConvertAlpha(Data[dataI]); var prevA = DestroyableHelper.ConvertAlpha(prevData[prevI]); Data[dataI] = DestroyableHelper.ConvertAlpha(dataA * prevA); } else { Data[dataI] = 0; } } } } }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); { Target = (T)target; Targets = targets.Select(t => (T)t).ToArray(); Separator(); OnInspector(); Separator(); serializedObject.ApplyModifiedProperties(); } if (EditorGUI.EndChangeCheck() == true) { GUI.changed = true; Repaint(); foreach (var t in Targets) { DestroyableHelper.SetDirty(t); } } }
public void DestroyChild() { if (child != null) { child = DestroyableHelper.Destroy(child); } }
protected void DirtyEach(System.Action <T> update) { foreach (var t in Targets) { update(t); DestroyableHelper.SetDirty(t); } }
public virtual void OnSceneGUI() { Target = (T)target; OnScene(); if (GUI.changed == true) { DestroyableHelper.SetDirty(target); } }
protected virtual void Awake() { if (this.GetComponent <Collider2D>() != null) { var collider2Ds = this.GetComponents <Collider2D>(); for (var i = collider2Ds.Length - 1; i >= 0; i--) { DestroyableHelper.Destroy(collider2Ds[i]); } } }
public void AddTriangle(DestroyableVector2Operator a, DestroyableVector2Operator b, DestroyableVector2Operator c) { if (a.Y != b.Y || a.Y != c.Y) { //var z = (a.V + b.V + c.V) / 3.0f; //var z1 = Vector3.MoveTowards(a.V, z, 1.0f); //var z2 = Vector3.MoveTowards(b.V, z, 1.0f); //var z3 = Vector3.MoveTowards(c.V, z, 1.0f); //Debug.DrawLine(z1, z2, Color.red, 10.0f); //Debug.DrawLine(z2, z3, Color.red, 10.0f); //Debug.DrawLine(z3, z1, Color.red, 10.0f); if (b.Y > a.Y) { DestroyableHelper.Swap(ref a, ref b); } if (c.Y > a.Y) { DestroyableHelper.Swap(ref c, ref a); } if (c.Y > b.Y) { DestroyableHelper.Swap(ref b, ref c); } var fth = a.Y - c.Y; var tth = a.Y - b.Y; var bth = b.Y - c.Y; var inx = c.X + (a.X - c.X) * DestroyableHelper.Divide(bth, fth); var d = new DestroyableVector2Operator((int)inx, b.Y); var abs = DestroyableHelper.Divide(a.X - b.X, tth); var ads = DestroyableHelper.Divide(a.X - d.X, tth); AddTriangle(b.X, d.X, abs, ads, b.Y, 1, tth); var cbs = DestroyableHelper.Divide(c.X - b.X, bth); var cds = DestroyableHelper.Divide(c.X - d.X, bth); AddTriangle(b.X, d.X, cbs, cds, b.Y, -1, bth); } }
public void AddTriangle(float l, float r, float ls, float rs, int y, int s, int c) { if (l > r) { DestroyableHelper.Swap(ref l, ref r); DestroyableHelper.Swap(ref ls, ref rs); } for (var i = 0; i < c; i++) { var il = Mathf.FloorToInt(l); var ir = Mathf.CeilToInt(r); for (var x = il; x < ir; x++) { AddPixel(x, y); } y += s; l += ls; r += rs; } }
protected void DrawDefault(string propertyPath, bool autoApply = true) { EditorGUI.BeginChangeCheck(); { EditorGUILayout.BeginVertical(DestroyableHelper.NoError); { EditorGUILayout.PropertyField(serializedObject.FindProperty(propertyPath), true); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck() == true) { if (autoApply == true) { serializedObject.ApplyModifiedProperties(); } for (var i = Targets.Length - 1; i >= 0; i--) { DestroyableHelper.SetDirty(Targets[i]); } } }
private void MarkDirty() { Each(t => DestroyableHelper.SetDirty(t)); }
protected bool Button(string text) { var rect = DestroyableHelper.Reserve(); return(GUI.Button(rect, text)); }
private void DestroyFixture() { DestroyableHelper.Destroy(gameObject); }