Пример #1
0
    private void UpdateChargeVariables()
    {
        m_ShipCurrentCharge           = 0.0f;
        m_ShipCurrentChargeCapacity   = 0.0f;
        m_ShipChargeCapacityPotential = 0.0f;
        foreach (GameObject ps in m_PowerStorages)
        {
            CPowerStorageBehaviour psb = ps.GetComponent <CPowerStorageBehaviour>();

            if (psb.IsBatteryChargeAvailable)
            {
                m_ShipCurrentCharge         += psb.BatteryCharge;
                m_ShipCurrentChargeCapacity += psb.BatteryCapacity;
            }

            m_ShipChargeCapacityPotential += psb.BatteryCapacity;
        }
    }
Пример #2
0
	// Member Properties

	
	// Member Methods
	public void RegisterPowerCapacitor(GameObject _PowerCapacitor)
	{
		m_PowerCapacitor = _PowerCapacitor;
		m_CachedPowerStorageBehaviour = m_PowerCapacitor.GetComponent<CPowerStorageBehaviour>();
		m_CachedPowerCapacitor = m_PowerCapacitor.GetComponent<CTestPowerCapacitor>();

		// Register charge/capacity state chages
		m_CachedPowerStorageBehaviour.EventBatteryCapacityChanged += HandleCapacitorStateChange;
		m_CachedPowerStorageBehaviour.EventBatteryChargeChanged += HandleCapacitorStateChange;
		
		// Register for when the circuitry breaks/fixes
		m_CachedPowerCapacitor.m_Circuitry1.EventComponentBreak += HandleCircuitryStateChange;
		m_CachedPowerCapacitor.m_Circuitry1.EventComponentFix += HandleCircuitryStateChange;
		m_CachedPowerCapacitor.m_Circuitry2.EventComponentBreak += HandleCircuitryStateChange;
		m_CachedPowerCapacitor.m_Circuitry2.EventComponentFix += HandleCircuitryStateChange;

		// Update initial values
		UpdateDUI();
	}
Пример #3
0
    // Member Properties


    // Member Methods
    public void RegisterPowerCapacitor(GameObject _PowerCapacitor)
    {
        m_PowerCapacitor = _PowerCapacitor;
        m_CachedPowerStorageBehaviour = m_PowerCapacitor.GetComponent <CPowerStorageBehaviour>();
        m_CachedPowerCapacitor        = m_PowerCapacitor.GetComponent <CTestPowerCapacitor>();

        // Register charge/capacity state chages
        m_CachedPowerStorageBehaviour.EventBatteryCapacityChanged += HandleCapacitorStateChange;
        m_CachedPowerStorageBehaviour.EventBatteryChargeChanged   += HandleCapacitorStateChange;

        // Register for when the circuitry breaks/fixes
        m_CachedPowerCapacitor.m_Circuitry1.EventComponentBreak += HandleCircuitryStateChange;
        m_CachedPowerCapacitor.m_Circuitry1.EventComponentFix   += HandleCircuitryStateChange;
        m_CachedPowerCapacitor.m_Circuitry2.EventComponentBreak += HandleCircuitryStateChange;
        m_CachedPowerCapacitor.m_Circuitry2.EventComponentFix   += HandleCircuitryStateChange;

        // Update initial values
        UpdateDUI();
    }
Пример #4
0
	// Member Methods
	public void Start()
	{
		m_PowerStorage = gameObject.GetComponent<CPowerStorageBehaviour>();

		// Register for when the circuitry breaks/fixes
		m_Circuitry1.EventComponentBreak += HandleCircuitryStateChange;
		m_Circuitry1.EventComponentFix += HandleCircuitryStateChange;
		m_Circuitry2.EventComponentBreak += HandleCircuitryStateChange;
		m_Circuitry2.EventComponentFix += HandleCircuitryStateChange;

		// Get the DUI of the power generator
		m_DUIPowerCapacitor = m_DUIConsole.DUI.GetComponent<CDUIPowerCapacitorRoot>();
		m_DUIPowerCapacitor.RegisterPowerCapacitor(gameObject);

		// Debug: Set the charge to half its total capacity
		if(CNetwork.IsServer)
		{
			m_PowerStorage.BatteryCapacity = m_MaxPowerBatteryCapacity;
			m_PowerStorage.BatteryCharge = m_PowerStorage.BatteryCapacity / 2;
		}
	}
Пример #5
0
    // Member Methods
    public void Start()
    {
        m_PowerStorage = gameObject.GetComponent <CPowerStorageBehaviour>();

        // Register for when the circuitry breaks/fixes
        m_Circuitry1.EventComponentBreak += HandleCircuitryStateChange;
        m_Circuitry1.EventComponentFix   += HandleCircuitryStateChange;
        m_Circuitry2.EventComponentBreak += HandleCircuitryStateChange;
        m_Circuitry2.EventComponentFix   += HandleCircuitryStateChange;

        // Get the DUI of the power generator
        m_DUIPowerCapacitor = m_DUIConsole.DUI.GetComponent <CDUIPowerCapacitorRoot>();
        m_DUIPowerCapacitor.RegisterPowerCapacitor(gameObject);

        // Debug: Set the charge to half its total capacity
        if (CNetwork.IsServer)
        {
            m_PowerStorage.BatteryCapacity = m_MaxPowerBatteryCapacity;
            m_PowerStorage.BatteryCharge   = m_PowerStorage.BatteryCapacity / 2;
        }
    }
Пример #6
0
	private void HandleCapacitorStateChange(CPowerStorageBehaviour _Capacitor)
	{
		UpdateDUI();
	}
Пример #7
0
 private void HandleCapacitorStateChange(CPowerStorageBehaviour _Capacitor)
 {
     UpdateDUI();
 }
Пример #8
0
    /////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////

    //float fModulePowerConsumption;

    //[AServerOnly]
    //void UpdateModulePowerConsumption()
    //{
    //    fModulePowerConsumption = (float)CModuleInterface.GetAllModules().Sum((m) =>
    //    {
    //        CModulePower mp = m.GetComponent<CModulePower>();
    //        return (mp.IsPowerActive ? mp.PowerConsumption * Time.deltaTime : 0.0);
    //    });

    //    float TOTAL = combinedConsumption + fModulePowerConsumption;

    //    Debug.Log("TOTAL: " + TOTAL.ToString());
    //}

    /////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////

    public void OnGUI()
    {
        return;

        string shipPowerOutput = "ShipPowerInfo\n";

        shipPowerOutput += string.Format("\tBatteryChargePool: [{0}]\n",
                                         Math.Round(m_ShipCurrentCharge, 2));



        string generatorOutput = "GeneratorInfo\n";

        foreach (GameObject generator in m_PowerGenerators)
        {
            CFacilityInterface        fi  = CUtility.FindInParents <CFacilityInterface>(generator);
            CPowerGenerationBehaviour pgb = generator.GetComponent <CPowerGenerationBehaviour>();

            generatorOutput += string.Format("\t[{0}] Within Facility [{1}] Type [{2}] \n\t\tIsGenerationActive: [{3}] GenRate: [{4}]\n",
                                             generator.name,
                                             fi.FacilityId,
                                             fi.FacilityType,
                                             pgb.IsPowerGenerationActive,
                                             Math.Round(pgb.PowerGenerationRate, 2));
        }

        string storageOutput = "StorageInfo\n";

        foreach (GameObject storage in m_PowerStorages)
        {
            CFacilityInterface     fi  = CUtility.FindInParents <CFacilityInterface>(storage);
            CPowerStorageBehaviour psb = storage.GetComponent <CPowerStorageBehaviour>();

            storageOutput += string.Format("\t[{0}] Within Facility [{1}] Type [{2}] \n\t\tIsChargeAvailable: [{3}] Capacity: [{4}] Charge: [{5}]\n",
                                           storage.name,
                                           fi.FacilityId,
                                           fi.FacilityType,
                                           psb.IsBatteryChargeAvailable,
                                           Math.Round(psb.BatteryCapacity, 2),
                                           Math.Round(psb.BatteryCharge, 2));
        }

        string facilitiesOutput = "FacilityPowerInfo\n";

        foreach (GameObject facility in gameObject.GetComponent <CShipFacilities>().Facilities)
        {
            CFacilityInterface fi = facility.GetComponent <CFacilityInterface>();
            CFacilityPower     fp = facility.GetComponent <CFacilityPower>();

            facilitiesOutput += string.Format("\tFacility [{0}] Type [{1}] \n\t\tIsActive: [{2}] ConsRate: [{3}]\n",
                                              fi.FacilityId,
                                              fi.FacilityType,
                                              fp.IsPowerActive,
                                              Math.Round(fp.PowerConsumption, 2));
        }

        float boxWidth  = 500;
        float boxHeight = 600;

        GUI.Label(new Rect(Screen.width / 2 - boxWidth, 0.0f, boxWidth, boxHeight),
                  "Power Status'\n" + shipPowerOutput + generatorOutput + storageOutput + facilitiesOutput);
    }