Energy manager: Checks whenever this device can do work or not.
758 {
760 {
762 }
763
765 {
766 return false;
767 }
768
769
770 float energy_usage = test_energy;
773
774 if (energy_usage == -1)
775 {
777 }
778
780 {
781 return false;
782 }
783
784 if (gathered_energy <= 0 && energy_usage <= 0)
785 {
786 return false;
787 }
788
789 int cycle_limit = 500;
790
791 while ( gathered_energy < energy_usage )
792 {
793
794 if (cycle_limit > 0)
795 {
796 cycle_limit--;
797 }
798 else
799 {
800 DPrint(
"Energy Manager ERROR: The 'cycle_limit' safety break had to be activated to prevent possible game freeze. Dumping debug information...");
801
802
803
804
805 if (energy_source.GetCompEM())
806 {
807
808 }
809
810
811
812
813
814
815 if (energy_source)
816 {
817
818 }
819
820
821
822 return false;
823 }
824
825
826 if ( energy_source && energy_source !=
m_ThisEntityAI && !energy_source.IsRuined() && energy_source.GetCompEM() && energy_source.GetCompEM().IsSwitchedOn() && energy_source.GetCompEM().CheckWetness() )
827 {
828 gathered_energy = gathered_energy + energy_source.GetCompEM().GetEnergy();
829 energy_source = energy_source.GetCompEM().GetEnergySource();
830 }
831 else
832 {
833
834 return false;
835 }
836 }
837
838
839 return true;
840 }
float GetEnergyUsage()
Energy manager: Returns the number of energy this device needs to run itself (See its config >> energ...
bool CheckWetness()
Energy manager: Checks if this device is being stopped from working by its wetness level....
float GetEnergy()
Energy manager: Returns the amount of stored energy this device has.
EntityAI GetEnergySource()
Energy manager: Returns the energy source this device is plugged into.
proto native CGame GetGame()
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...