public Element(global::Element e, List <global::Element> elements) { id = e.id; state = (byte)e.state; if (e.HasTag(GameTags.Unstable)) { state |= 8; } int num = elements.FindIndex((global::Element ele) => ele.id == e.lowTempTransitionTarget); int num2 = elements.FindIndex((global::Element ele) => ele.id == e.highTempTransitionTarget); lowTempTransitionIdx = (byte)((num < 0) ? 255 : num); highTempTransitionIdx = (byte)((num2 < 0) ? 255 : num2); elementsTableIdx = (byte)elements.IndexOf(e); specificHeatCapacity = e.specificHeatCapacity; thermalConductivity = e.thermalConductivity; solidSurfaceAreaMultiplier = e.solidSurfaceAreaMultiplier; liquidSurfaceAreaMultiplier = e.liquidSurfaceAreaMultiplier; gasSurfaceAreaMultiplier = e.gasSurfaceAreaMultiplier; molarMass = e.molarMass; strength = e.strength; flow = e.flow; viscosity = e.viscosity; minHorizontalFlow = e.minHorizontalFlow; minVerticalFlow = e.minVerticalFlow; maxMass = e.maxMass; lowTemp = e.lowTemp; highTemp = e.highTemp; highTempTransitionOreID = e.highTempTransitionOreID; highTempTransitionOreMassConversion = e.highTempTransitionOreMassConversion; lowTempTransitionOreID = e.lowTempTransitionOreID; lowTempTransitionOreMassConversion = e.lowTempTransitionOreMassConversion; sublimateIndex = (sbyte)elements.FindIndex((global::Element ele) => ele.id == e.sublimateId); convertIndex = (sbyte)elements.FindIndex((global::Element ele) => ele.id == e.convertId); pack0 = 0; pack1 = 0; if (e.substance == null) { colour = 0u; } else { Color32 color = e.substance.colour; colour = (uint)((color.a << 24) | (color.b << 16) | (color.g << 8) | color.r); } sublimateFX = e.sublimateFX; lightAbsorptionFactor = e.lightAbsorptionFactor; defaultValues = e.defaultValues; }
/// <summary> /// Spawns an FX object only if it is on screen. /// </summary> private static void SpawnFXIf(Game instance, SpawnFXHashes fx, Vector3 position, float rotation, Sublimates caller) { if (caller != null && instance != null) { int cell = Grid.PosToCell(caller); // GetMyWorldId but with precomputed cell if (Grid.IsValidCell(cell)) { byte id = Grid.WorldIdx[cell]; Grid.GetVisibleExtents(out int minX, out int minY, out int maxX, out int maxY); Grid.CellToXY(cell, out int x, out int y); if (id != ClusterManager.INVALID_WORLD_IDX && ClusterManager.Instance. activeWorldId == id && Grid.IsVisible(cell) && x >= minX && x <= maxX && y >= minY && y <= maxY) { // Properly do the Z layer setting position.z = Grid.GetLayerZ(Grid.SceneLayer.Front); instance.SpawnFX(fx, position, rotation); } } } }