mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
better null checking
This commit is contained in:
parent
ece9d959fd
commit
d3388a4dad
@ -577,20 +577,11 @@ namespace ConformalDecals {
|
||||
|
||||
public void Render(Camera camera) {
|
||||
if (!_isAttached) return;
|
||||
|
||||
try {
|
||||
// render on each target object
|
||||
foreach (var target in _targets) {
|
||||
target.Render(_decalMaterial, part.mpb, camera);
|
||||
}
|
||||
} catch (NullReferenceException) {
|
||||
// catch any NREs and purge null transforms from the target list
|
||||
// comparing Transform to null is expensive, but a try-catch block is much cheaper
|
||||
foreach (var target in _targets) {
|
||||
if (target.target == null) {
|
||||
_targets.Remove(target);
|
||||
}
|
||||
}
|
||||
|
||||
// render on each target object
|
||||
foreach (var target in _targets) {
|
||||
if (ReferenceEquals(target.target, null)) _targets.Remove(target);
|
||||
else target.Render(_decalMaterial, part.mpb, camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user