- Reproducable without other mods?
- should activate only when compatible lamps are present in terrain or mission (and module to manual activate it) - alternative would be init EH in the object class with isNil check for already running
- check sun state every 0.25s seems too much
- not checking for CUP_lampState change first
- positionCameraToWorld and pos check every 0.5s seems too much (could be made based on speed/vehicle type one is in)
- nearObjects check every 0.5s (relevant when flying fast) instead of caching relevant object positions
- (minor) not saving both texture paths to variable (instead _m = format ['ca\Structures\Misc_Powerlines\Data\powlines_%1.rvmat',['multi1','light1'] select CUP_lampState];)
- (minor) not saving damaged texture path to variable
I am in favour of removing this completely. Does anyone even notice a difference? No other terrain mod does this, CUP should not either. This can easily be a separately published script if someone really really wants it, it will never be good enough for inclusion in CUP Terrains.
As for refactoring, @kju's suggestions are rather irrelevant in terms of performance, important are:
- Run only on server with `setObjectMaterialGlobal˙
- Second loop is pointless, value is global, just change all the lamps if state changes instead of looping over all lamps in 400m range if you moved 100m (~commy2)
- Use 1s PFH
- Use unscheduled
- Code cleanup
- Comments! (who knows that's sunrise formula from their head)
Entire thing can be made way shorter and way more efficient.
@NeoArmageddon any progress on moving this to models. Vanilla lamp posts seem to do that.