public void LoadBuild(List <PlacedPart> newParts, List <PlacedPart> newInactiveParts) { this.DeleteAllIcons(); Vector2 zero = Vector2.zero; Vector2 zero2 = Vector2.zero; PartGrid.GetMinMax(newParts, ref zero2, ref zero); Vector2 vector = new Vector2(Mathf.Max(0f, zero.x - this.width), Mathf.Max(0f, zero.y - (this.height - 0.5f))); Vector2 b = new Vector2(Mathf.Min(zero2.x, vector.x), Mathf.Min(zero2.y, vector.y)); for (int i = 0; i < newParts.Count; i++) { newParts[i].position -= b; } if (!Ref.hasPartsExpansion) { for (int j = 0; j < newParts.Count; j++) { if (newParts[j].partData.inFull) { newInactiveParts.Add(newParts[j]); newParts.RemoveAt(j); j--; } } } this.parts = newParts; this.inactiveParts = newInactiveParts; this.LoadAllIcons(); }
public static void CenterParts(List <PlacedPart> parts, Vector2 targetCenter) { Vector2 zero = Vector2.zero; Vector2 zero2 = Vector2.zero; PartGrid.GetMinMax(parts, ref zero2, ref zero); Vector2 b = (zero2 + zero) / 2f - targetCenter; for (int i = 0; i < parts.Count; i++) { parts[i].position -= b; } }