// Member Methods public void RegisterAtmosphereGenerator(GameObject _AtmosphereGenerator) { m_AtmosphereGenerator = _AtmosphereGenerator; m_CachedAtmosphereGeneratorBehaviour = m_AtmosphereGenerator.GetComponent <CAtmosphereGeneratorBehaviour>(); m_CachedAtmosphereGenerator = m_AtmosphereGenerator.GetComponent <CTestAtmosphereGenerator>(); // Register generation rate state chages m_CachedAtmosphereGeneratorBehaviour.EventGenerationRateChanged += HandleGenerationRateStateChange; // Register for when the circuitry breaks/fixes m_CachedAtmosphereGenerator.m_CircuitryComponent.EventComponentBreak += HandleCircuitryStateChange; m_CachedAtmosphereGenerator.m_CircuitryComponent.EventComponentFix += HandleCircuitryStateChange; // Update initial values UpdateDUI(); }
// Member Methods public void RegisterAtmosphereGenerator(GameObject _AtmosphereGenerator) { m_AtmosphereGenerator = _AtmosphereGenerator; m_CachedAtmosphereGeneratorBehaviour = m_AtmosphereGenerator.GetComponent<CAtmosphereGeneratorBehaviour>(); m_CachedAtmosphereGenerator = m_AtmosphereGenerator.GetComponent<CTestAtmosphereGenerator>(); // Register generation rate state chages m_CachedAtmosphereGeneratorBehaviour.EventGenerationRateChanged += HandleGenerationRateStateChange; // Register for when the circuitry breaks/fixes m_CachedAtmosphereGenerator.m_CircuitryComponent.EventComponentBreak += HandleCircuitryStateChange; m_CachedAtmosphereGenerator.m_CircuitryComponent.EventComponentFix += HandleCircuitryStateChange; // Update initial values UpdateDUI(); }
private void UpdateFacilityAtmosphereRefilling() { // Reset all facility refilling foreach (GameObject facility in gameObject.GetComponent <CShipFacilities>().Facilities) { facility.GetComponent <CFacilityAtmosphere>().AtmosphereRefillRate = 0.0f; } // Get the facilities that are requiring a refill of atmosphere (i.e, have a leak, hull breach, consumer) var facilitiesRequiringRefilling = from facility in gameObject.GetComponent <CShipFacilities>().Facilities where facility.GetComponent <CFacilityAtmosphere>().RequiresAtmosphereRefill select facility; // If there are facilities requiring this, calculate the refilling output int numFacilitiesRequiringRefill = facilitiesRequiringRefilling.ToArray().Length; if (numFacilitiesRequiringRefill != 0) { // Get the combined output of all atmosphere distributors float combinedOutput = 0.0f; foreach (GameObject ag in m_AtmosphereGenerators) { CAtmosphereGeneratorBehaviour agb = ag.GetComponent <CAtmosphereGeneratorBehaviour>(); if (agb.IsAtmosphereGenerationActive) { combinedOutput += agb.AtmosphereGenerationRate; } } // Calculate the output for each facility evenly float evenDistribution = combinedOutput / numFacilitiesRequiringRefill; // Apply this refilling value to the facilities that need it foreach (GameObject facility in facilitiesRequiringRefilling) { facility.GetComponent <CFacilityAtmosphere>().AtmosphereRefillRate = evenDistribution; } } }
// Member Properties // Member Methods public void Start() { m_AtmosphereGenerator = gameObject.GetComponent<CAtmosphereGeneratorBehaviour>(); // Register for when the calibrator breaks/fixes m_LiquidComponent.EventHealthChange += HandleFluidHealthChange; // Register for when the circuitry breaks/fixes m_CircuitryComponent.EventComponentBreak += HandleCircuitryBreaking; m_CircuitryComponent.EventComponentFix += HandleCircuitryFixing; // Get the DUI of the power generator m_DUIAtmosphereGeneration = m_DUIConsole.DUI.GetComponent<CDUIAtmosphereGeneratorRoot>(); m_DUIAtmosphereGeneration.RegisterAtmosphereGenerator(gameObject); if(CNetwork.IsServer) { // Set the generation rate m_AtmosphereGenerator.AtmosphereGenerationRate = m_MaxAtmosphereGenerationRate; } }
// Member Properties // Member Methods public void Start() { m_AtmosphereGenerator = gameObject.GetComponent <CAtmosphereGeneratorBehaviour>(); // Register for when the calibrator breaks/fixes m_LiquidComponent.EventHealthChange += HandleFluidHealthChange; // Register for when the circuitry breaks/fixes m_CircuitryComponent.EventComponentBreak += HandleCircuitryBreaking; m_CircuitryComponent.EventComponentFix += HandleCircuitryFixing; // Get the DUI of the power generator m_DUIAtmosphereGeneration = m_DUIConsole.DUI.GetComponent <CDUIAtmosphereGeneratorRoot>(); m_DUIAtmosphereGeneration.RegisterAtmosphereGenerator(gameObject); if (CNetwork.IsServer) { // Set the generation rate m_AtmosphereGenerator.AtmosphereGenerationRate = m_MaxAtmosphereGenerationRate; } }
private void HandleGenerationRateStateChange(CAtmosphereGeneratorBehaviour _Generator) { UpdateDUI(); }
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); }