void Update() { if (TheGame.Get().IsPaused()) { return; } float game_speed = TheGame.Get().GetGameTimeSpeedPerSec(); //Calculate heat float total_heat = global_heat * global_heat_weight; float total_heat_weight = global_heat_weight; foreach (HeatSource source in HeatSource.GetAll()) { float dist = (source.transform.position - transform.position).magnitude; if (source.enabled && dist < source.heat_range) { total_heat += source.heat * source.heat_weight; total_heat_weight += source.heat_weight; } } //Character heat will move toward this value float average_heat = total_heat / total_heat_weight; float current_heat = character.Attributes.GetAttributeValue(AttributeType.Heat); float change_speed = heat_change_speed; float dir = average_heat - current_heat; //Cold resist if (dir < 0f) { float resist = cold_resist + character.Attributes.GetBonusEffectTotal(BonusType.ColdResist); change_speed = change_speed / (1f + resist); } //Update heat if (Mathf.Abs(dir) > 0.1f) { current_heat += Mathf.Sign(dir) * change_speed * game_speed * Time.deltaTime; character.Attributes.SetAttribute(AttributeType.Heat, current_heat); } //Deal damage if (current_heat < damage_threshold + 0.01f) { float update_value = damage_hp_loss * game_speed * Time.deltaTime; character.Attributes.AddAttribute(AttributeType.Health, update_value); } //Debug.Log(average_heat + " " + current_heat + " " + change_speed); }
public static HeatSource GetNearest(Vector3 pos, float range = 999f) { HeatSource nearest = null; float min_dist = range; foreach (HeatSource heat in heat_list) { float dist = (heat.transform.position - pos).magnitude; if (dist < min_dist) { min_dist = dist; nearest = heat; } } return(nearest); }
void Awake() { firepit_list.Add(this); select = GetComponent <Selectable>(); construction = GetComponent <Construction>(); buildable = GetComponent <Buildable>(); unique_id = GetComponent <UniqueID>(); heat_source = GetComponent <HeatSource>(); if (fire_fx) { fire_fx.SetActive(false); } if (fuel_model) { fuel_model.SetActive(false); } }