static void Postfix(HeatSource __instance) { if (__instance.isIndoorAndCoolDown()) { __instance.m_TempIncrease = prevTemp - (prevTemp - __instance.m_TempIncrease) * Main.config.slowerCoolDown; } }
static void Prefix(HeatSource __instance) { if (__instance.isIndoorAndCoolDown()) { prevTemp = __instance.m_TempIncrease; } }
public double GetResultsArea(RealPoint point) { double result = 0.0; foreach (var area in this.Areas) { foreach (var segmentI in area.Segments) { int i = 0; foreach (var collPointI in segmentI.CollocationPoints) { var functionT = Function_T.CalculateAreaValue(point, segmentI, collPointI, area.configurationData); var functionq = Function_q.CalculateAreaValue(point, segmentI, collPointI, area.configurationData); result += -functionq * segmentI.TemperatureBoundaryCondition.BoundaryConditionVector[i] + functionT * segmentI.HeatFluxBoundaryCondition.BoundaryConditionVector[i]; i++; } } } foreach (var area in this.Areas) { var initial = InitialCondition.CalculateValue(area, point); result += initial; if (area.configurationData.addHeatSource) { var subAreaIntegrationHelper = new SubAreaIntegrationHelper(4, area.Surfaces.Select(x => x.SurfaceShape).ToList()); result += HeatSource.CalculateValue(area, point, subAreaIntegrationHelper); } } return(result); }
void Start() { _state = FireState.Normal; _heatSource = GetComponent <HeatSource>(); _heatSource.enabled = false; _meshRenderer = GetComponent <Renderer>(); _burningCells = new List <FireCell>(); }
/// <summary> /// Find the best target and turn the missile for a head-on collision. /// </summary> void Update() { float time = Time.time; if (mNextUpdate < time) { mNextUpdate = time + updateFrequency; // Find the most optimal target ahead of the missile if (currentTarget == null || !oneTarget) { currentTarget = HeatSource.Find(mTrans.position, mTrans.rotation * Vector3.forward, sensorRange, sensorAngle); } if (currentTarget != null) { // Calculate local space direction Vector3 dir = (currentTarget.transform.position - mTrans.position); float dist = dir.magnitude; dir *= 1.0f / dist; dir = Quaternion.Inverse(mTrans.rotation) * dir; // Make the missile turn slower if it's far away from the target, and faster when it's close float turnSensivitity = 0.5f + 2.5f * (1.0f - dist / sensorRange); // Calculate the turn amount based on the direction mTurn.x = Mathf.Clamp(dir.y * turnSensivitity, -1f, 1f); mTurn.y = Mathf.Clamp(dir.x * turnSensivitity, -1f, 1f); // Locked on target mTimeSinceTarget = 0f; } else { // No target lock -- keep track of how long it has been mTimeSinceTarget += updateFrequency + Time.deltaTime; } mControl.turningInput = mTurn; mControl.moveInput = Vector3.forward; } // If it has been too long if (mTimeSinceTarget > 2f) { Explosive exp = mControl.GetComponentInChildren<Explosive>(); if (exp != null) { exp.Explode(); } else { NetworkManager.RemoteDestroy(mControl.gameObject); } } }
/// <summary> /// Find the best target and turn the missile for a head-on collision. /// </summary> void Update() { float time = Time.time; if (mNextUpdate < time) { mNextUpdate = time + updateFrequency; // Find the most optimal target ahead of the missile if (currentTarget == null || !oneTarget) { currentTarget = HeatSource.Find(mTrans.position, mTrans.rotation * Vector3.forward, sensorRange, sensorAngle); } if (currentTarget != null) { // Calculate local space direction Vector3 dir = (currentTarget.transform.position - mTrans.position); float dist = dir.magnitude; dir *= 1.0f / dist; dir = Quaternion.Inverse(mTrans.rotation) * dir; // Make the missile turn slower if it's far away from the target, and faster when it's close float turnSensivitity = 0.5f + 2.5f * (1.0f - dist / sensorRange); // Calculate the turn amount based on the direction mTurn.x = Mathf.Clamp(dir.y * turnSensivitity, -1f, 1f); mTurn.y = Mathf.Clamp(dir.x * turnSensivitity, -1f, 1f); // Locked on target mTimeSinceTarget = 0f; } else { // No target lock -- keep track of how long it has been mTimeSinceTarget += updateFrequency + Time.deltaTime; } mControl.turningInput = mTurn; mControl.moveInput = Vector3.forward; } // If it has been too long if (mTimeSinceTarget > 2f) { Explosive exp = mControl.GetComponentInChildren <Explosive>(); if (exp != null) { exp.Explode(); } else { NetworkManager.RemoteDestroy(mControl.gameObject); } } }
private void OnCollisionStay(Collision collision) { HeatSource source = collision.gameObject.GetComponent <HeatSource>(); if (source != null) { ApplyHeatTransfer(HeatTransferFrom(source)); } }
private void OnCollisionEnter(Collision collision) { HeatSource source = collision.gameObject.GetComponent <HeatSource>(); if (source != null) { sources.Add(source); } }
private void OnCollisionExit(Collision collision) { HeatSource source = collision.gameObject.GetComponent <HeatSource>(); if (source != null) { sources.Remove(source); } }
// Use this for initialization void Start() { source = GetComponent <HeatSource>(); if (source != null) { InvokeRepeating("SetTemperature", 1.0f, 1.0f); } }
private void OnTriggerStay(Collider other) { HeatSensitive sensitive = other.GetComponent <HeatSensitive>(); HeatSource source = other.GetComponent <HeatSource>(); if (sensitive != null) { } if (source != null) { } }
//Called by heat sources during OnDisable(), removes them from list of active heat sources in the scene public void UnregisterHeatSource(HeatSource source) { Vector2 gridPosition; if (grid.GetGridPosition(source.transform.position, out gridPosition)) { List <HeatSource> heatSources = grid.GetCellContents(gridPosition); if (heatSources.Contains(source)) { heatSources.Remove(source); } } }
public double GetTemperatureFromSurfaceIntegrationPointConstants(SurfaceIntegrationPoint point) { double result = 0.0; int j = 0; foreach (var area in this.Areas) { foreach (var segment in area.Segments) { foreach (var collPoint in segment.CollocationPoints) { result += -point.FunctionqConstantValue[j] * segment.TemperatureBoundaryCondition.BoundaryConditionVector[collPoint.Index] + point.FunctionTConstantValue[j] * segment.HeatFluxBoundaryCondition.BoundaryConditionVector[collPoint.Index]; j++; } } } int k = 0; foreach (var area in this.Areas) { //To tradycyjnie result += InitialCondition.CalculateValue(area, point.RealPosition); //To w przypadku przechowywania parametrów //foreach (var surface in this.Surfaces) //{ // foreach (var surfaceIntegrationPoint in surface.SurfaceIntegrationPoints) // { // value += point.InitialConditionConstantValues[k] * surfaceIntegrationPoint.TemperatureValue; // k++; // } //} if (area.configurationData.addHeatSource) { if (area.configurationData.isHeatSourceTimeDependent) { var subAreaIntegrationHelper = new SubAreaIntegrationHelper(4, area.Surfaces.Select(x => x.SurfaceShape).ToList()); result += HeatSource.CalculateValue(area, point.RealPosition, subAreaIntegrationHelper); } else { result += point.HeatSourceConstantValue; } } } return(result); }
/// <summary> /// Keep the reticle updated /// </summary> void Update() { if (!mIsPlayerControlled) return; // Find the target in front of the missile launcher that the missile would lock on if (mMissile != null && base.canFire) { mTarget = HeatSource.Find(mTrans.position, mTrans.rotation * Vector3.forward, mMissile.sensorRange, mMissile.sensorAngle); } else mTarget = null; // Update the player target if this is the player's missile launcher Player.target = (mTarget == null) ? null : mTarget.transform; }
public float HeatTransferFrom(HeatSource source) { float Q = 0; if (Temperature > source.Temperature) { Q = HeatTransfer(Temperature, source.Temperature); } else if (source.Temperature > Temperature) { Q = HeatTransfer(source.Temperature, Temperature); } return(Q); }
private static void Postfix(ref string __result) { Vector3 pos = GameManager.GetPlayerTransform().position; Fire result = null; float num = float.PositiveInfinity; for (int i = 0; i < FireManager.m_Fires.Count; i++) { Fire firem = FireManager.m_Fires[i]; float num2 = Vector3.Distance(pos, firem.transform.position); if (num2 < num) { num = num2; result = firem; } } Fire fire = result; if (fire == null) { return; } HeatSource myheat = fire.m_HeatSource; float maxTemp = (float)AccessTools.Field(typeof(HeatSource), "m_MaxTempIncrease").GetValue(myheat); float innerRad = (float)AccessTools.Field(typeof(HeatSource), "m_MaxTempIncreaseInnerRadius").GetValue(myheat); float outerRad = (float)AccessTools.Field(typeof(HeatSource), "m_MaxTempIncreaseOuterRadius").GetValue(myheat); float dist = Vector3.Distance(pos, fire.transform.position); FireState mystate = (FireState)AccessTools.Field(typeof(Fire), "m_FireState").GetValue(fire); if (dist > 20) { return; } __result += "\n\nFire state:" + Enum.GetName(typeof(FireState), mystate) + " dist:" + string.Format("{0:0.0}", dist) + " >>Heat temp:" + string.Format("{0:0.00}", myheat.GetCurrentTempIncrease()) + " max:" + maxTemp + " isembers:" + fire.IsEmbers(); __result += "\nRadius, Inner:" + innerRad + " Outer:" + outerRad; HeatReservoir myres = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(fire.gameObject)); if (myres == null) { // Debug.Log("no heat reservoir associated with fire"); return; } __result += "\nRsvr temp:" + string.Format("{0:0.00}", myres.temp) + " size:" + myres.size_cmins + " ins:" + myres.insulation_factor + " LastFireTemp:" + string.Format("{0:0.00}", myres.lastFireTemp); }
void Update() { //If left mouse clicked on a surface spawn new heat source on that surface if (Input.GetMouseButtonDown(0)) { Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; int layerMask = 1 << 8; //Layer 8 = PlaceableSurface if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) { Quaternion spawnRotation = Quaternion.FromToRotation(Vector3.up, hit.normal); Vector3 spawnPoint = hit.point + (hit.normal * (placeableObject.transform.localScale.y * 0.5f)); Debug.Log(hit.point + (hit.normal * (placeableObject.transform.localScale.y * 0.5f))); HeatSource sourceObject = Instantiate(placeableObject, spawnPoint, spawnRotation); sourceObject.InitialiseHeatSource(sourceTemperature, heatRange, heatFalloffRange, angle); } } }
public void CalculateSurfaceIntegrationPointsConstants() { //double denominator1 = InitialCondition.denominator1(configurationData); //double denominator2 = InitialCondition.denominator2(configurationData); foreach (var area in this.Areas) { foreach (var surface in area.Surfaces) { Parallel.ForEach(surface.InitialConditionSurfaceIntegrationPoints, (surfaceIntegrationPoint) => { var sur = surfaceIntegrationPoint; foreach (var area1 in this.Areas) { foreach (var segmentI in area1.Segments) { foreach (var collPointI in segmentI.CollocationPoints) { surfaceIntegrationPoint.FunctionTConstantValue.Add(Function_T.CalculateAreaValue(surfaceIntegrationPoint.RealPosition, segmentI, collPointI, area1.configurationData)); surfaceIntegrationPoint.FunctionqConstantValue.Add(Function_q.CalculateAreaValue(surfaceIntegrationPoint.RealPosition, segmentI, collPointI, area1.configurationData)); } } } //To w przypadku przechowywania parametrów //foreach (var innerSurface in this.Surfaces) //{ // foreach (var innerSurfaceIntegrationPoint in innerSurface.SurfaceIntegrationPoints) // { // surfaceIntegrationPoint.InitialConditionConstantValues.Add(InitialCondition.CalculateSiglePointFunctionValue(surfaceIntegrationPoint.RealPosition, denominator1, denominator2, innerSurfaceIntegrationPoint)); // } //} if (area.configurationData.addHeatSource) { if (!area.configurationData.isHeatSourceTimeDependent) { var subAreaIntegrationHelper = new SubAreaIntegrationHelper(4, area.Surfaces.Select(x => x.SurfaceShape).ToList()); surfaceIntegrationPoint.HeatSourceConstantValue = HeatSource.CalculateValue(area, surfaceIntegrationPoint.RealPosition, subAreaIntegrationHelper); } } }); } } }
/// <summary> /// Find the most optimal heat source ahead of the specified point. /// </summary> static public HeatSource Find(Vector3 pos, Vector3 dir, float maxRange, float maxAngle) { HeatSource bestSource = null; float bestValue = 0f; foreach (HeatSource heat in mList) { if (heat == null || heat.mTrans == null) { continue; } // If the heat source is too far, move on to the next Vector3 heatDir = heat.mTrans.position - pos; float distance = heatDir.magnitude; if (distance > maxRange || distance < 0.01f) { continue; } // Normalize the distance and determine the dot product if (distance != 0f) { heatDir *= 1.0f / distance; } // Calculate the angle float angle = Vector3.Angle(dir, heatDir); // The angle must be within the sensor threshold if (angle < maxAngle) { // Calculate the value of this target float val = (maxRange - distance) / maxRange * (1f - angle / maxAngle); if (val > bestValue) { bestValue = val; bestSource = heat; } } } return(bestSource); }
public Area CalculateIterationForSingleArea() { this.Problem.Areas[0].calculateVariableBoundaryConditions(); this.Problem.Areas[0].CalculateBoundaryTemperature(); this.vectorF = this.Problem.Areas[0].GetKnownBoundaryVector(); if (this.Problem.IterationProcess.CurrentIteration == 1 || this.Problem.Areas[0].configurationData.arePropertiesTimeDependent()) { this.matrixT = Function_T.CalculateBoundaryMatrix(this.Problem.Areas[0]); this.matrixq = Function_q.CalculateBoundaryMatrix(this.Problem.Areas[0]); } if (Problem.IterationProcess.CurrentIteration == 1) { Problem.CalculateCollocationPointsConstants(); Problem.CalculateSurfaceIntegrationPointsConstants(); } this.SeparateKnownFromUnknownForSingleArea(); this.CalculateKnownVectorForSingleArea(); //To tradycyjnie this.initialCondition = InitialCondition.CalculateBoundaryVector(this.Problem.Areas[0]); //To w przypadku przechowywania parametrów //this.GetInitialConditionVectorFromCollocationPointsConstants(); this.AddInitialConditionForSingleArea(); if (this.Problem.Areas[0].configurationData.addHeatSource) { if (this.Problem.Areas[0].configurationData.isHeatSourceTimeDependent || this.Problem.IterationProcess.CurrentIteration == 1) { this.heatSource = HeatSource.CalculateBoundaryVector(this.Problem.Areas[0]); } this.AddHeatSource(); } this.SolveEquations(); this.SetUnknownBoundaryConditionsForSingleArea(); return(this.Problem.Areas[0]); }
/// <summary> /// Keep the reticle updated /// </summary> void Update() { if (!mIsPlayerControlled) { return; } // Find the target in front of the missile launcher that the missile would lock on if (mMissile != null && base.canFire) { mTarget = HeatSource.Find(mTrans.position, mTrans.rotation * Vector3.forward, mMissile.sensorRange, mMissile.sensorAngle); } else { mTarget = null; } // Update the player target if this is the player's missile launcher Player.target = (mTarget == null) ? null : mTarget.transform; }
//When heat source drop down menu changes, update the selected heat source type variable and change UI to show correct settings void HeatSourceTypeChange() { heatSourceType = (HeatSourceType)heatSourceTypeInput.value; placeableObject = heatSourcePrefabs[heatSourceTypeInput.value]; switch (heatSourceType) { case HeatSourceType.Radius: rangeSettingsContainer.gameObject.SetActive(true); angleSettingsContainer.gameObject.SetActive(false); rangeText.text = "Range = " + heatRange.ToString("0.0"); rangeFalloffText.text = "Range Falloff = " + heatFalloffRange.ToString("0.0"); break; case HeatSourceType.Collider: rangeSettingsContainer.gameObject.SetActive(false); angleSettingsContainer.gameObject.SetActive(true); angleText.text = "Angle = " + angle.ToString("0"); break; default: break; } }
static bool isIndoorAndCoolDown(this HeatSource hs) => GameManager.GetWeatherComponent().IsIndoorScene() && !hs.IsTurnedOn() && hs.m_TempIncrease > 0f;
private float Brightness(HeatSource other) { var distance = Distance(other.gameObject); return(other.Intensity / 4 * Mathf.PI * distance * distance); }