EnergyUsingObject.ReceiveEnergy C# (CSharp) 메소드

ReceiveEnergy() 공개 메소드

Receives the energy. called from the plug load.. amt of energy used.
public ReceiveEnergy ( ) : float
리턴 float
	public float ReceiveEnergy() {

		float amountToReturn = 0;

		if (powerSupply.getIsEnergySupplied()) { //hub supplying energy.
			//get how much energy to add based on average per sec.
			float energyToAdd = powerSupply.getAvgUsePerSec() * Time.deltaTime * scale.getTimeScale();

			if (powerSupply.getIsOn()) { //if on.
				
				powerSupply.addTotalUse(energyToAdd);
				amountToReturn = energyToAdd;
				
			}
			
			//and charge battery as well.
			int numB = getNumBatteries();
			for (int i=0; i<numB; i++) {
				Battery b = powerSupply.getBatteryList()[i];
				if (!b.getIsFull()) {
					//found a not full battery.. charge this one and break.. so you don't charge the others too.
					b.setEnergy(b.getCurEnergy() + energyToAdd);
					break;
				}
			}
			
		}
		return amountToReturn;
	}