Heatstroke VFX

Filling the heatstroke meter now results in a postprocessing filter which increasingly distorts the player's view as they get closer to death.
This commit is contained in:
Reinier Vens 2021-03-06 02:42:19 +00:00
commit 2f088b5590
11 changed files with 183 additions and 26 deletions

View file

@ -2329,7 +2329,7 @@ Transform:
- {fileID: 488792361}
- {fileID: 970624070}
m_Father: {fileID: 1665127616}
m_RootOrder: 5
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &204301709
GameObject:
@ -11021,7 +11021,7 @@ Transform:
- {fileID: 1075335641}
- {fileID: 166261017}
m_Father: {fileID: 1665127616}
m_RootOrder: 6
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &831892783
GameObject:
@ -11060,6 +11060,54 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -2, y: 24}
m_Pivot: {x: 0.5, y: 1}
--- !u!1 &837424433
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 837424434}
- component: {fileID: 837424435}
m_Layer: 8
m_Name: Severe Heatstroke Postprocessing
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &837424434
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 837424433}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1665127616}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &837424435
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 837424433}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
m_Name:
m_EditorClassIdentifier:
sharedProfile: {fileID: 11400000, guid: dd57a2fd868ca1042b1ce02b253716e7, type: 2}
isGlobal: 1
blendDistance: 0
weight: 0
priority: 2
--- !u!1 &840997851
GameObject:
m_ObjectHideFlags: 0
@ -13106,6 +13154,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 39f95af24dd29a645895a57a75460b0c, type: 3}
m_Name:
m_EditorClassIdentifier:
HeatstrokePP: {fileID: 1404901906}
SevereHeatstrokePP: {fileID: 837424435}
ViewDot: {fileID: 146394778}
TargetIndicator: {fileID: 1556666357}
LockIndicator: {fileID: 1876420642}
@ -16581,6 +16631,54 @@ CanvasGroup:
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!1 &1404901904
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1404901905}
- component: {fileID: 1404901906}
m_Layer: 8
m_Name: Heatstroke Postprocessing
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1404901905
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1404901904}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1665127616}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1404901906
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1404901904}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
m_Name:
m_EditorClassIdentifier:
sharedProfile: {fileID: 11400000, guid: a66f8baac31efff459abb11a52203aa6, type: 2}
isGlobal: 1
blendDistance: 0
weight: 0
priority: 1
--- !u!1 &1416434298
GameObject:
m_ObjectHideFlags: 0
@ -18080,7 +18178,7 @@ Transform:
- {fileID: 1537342002}
- {fileID: 39508928}
m_Father: {fileID: 1665127616}
m_RootOrder: 4
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1547889400
MonoBehaviour:
@ -18146,7 +18244,7 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 55.675
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -19077,7 +19175,7 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 60.98
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -19710,6 +19808,8 @@ Transform:
- {fileID: 393266592}
- {fileID: 2115559090}
- {fileID: 937280108}
- {fileID: 1404901905}
- {fileID: 837424434}
- {fileID: 1547889399}
- {fileID: 199435031}
- {fileID: 826773974}

Binary file not shown.

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a66f8baac31efff459abb11a52203aa6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dd57a2fd868ca1042b1ce02b253716e7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -14,6 +14,7 @@ using UniRx;
using UnityEngine;
using Unity.Mathematics;
using UnityEngine.InputSystem;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
@ -22,6 +23,8 @@ using Random = UnityEngine.Random;
public class ActionGameManager : MonoBehaviour
{
public PostProcessVolume HeatstrokePP;
public PostProcessVolume SevereHeatstrokePP;
public PlaceUIElementWorldspace ViewDot;
public PlaceUIElementWorldspace TargetIndicator;
public Prototype LockIndicator;
@ -55,20 +58,27 @@ public class ActionGameManager : MonoBehaviour
private float _time;
private AetheriaInput _input;
private int _zoomLevelIndex;
private Ship _currentShip;
// private ShipInput _shipInput;
private List<Agent> _shipAgents = new List<Agent>();
private IDisposable _shipTargetSubscription;
private float2 _shipYawPitch;
private float3 _viewDirection;
private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups;
private (LockWeapon targetLock, PlaceUIElementWorldspace indicator, Rotate spin)[] _lockingIndicators;
private List<IDisposable> _shipSubscriptions = new List<IDisposable>();
private float _severeHeatstrokePhase;
public List<Entity> PlayerEntities { get; } = new List<Entity>();
public EquippedDockingBay DockingBay { get; private set; }
public Entity DockedEntity { get; private set; }
public Ship CurrentShip { get; set; }
public Ship CurrentShip
{
get => _currentShip;
set => _currentShip = value;
}
public DatabaseCache ItemData { get; private set; }
public ItemManager ItemManager { get; private set; }
public Zone Zone { get; private set; }
@ -81,6 +91,7 @@ public class ActionGameManager : MonoBehaviour
(float2(0, -1), "Rear")
};
public void SaveLoadout(EntityPack pack)
{
File.WriteAllBytes(Path.Combine(_loadoutPath.FullName, $"{pack.Name}.preset"), MessagePackSerializer.Serialize(pack));
@ -479,6 +490,8 @@ public class ActionGameManager : MonoBehaviour
var bay = entity.TryDock(CurrentShip);
if (bay != null)
{
foreach(var subscription in _shipSubscriptions) subscription.Dispose();
_shipSubscriptions.Clear();
DockedEntity = entity;
SectorRenderer.PerspectiveEntity = DockedEntity;
DockingBay = bay;
@ -550,8 +563,7 @@ public class ActionGameManager : MonoBehaviour
if (float.IsNaN(CurrentShip.Hull.Durability))
Debug.Log("WTF!");
});
_shipTargetSubscription?.Dispose();
_shipTargetSubscription = CurrentShip.Target.Subscribe(target =>
_shipSubscriptions.Add(CurrentShip.Target.Subscribe(target =>
{
TargetIndicator.gameObject.SetActive(CurrentShip.Target.Value != null);
TargetShipPanel.gameObject.SetActive(target != null);
@ -560,7 +572,9 @@ public class ActionGameManager : MonoBehaviour
TargetShipPanel.Display(target, true);
TargetSchematicDisplay.ShowShip(target, CurrentShip);
}
});
}));
//_shipSubscriptions.Add(CurrentShip.HeatstrokeRisk.Subscribe(_ => _severeHeatstrokePhase = 0));
Cursor.lockState = CursorLockMode.Locked;
GameplayUI.SetActive(true);
@ -647,6 +661,11 @@ public class ActionGameManager : MonoBehaviour
_viewDirection = mul(float3(0, 0, 1), Unity.Mathematics.float3x3.Euler(float3(_shipYawPitch.yx, 0), RotationOrder.YXZ));
CurrentShip.LookDirection = _viewDirection;
CurrentShip.MovementDirection = _input.Player.Move.ReadValue<Vector2>();
HeatstrokePP.weight = saturate(unlerp(0, Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, CurrentShip.Heatstroke));
var severeHeatstrokeLerp = saturate(unlerp(Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, 1, CurrentShip.Heatstroke));
SevereHeatstrokePP.weight =
severeHeatstrokeLerp + severeHeatstrokeLerp * (1 - severeHeatstrokeLerp) *
max(Settings.HeatstrokePhasingFloor, sin(Time.time * Settings.HeatstrokePhasingFrequency));
}
}
foreach(var agent in _shipAgents)

View file

@ -10,6 +10,8 @@ using UnityEngine;
[CreateAssetMenu(fileName = "Sector Display Properties", menuName = "Aetheria/Sector Display Properties")]
public class GameSettings : ScriptableObject
{
public float HeatstrokePhasingFloor = 0;
public float HeatstrokePhasingFrequency = 5;
public float WormholeDistanceRatio;
public float DefaultZoneRadius;
public float DefaultZoneMass;

View file

@ -27,7 +27,6 @@ public class Cockpit : IBehavior
public BehaviorData Data => _data;
public float Heatstroke { get; private set; }
public Cockpit(ItemManager context, CockpitData data, Entity entity, EquippedItem item)
{
@ -35,22 +34,10 @@ public class Cockpit : IBehavior
_data = data;
Entity = entity;
Item = item;
Heatstroke = 0;
}
public bool Execute(float delta)
{
if (Item.Temperature > Context.GameplaySettings.HeatstrokeTemperature)
{
Heatstroke = saturate(
Heatstroke +
pow(Item.Temperature - Context.GameplaySettings.HeatstrokeTemperature, Context.GameplaySettings.HeatstrokeExponent) *
Context.GameplaySettings.HeatstrokeMultiplier * delta);
}
else
{
Heatstroke = saturate(Heatstroke - Context.GameplaySettings.HeatstrokeRecoverySpeed * delta);
}
return Heatstroke < Context.GameplaySettings.HeatstrokeControlLimit;
return true;
}
}

View file

@ -97,6 +97,8 @@ public abstract class Entity
}
public Shield Shield { get; private set; }
public Cockpit Cockpit { get; private set; }
public float Heatstroke { get; private set; }
public float TargetRange { get; private set; }
public float MaxTemp { get; private set; }
@ -112,6 +114,7 @@ public abstract class Entity
public Subject<EquippedItem> ItemOnline = new Subject<EquippedItem>();
public Subject<float> HullDamage = new Subject<float>();
public Subject<Entity> Docked = new Subject<Entity>();
public Subject<Unit> HeatstrokeRisk = new Subject<Unit>();
public UniRx.IObservable<EquippedItem> ItemDestroyed;
public UniRx.IObservable<int2> HullArmorDepleted;
@ -123,6 +126,7 @@ public abstract class Entity
public virtual void Activate()
{
_active = true;
Heatstroke = 0;
foreach (var item in Equipment)
foreach (var behavior in item.Behaviors)
{
@ -355,6 +359,8 @@ public abstract class Entity
_heatsinks.Remove(heatsink);
if (b is Shield)
Shield = null;
if (b is Cockpit)
Cockpit = null;
}
return item.EquippableItem;
@ -533,6 +539,8 @@ public abstract class Entity
_heatsinks.Add(heatsink);
if (b is Shield shield)
Shield = shield;
if (b is Cockpit cockpit)
Cockpit = cockpit;
}
equippedItem.OnOnline += () => ItemOnline.OnNext(equippedItem);
@ -731,6 +739,24 @@ public abstract class Entity
UpdateTemperature(delta);
if(Cockpit != null)
{
if (Cockpit.Item.Temperature > ItemManager.GameplaySettings.HeatstrokeTemperature)
{
var previous = Heatstroke;
Heatstroke = saturate(
Heatstroke +
pow(Cockpit.Item.Temperature - ItemManager.GameplaySettings.HeatstrokeTemperature, ItemManager.GameplaySettings.HeatstrokeExponent) *
ItemManager.GameplaySettings.HeatstrokeMultiplier * delta);
if(previous < ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold && Heatstroke > ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold)
HeatstrokeRisk.OnNext(Unit.Default);
}
else
{
Heatstroke = saturate(Heatstroke - ItemManager.GameplaySettings.HeatstrokeRecoverySpeed * delta);
}
}
if (_active)
{
foreach (var equippedItem in _orderedEquipment)

View file

@ -88,6 +88,7 @@ public class ZoneGenerationSettings
[Serializable, MessagePackObject(keyAsPropertyName: true), JsonObject]
public class GameplaySettings
{
public float SevereHeatstrokeRiskThreshold = .25f;
public float WormholeDepth = 1000;
public float WormholeExitVelocity = 20;
public float WormholeExitRadius = 50;

View file

@ -241,7 +241,7 @@ public class SchematicDisplay : MonoBehaviour
CockpitTemperatureLabel.text = $"{((int)(_cockpit.Item.Temperature - 273.15f)).ToString()}°C";
HeatstrokeMeterFill.anchorMax = new Vector2(_cockpit.Heatstroke, 1);
HeatstrokeMeterFill.anchorMax = new Vector2(_entity.Heatstroke, 1);
HeatstrokeLimitFill.anchorMax = new Vector2(_cockpit.Item.Temperature / Settings.GameplaySettings.HeatstrokeTemperature, 1);
if (_capacitors.Length == 0)