* Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
143 lines
5.1 KiB
C#
143 lines
5.1 KiB
C#
using System;
|
|
using Content.Server.GameObjects.Components.Mobs;
|
|
using Content.Shared.Alert;
|
|
using Content.Shared.Atmos;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.GameObjects.Components.Damage;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Server.GameObjects.Components.Temperature
|
|
{
|
|
/// <summary>
|
|
/// Handles changing temperature,
|
|
/// informing others of the current temperature,
|
|
/// and taking fire damage from high temperature.
|
|
/// </summary>
|
|
[RegisterComponent]
|
|
public class TemperatureComponent : Component
|
|
{
|
|
/// <inheritdoc />
|
|
public override string Name => "Temperature";
|
|
|
|
[ViewVariables] public float CurrentTemperature { get => _currentTemperature; set => _currentTemperature = value; }
|
|
|
|
[ViewVariables] public float HeatDamageThreshold => _heatDamageThreshold;
|
|
[ViewVariables] public float ColdDamageThreshold => _coldDamageThreshold;
|
|
[ViewVariables] public float TempDamageCoefficient => _tempDamageCoefficient;
|
|
[ViewVariables] public float HeatCapacity {
|
|
get
|
|
{
|
|
if (Owner.TryGetComponent<IPhysBody>(out var physics))
|
|
{
|
|
return SpecificHeat * physics.Mass;
|
|
}
|
|
|
|
return Atmospherics.MinimumHeatCapacity;
|
|
}
|
|
}
|
|
|
|
[ViewVariables] public float SpecificHeat => _specificHeat;
|
|
|
|
private float _heatDamageThreshold;
|
|
private float _coldDamageThreshold;
|
|
private float _tempDamageCoefficient;
|
|
private float _currentTemperature;
|
|
private float _specificHeat;
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
|
|
serializer.DataField(ref _heatDamageThreshold, "heatDamageThreshold", 0);
|
|
serializer.DataField(ref _coldDamageThreshold, "coldDamageThreshold", 0);
|
|
serializer.DataField(ref _tempDamageCoefficient, "tempDamageCoefficient", 1);
|
|
serializer.DataField(ref _currentTemperature, "currentTemperature", Atmospherics.T20C);
|
|
serializer.DataField(ref _specificHeat, "specificHeat", Atmospherics.MinimumHeatCapacity);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
var tempDamage = 0;
|
|
DamageType? damageType = null;
|
|
if (CurrentTemperature >= _heatDamageThreshold)
|
|
{
|
|
tempDamage = (int) Math.Floor((CurrentTemperature - _heatDamageThreshold) * _tempDamageCoefficient);
|
|
damageType = DamageType.Heat;
|
|
}
|
|
else if (CurrentTemperature <= _coldDamageThreshold)
|
|
{
|
|
tempDamage = (int) Math.Floor((_coldDamageThreshold - CurrentTemperature) * _tempDamageCoefficient);
|
|
damageType = DamageType.Cold;
|
|
}
|
|
|
|
if (Owner.TryGetComponent(out ServerAlertsComponent status))
|
|
{
|
|
switch(CurrentTemperature)
|
|
{
|
|
// Cold strong.
|
|
case var t when t <= 260:
|
|
status.ShowAlert(AlertType.Cold, 3);
|
|
break;
|
|
|
|
// Cold mild.
|
|
case var t when t <= 280 && t > 260:
|
|
status.ShowAlert(AlertType.Cold, 2);
|
|
break;
|
|
|
|
// Cold weak.
|
|
case var t when t <= 292 && t > 280:
|
|
status.ShowAlert(AlertType.Cold, 1);
|
|
break;
|
|
|
|
// Safe.
|
|
case var t when t <= 327 && t > 292:
|
|
status.ClearAlertCategory(AlertCategory.Temperature);
|
|
break;
|
|
|
|
// Heat weak.
|
|
case var t when t <= 335 && t > 327:
|
|
status.ShowAlert(AlertType.Hot, 1);
|
|
break;
|
|
|
|
// Heat mild.
|
|
case var t when t <= 345 && t > 335:
|
|
status.ShowAlert(AlertType.Hot, 2);
|
|
break;
|
|
|
|
// Heat strong.
|
|
case var t when t > 345:
|
|
status.ShowAlert(AlertType.Hot, 3);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!damageType.HasValue) return;
|
|
|
|
if (!Owner.TryGetComponent(out IDamageableComponent component)) return;
|
|
component.ChangeDamage(damageType.Value, tempDamage, false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Forcefully give heat to this component
|
|
/// </summary>
|
|
/// <param name="heatAmount"></param>
|
|
public void ReceiveHeat(float heatAmount)
|
|
{
|
|
CurrentTemperature += heatAmount / HeatCapacity;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Forcefully remove heat from this component
|
|
/// </summary>
|
|
/// <param name="heatAmount"></param>
|
|
public void RemoveHeat(float heatAmount)
|
|
{
|
|
CurrentTemperature -= heatAmount / HeatCapacity;
|
|
}
|
|
|
|
}
|
|
}
|