private void UpdateFacilityAtmosphereQuality() { // Calculate the combined quantity of atmosphere between all facilities float combinedVolume = 0.0f; foreach (GameObject facility in gameObject.GetComponent <CShipFacilities>().Facilities) { combinedVolume += facility.GetComponent <CFacilityAtmosphere>().AtmosphereVolume; } // Calculate the combined quality capacity of all the life support system float combinedCapacitySupport = 0.0f; foreach (GameObject conditioner in m_AtmosphereConditioners) { CAtmosphereConditioningBehaviour acb = conditioner.GetComponent <CAtmosphereConditioningBehaviour>(); if (acb.IsAtmosphereConditioningActive) { combinedCapacitySupport += acb.AtmosphereCapacitySupport; } } // Apply the global quality value for all facilities float atmosphereQuality = combinedCapacitySupport / combinedVolume; // Cap the quality to 120% if (atmosphereQuality > 1.2f) { atmosphereQuality = 1.2f; } ShipAtmosphericQuality = atmosphereQuality; }
// Member Properties // Member Methods public void Start() { m_AtmosphereConditioner = gameObject.GetComponent<CAtmosphereConditioningBehaviour>(); // Register for when the fusebox breaks/fixes //TODO: Replace with actual component //CFuseBoxBehaviour fbc = gameObject.GetComponent<CModuleInterface>().FindAttachedComponentsByType(CComponentInterface.EType.FuseBox)[0].GetComponent<CFuseBoxBehaviour>(); //fbc.EventBroken += HandleFuseBoxBreaking; //fbc.EventFixed += HandleFuseBoxFixing; }
// Member Properties // Member Methods public void Start() { m_AtmosphereConditioner = gameObject.GetComponent <CAtmosphereConditioningBehaviour>(); // Register for when the fusebox breaks/fixes //TODO: Replace with actual component //CFuseBoxBehaviour fbc = gameObject.GetComponent<CModuleInterface>().FindAttachedComponentsByType(CComponentInterface.EType.FuseBox)[0].GetComponent<CFuseBoxBehaviour>(); //fbc.EventBroken += HandleFuseBoxBreaking; //fbc.EventFixed += HandleFuseBoxFixing; }
public void OnGUI() { return; string shipLifeSupportOutput = "ShipLifeSupportInfo\n"; shipLifeSupportOutput += string.Format("\tQuality: [{0}%]\n", Math.Round(ShipAtmosphericQuality * 100.0f, 1)); string generatorOutput = "GeneratorInfo\n"; foreach (GameObject generator in m_AtmosphereGenerators) { CFacilityInterface fi = CUtility.FindInParents <CFacilityInterface>(generator); CAtmosphereGeneratorBehaviour agb = generator.GetComponent <CAtmosphereGeneratorBehaviour>(); generatorOutput += string.Format("\t[{0}] Within Facility [{1}] Type [{2}] \n\t\tIsGenerationActive: [{3}] GenRate: [{4}]\n", generator.name, fi.FacilityId, fi.FacilityType, agb.IsAtmosphereGenerationActive, Math.Round(agb.AtmosphereGenerationRate, 2)); } string conditionerOutput = "ConditionerInfo\n"; foreach (GameObject conditioner in m_AtmosphereConditioners) { CFacilityInterface fi = CUtility.FindInParents <CFacilityInterface>(conditioner); CAtmosphereConditioningBehaviour acb = conditioner.GetComponent <CAtmosphereConditioningBehaviour>(); conditionerOutput += string.Format("\t[{0}] Within Facility [{1}] Type [{2}] \n\t\tIsConditioningActive: [{3}] SupportCap: [{4}]\n", conditioner.name, fi.FacilityId, fi.FacilityType, acb.IsAtmosphereConditioningActive, Math.Round(acb.AtmosphereCapacitySupport, 2)); } string facilitiesOutput = "FacilityAtmosphereInfo\n"; foreach (GameObject facility in gameObject.GetComponent <CShipFacilities>().Facilities) { CFacilityInterface fi = facility.GetComponent <CFacilityInterface>(); CFacilityAtmosphere fa = facility.GetComponent <CFacilityAtmosphere>(); facilitiesOutput += string.Format("\tFacility [{0}] Type [{1}] \n\t\tTotalVol: [{2}] Quantity: [{3}] RefilRate: [{4}] ConsRate: [{5}]\n", fi.FacilityId, fi.FacilityType, Math.Round(fa.AtmosphereVolume, 2), Math.Round(fa.AtmosphereQuantity, 2), Math.Round(fa.AtmosphereRefillRate, 2), Math.Round(fa.AtmosphereConsumeRate, 2)); } float boxWidth = 500; float boxHeight = 600; GUI.Label(new Rect(Screen.width / 2, 0.0f, boxWidth, boxHeight), "Atmosphere Status'\n" + shipLifeSupportOutput + generatorOutput + conditionerOutput + facilitiesOutput); }