public static void Free <T>(this HashSet <T> hashSet) { HashSetPool <T> .Free(hashSet); }
private void DrawHandle() { // Trying to be very speed / memory efficient in this method if (!e.IsRepaint) { return; } var color = Color.white; var highlight = false; var invalid = false; var willDisconnect = false; var connections = HashSetPool <IUnitConnection> .New(); GetConnectionsNoAlloc(connections); var isConnected = connections.Count > 0; if (isConnected) { foreach (var connection in connections) { if (connection is InvalidConnection) { invalid = true; } var sourceWidget = canvas.Widget <IUnitPortWidget>(connection.source); var destinationWidget = canvas.Widget <IUnitPortWidget>(connection.destination); if (sourceWidget.isMouseOver || destinationWidget.isMouseOver) { highlight = true; } if (sourceWidget.willDisconnect || destinationWidget.willDisconnect) { willDisconnect = true; } } } if (isMouseOver) { highlight = true; } if (willDisconnect) { color = UnitConnectionStyles.disconnectColor; } else if (highlight) { color = UnitConnectionStyles.highlightColor; } else if (invalid) { color = UnitConnectionStyles.invalidColor; } else if (canvas.isCreatingConnection && (canvas.connectionSource == port || canvas.connectionSource.CanValidlyConnectTo(port))) { color = this.color; } else if (isConnected) { Color?resolvedColor = null; foreach (var connection in connections) { var connectionColor = canvas.Widget <IUnitConnectionWidget>(connection).color; if (resolvedColor == null) { resolvedColor = connectionColor; } else if (resolvedColor != connectionColor) { resolvedColor = this.color; break; } } color = resolvedColor.Value; } if (colorIfActive) { foreach (var connection in connections) { var connectionEditorData = reference.GetElementDebugData <IUnitConnectionDebugData>(connection); if (EditorApplication.isPaused) { if (EditorTimeBinding.frame == connectionEditorData.lastInvokeFrame) { color = UnitConnectionStyles.activeColor; break; } } else { color = Color.Lerp(UnitConnectionStyles.activeColor, color, (EditorTimeBinding.time - connectionEditorData.lastInvokeTime) / UnitWidget <IUnit> .Styles.invokeFadeDuration); } } } var handlePosition = this.handlePosition; if (highlight) { var widthExpansion = handlePosition.width * (Styles.highlightScaling - 1); var heightExpansion = handlePosition.height * (Styles.highlightScaling - 1); handlePosition.width += widthExpansion; handlePosition.height += heightExpansion; handlePosition.x -= widthExpansion / 2; handlePosition.y -= heightExpansion / 2; } if (highlight || isConnected || canvas.connectionSource == port || canvas.isCreatingConnection && canvas.connectionSource.CanValidlyConnectTo(port)) { using (LudiqGUI.color.Override(color.WithAlphaMultiplied(LudiqGUI.color.value.a * 0.85f))) // Full color is a bit hard on the eyes { if (handleTextureConnected != null) { GUI.DrawTexture(handlePosition, handleTextureConnected); } } } else { if (handleTextureUnconnected != null) { GUI.DrawTexture(handlePosition, handleTextureUnconnected); } } HashSetPool <IUnitConnection> .Free(connections); }
private static void FreeEventsToTrigger <TEvent>(HashSet <TEvent> toTrigger) where TEvent : MachineEvent { HashSetPool <TEvent> .Free(toTrigger); }
public void Recycle() { HashSetPool <ObjectType, PoolIdentifier> .Free(this); }