Aetheric Drive VFX

This commit is contained in:
Reinier Vens 2021-04-30 15:37:39 +01:00
commit 80863cf64b
9 changed files with 4882 additions and 13 deletions

View file

@ -86,7 +86,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Scale: 5.3455396
- _Scale: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 151cf0ff54a22274caf671ece149fa6e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -802,8 +802,8 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 741153267}
m_LocalRotation: {x: 0.0155069325, y: 0.9502416, z: -0.30741316, w: 0.047933314}
m_LocalPosition: {x: -117.520035, y: -77.087425, z: 149.09027}
m_LocalRotation: {x: 0.015506926, y: 0.9502416, z: -0.30741316, w: 0.047933295}
m_LocalPosition: {x: -117.52003, y: -77.08742, z: 149.09026}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 412917866}
@ -1301,8 +1301,8 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 965376321}
m_LocalRotation: {x: 0.0155069325, y: 0.9502416, z: -0.30741316, w: 0.047933314}
m_LocalPosition: {x: -117.520035, y: -77.087425, z: 149.09027}
m_LocalRotation: {x: 0.015506926, y: 0.9502416, z: -0.30741316, w: 0.047933295}
m_LocalPosition: {x: -117.52003, y: -77.08742, z: 149.09026}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
@ -2388,7 +2388,7 @@ PrefabInstance:
- target: {fileID: 3664209305474245377, guid: 3d8d9cbf10b12214e98891c1f03c1e99,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 60.98
objectReference: {fileID: 0}
- target: {fileID: 3664209305474245377, guid: 3d8d9cbf10b12214e98891c1f03c1e99,
type: 3}
@ -2413,7 +2413,7 @@ PrefabInstance:
- target: {fileID: 3664209306888449100, guid: 3d8d9cbf10b12214e98891c1f03c1e99,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 55.675
objectReference: {fileID: 0}
- target: {fileID: 3664209306888449100, guid: 3d8d9cbf10b12214e98891c1f03c1e99,
type: 3}

View file

@ -416,7 +416,7 @@ public class EntityInstance : MonoBehaviour
_destroyed = true;
foreach (var gear in Entity.Equipment)
{
if (Random.value < ZoneRenderer.Settings.LootDropProbability)
if (gear != Entity.EquippedHull && Random.value < ZoneRenderer.Settings.LootDropProbability)
{
ZoneRenderer.DropItem(
Entity.Position,

View file

@ -2,6 +2,8 @@ using System;
using System.Collections;
using System.Linq;
using UnityEngine;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class ShipInstance : EntityInstance
{
@ -14,8 +16,17 @@ public class ShipInstance : EntityInstance
public float BaseEmission;
public int MaxParticleCount;
}
private class AetherDriveInstance
{
public AetherDrive Drive;
public ParticleSystem Particles;
public float BaseEmission;
public float BaseForce;
}
private ThrusterInstance[] _thrusters;
private AetherDriveInstance _aetherDrive;
public Ship Ship { get; private set; }
@ -35,6 +46,20 @@ public class ShipInstance : EntityInstance
return;
}
Ship = ship;
var drive = ship.GetBehavior<AetherDrive>();
if (drive != null)
{
var particles = Instantiate(UnityHelpers.LoadAsset<ParticleSystem>(drive.DriveData.Particles), transform, false);
var main = particles.main;
main.customSimulationSpace = LocalSpace;
_aetherDrive = new AetherDriveInstance
{
Drive = drive,
BaseEmission = particles.emission.rateOverTimeMultiplier,
Particles = particles,
BaseForce = particles.forceOverLifetime.z.curveMultiplier
};
}
_thrusters = ship.GetBehaviors<Thruster>().Select(thruster =>
{
var effectData = (ThrusterData) thruster.Data;
@ -89,6 +114,18 @@ public class ShipInstance : EntityInstance
TractorBeam.Power = Entity.TractorPower;
TractorBeam.Direction = Entity.LookDirection;
if (_aetherDrive != null)
{
var thrust = length(_aetherDrive.Drive.ThrustDirection);
var forceOverLifetime = _aetherDrive.Particles.forceOverLifetime;
var curve = forceOverLifetime.z;
curve.curveMultiplier = thrust * _aetherDrive.BaseForce;
if(thrust > .01f)
_aetherDrive.Particles.transform.forward = new Vector3(_aetherDrive.Drive.ThrustDirection.x, 0, _aetherDrive.Drive.ThrustDirection.y);
var emissionModule = _aetherDrive.Particles.emission;
emissionModule.rateOverTimeMultiplier = _aetherDrive.BaseEmission * thrust;
}
foreach (var thrusterInstance in _thrusters)
{

View file

@ -45,6 +45,9 @@ public class AetherDriveData : BehaviorData
[InspectableAudioParameter, JsonProperty("torqueAudio"), Key(12), RuntimeInspectable]
public uint TorqueRatioAudioParameter;
[InspectablePrefab, JsonProperty("particles"), Key(13)]
public string Particles;
public override Behavior CreateInstance(EquippedItem item)
{
@ -65,6 +68,7 @@ public class AetherDrive : Behavior
public float3 Thrust { get; private set; }
public float3 Rpm { get; private set; }
public float MaximumRpm { get; private set; }
public float2 ThrustDirection { get; private set; }
public AetherDriveData DriveData => _data;
@ -105,9 +109,10 @@ public class AetherDrive : Behavior
var heat = rpmLoss * _data.RotorMass * (1 - couplingEfficiency);
AddHeat((heat.x + heat.y + heat.z)*ItemManager.GameplaySettings.AetherHeatMultiplier);
ThrustDirection = forward * (_axis.x * force.x / Entity.Mass) + right * (_axis.y * force.y / Entity.Mass);
Entity.Velocity += ThrustDirection;
Entity.Velocity += forward * (_axis.x * force.x / Entity.Mass);
Entity.Velocity += right * (_axis.y * force.y / Entity.Mass);
Entity.Direction = mul(Entity.Direction,
Unity.Mathematics.float2x2.Rotate(force.z * _axis.z * ItemManager.GameplaySettings.AetherTorqueMultiplier / Entity.Mass));

BIN
GameData/AetherDB.msgpack (Stored with Git LFS)

Binary file not shown.

BIN
GameData/PlayerSettings.msgpack (Stored with Git LFS)

Binary file not shown.