Aetheric Drive VFX
This commit is contained in:
parent
68ab14dc42
commit
80863cf64b
9 changed files with 4882 additions and 13 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue