public override void UpdateLate() { foreach (KeyValuePair <Int2, NodeDetails> _nodeDetails in nodesToUpdate) { Node _node = GameGrid.GetInstance().TryGetNode(_nodeDetails.Key); RoomManager.Room _room = RoomManager.GetInstance().GetRoom(_node.RoomIndex); if (_room == null) { continue; } Color32 _lightColor = new Color32(0, 0, 0, 0); if (_nodeDetails.Value.HasDirtyLighting) { for (int _lampIndex = 0; _lampIndex < _room.Lamps.Count; _lampIndex++) { Lamp _lamp = _room.Lamps[_lampIndex]; if (_node.RoomIndex != _lamp.GetRoomIndex()) { Debug.LogErrorFormat("Somehow Node({0}) found {1} despite being in different rooms ({2} and {3})!", _node.GridPos, _lamp.name, _node.RoomIndex, _lamp.GetRoomIndex()); continue; } Int2 _distance = _node.GridPos - _lamp.GetNode().GridPos; if (Mathf.Abs(_distance.x) > _lamp.GetRadius() || Mathf.Abs(_distance.y) > _lamp.GetRadius()) { continue; } float _pathLength; bool _hasFoundPath = Task.FindPath.TryGetPathLength(_node, _lamp.GetNode(), out _pathLength); if (!_hasFoundPath) { continue; } if (_pathLength > _lamp.GetRadius()) { continue; } float _lightFromLamp = 1.0f - _pathLength / (float)_lamp.GetRadius(); _lightColor = new Color32( (byte)(_lamp.GetColor().r *_lightFromLamp), (byte)(_lamp.GetColor().g *_lightFromLamp), (byte)(_lamp.GetColor().b *_lightFromLamp), (byte)(255 * _lightFromLamp) ); } } if (_nodeDetails.Value.HasDirtyIncandescence && _node.ChemicalContainer.IsIncandescent()) { Chemical.Blob _chem_0 = _node.ChemicalContainer.Contents[0]; Chemical.Blob _chem_1 = _node.ChemicalContainer.Contents[1]; Chemical.Blob _chem_2 = _node.ChemicalContainer.Contents[2]; Color _incandescence = _node.ChemicalContainer.GetIncandescence(); _lightColor.r = (byte)Mathf.Max(_lightColor.r, _incandescence.r * 255.0f); _lightColor.g = (byte)Mathf.Max(_lightColor.g, _incandescence.g * 255.0f); _lightColor.b = (byte)Mathf.Max(_lightColor.b, _incandescence.b * 255.0f); _lightColor.a = (byte)Mathf.Max(_lightColor.a, _incandescence.a * 255.0f); } _node.SetLighting(_lightColor); } for (int i = 0; i < wallNodesToUpdate.Count; i++) { Node _node = GameGrid.GetInstance().TryGetNode(wallNodesToUpdate[i]); _node.SetLightingBasedOnNeighbors(); } nodesToUpdate.Clear(); }