Пример #1
0
    // Member Properties


    // Member Methods
    public void Start()
    {
        m_PowerGenerator = gameObject.GetComponent <CPowerGenerationBehaviour>();

        // Register for when the calibrator breaks/fixes
        m_CalibrationComponent.EventHealthChange += HandleCalibrationHealthChange;

        // Register for when the circuitry breaks/fixes
        m_CircuitryComponent.EventComponentBreak += HandleCircuitryBreaking;
        m_CircuitryComponent.EventComponentFix   += HandleCircuitryFixing;

        // Get the DUI of the power generator
        m_DUIPowerGeneration = m_DUIConsole.DUI.GetComponent <CDUIPowerGeneratorRoot>();
        m_DUIPowerGeneration.RegisterPowerGenerator(gameObject);

        if (CNetwork.IsServer)
        {
            // Set the generation rate
            m_PowerGenerator.PowerGenerationRate          = m_MaxPowerGenerationRate;
            m_PowerGenerator.PowerGenerationRatePotential = m_MaxPowerGenerationRate;
        }

        // Set the cubemap for the children
        foreach (Renderer r in GetComponentsInChildren <Renderer>())
        {
            r.material.SetTexture("_Cube", transform.parent.GetComponent <CModulePortInterface>().CubeMapSnapshot);
        }
    }
Пример #2
0
	// Member Properties
	
	
	// Member Methods
	public void Start()
	{
		m_PowerGenerator = gameObject.GetComponent<CPowerGenerationBehaviour>();

		// Register for when the calibrator breaks/fixes
		m_CalibrationComponent.EventHealthChange += HandleCalibrationHealthChange;
		
		// Register for when the circuitry breaks/fixes
		m_CircuitryComponent.EventComponentBreak += HandleCircuitryBreaking;
		m_CircuitryComponent.EventComponentFix += HandleCircuitryFixing;

		// Get the DUI of the power generator
		m_DUIPowerGeneration = m_DUIConsole.DUI.GetComponent<CDUIPowerGeneratorRoot>();
		m_DUIPowerGeneration.RegisterPowerGenerator(gameObject);

		if(CNetwork.IsServer)
		{
			// Set the generation rate
			m_PowerGenerator.PowerGenerationRate = m_MaxPowerGenerationRate;
			m_PowerGenerator.PowerGenerationRatePotential = m_MaxPowerGenerationRate;
		}

		// Set the cubemap for the children
		foreach(Renderer r in GetComponentsInChildren<Renderer>())
		{
			r.material.SetTexture("_Cube", transform.parent.GetComponent<CModulePortInterface>().CubeMapSnapshot);
		}
	}
Пример #3
0
 private void UpdateGenerationVariables()
 {
     m_ShipCurentGenerationRate    = 0.0f;
     m_ShipGenerationRatePotential = 0.0f;
     foreach (GameObject pg in m_PowerGenerators)
     {
         CPowerGenerationBehaviour pgb = pg.GetComponent <CPowerGenerationBehaviour>();
         if (pgb.IsPowerGenerationActive)
         {
             m_ShipCurentGenerationRate += pgb.PowerGenerationRate;
         }
         m_ShipGenerationRatePotential += pgb.PowerGenerationRatePotential;
     }
 }
Пример #4
0
    // Member Properties


    // Member Methods
    public void RegisterPowerGenerator(GameObject _PowerGenerator)
    {
        m_PowerGenerator = _PowerGenerator;
        m_CachedPowerGeneratorBehaviour = m_PowerGenerator.GetComponent <CPowerGenerationBehaviour>();
        m_CachedPowerGenerator          = m_PowerGenerator.GetComponent <CTestPowerGenerator>();

        // Register generation rate state chages
        m_CachedPowerGeneratorBehaviour.EventGenerationRateChanged          += HandleGenerationStateChange;
        m_CachedPowerGeneratorBehaviour.EventGenerationRatePotentialChanged += HandleGenerationStateChange;

        // Register for when the circuitry breaks/fixes
        m_CachedPowerGenerator.m_CircuitryComponent.EventComponentBreak += HandleCircuitryStateChange;
        m_CachedPowerGenerator.m_CircuitryComponent.EventComponentFix   += HandleCircuitryStateChange;

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

	
	// Member Methods
	public void RegisterPowerGenerator(GameObject _PowerGenerator)
	{
		m_PowerGenerator = _PowerGenerator;
		m_CachedPowerGeneratorBehaviour = m_PowerGenerator.GetComponent<CPowerGenerationBehaviour>();
		m_CachedPowerGenerator = m_PowerGenerator.GetComponent<CTestPowerGenerator>();
		
		// Register generation rate state chages
		m_CachedPowerGeneratorBehaviour.EventGenerationRateChanged += HandleGenerationStateChange;
		m_CachedPowerGeneratorBehaviour.EventGenerationRatePotentialChanged += HandleGenerationStateChange;

		// Register for when the circuitry breaks/fixes
		m_CachedPowerGenerator.m_CircuitryComponent.EventComponentBreak += HandleCircuitryStateChange;
		m_CachedPowerGenerator.m_CircuitryComponent.EventComponentFix += HandleCircuitryStateChange;
		
		// Update initial values
		UpdateDUI();
	}
Пример #6
0
 private void HandleGenerationStateChange(CPowerGenerationBehaviour _Generator)
 {
     UpdateDUI();
 }
Пример #7
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);
    }
Пример #8
0
	private void HandleGenerationStateChange(CPowerGenerationBehaviour _Generator)
	{
		UpdateDUI();
	}