public void Run(RenderMeshContext context) { Element element = null; for (int i = start; i != end; i++) { ConduitFlow.Conduit conduit = context.outer.flowManager.soaInfo.GetConduit(context.visible_conduits[i]); ConduitFlow.ConduitFlowInfo lastFlowInfo = conduit.GetLastFlowInfo(context.outer.flowManager); ConduitFlow.ConduitContents initialContents = conduit.GetInitialContents(context.outer.flowManager); if (lastFlowInfo.contents.mass > 0f) { int cell = conduit.GetCell(context.outer.flowManager); int cellFromDirection = ConduitFlow.GetCellFromDirection(cell, lastFlowInfo.direction); Vector2I v = Grid.CellToXY(cell); Vector2I vector2I = Grid.CellToXY(cellFromDirection); Vector2 pos = (cell != -1) ? Vector2.Lerp(new Vector2((float)v.x, (float)v.y), new Vector2((float)vector2I.x, (float)vector2I.y), context.lerp_percent) : ((Vector2)v); Color32 cellTintColour = context.outer.GetCellTintColour(cell); Color32 cellTintColour2 = context.outer.GetCellTintColour(cellFromDirection); Color32 color = Color32.Lerp(cellTintColour, cellTintColour2, context.lerp_percent); bool highlight = false; if (context.outer.showContents) { if (lastFlowInfo.contents.mass >= initialContents.mass) { moving_balls.Add(new Ball(lastFlowInfo.direction, pos, color, context.outer.tuning.size, false, false)); } if (element == null || lastFlowInfo.contents.element != element.id) { element = ElementLoader.FindElementByHash(lastFlowInfo.contents.element); } } else { element = null; int num = Grid.PosToCell(new Vector3(pos.x + GRID_OFFSET.x, pos.y + GRID_OFFSET.y, 0f)); highlight = (num == context.outer.highlightedCell); } Color32 contentsColor = context.outer.GetContentsColor(element, color); float num2 = 1f; if (context.outer.showContents || lastFlowInfo.contents.mass < initialContents.mass) { num2 = context.outer.CalculateMassScale(lastFlowInfo.contents.mass); } moving_balls.Add(new Ball(lastFlowInfo.direction, pos, contentsColor, context.outer.tuning.size * num2, true, highlight)); moving_conduits.Add(conduit); } if (initialContents.mass > lastFlowInfo.contents.mass && initialContents.mass > 0f) { int cell2 = conduit.GetCell(context.outer.flowManager); Vector2I v2 = Grid.CellToXY(cell2); Vector2 pos2 = v2; float mass = initialContents.mass - lastFlowInfo.contents.mass; bool highlight2 = false; Color32 cellTintColour3 = context.outer.GetCellTintColour(cell2); float num3 = context.outer.CalculateMassScale(mass); if (context.outer.showContents) { static_balls.Add(new Ball(ConduitFlow.FlowDirections.None, pos2, cellTintColour3, context.outer.tuning.size * num3, false, false)); if (element == null || initialContents.element != element.id) { element = ElementLoader.FindElementByHash(initialContents.element); } } else { element = null; highlight2 = (cell2 == context.outer.highlightedCell); } Color32 contentsColor2 = context.outer.GetContentsColor(element, cellTintColour3); static_balls.Add(new Ball(ConduitFlow.FlowDirections.None, pos2, contentsColor2, context.outer.tuning.size * num3, true, highlight2)); } } }