Loot
Fixed: unable to undock with an aetheric drive (game requires locomotion) Entities have a chance of dropping any item on board when killed Mine behavior generalized to grid objects, used in dropped loot Added tractor beam (not itemized yet) which pulls in nearby loot (and mines!) Items are added to player inventory when they collide with the ship (and mines explode!) Added console command to spawn turret
This commit is contained in:
parent
c1d632f18a
commit
11a55e236b
56 changed files with 6962 additions and 161 deletions
|
|
@ -17,7 +17,6 @@ public class ConstantParticleWeapon : MonoBehaviour
|
|||
private float _emission;
|
||||
private List<ParticleSystem.Particle> _collisionParticles = new List<ParticleSystem.Particle>();
|
||||
private HullCollider _hull;
|
||||
private Transform _simulationSpace;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
|
@ -33,12 +32,11 @@ public class ConstantParticleWeapon : MonoBehaviour
|
|||
|
||||
public void Initialize()
|
||||
{
|
||||
_simulationSpace = new GameObject($"{gameObject.name} Sim Space").transform;
|
||||
foreach(var p in Particles)
|
||||
{
|
||||
var main = p.main;
|
||||
main.simulationSpace = ParticleSystemSimulationSpace.Custom;
|
||||
main.customSimulationSpace = _simulationSpace;
|
||||
main.customSimulationSpace = Source.LocalSpace;
|
||||
}
|
||||
|
||||
var trigger = Particles[0].trigger;
|
||||
|
|
@ -57,11 +55,9 @@ public class ConstantParticleWeapon : MonoBehaviour
|
|||
private void Update()
|
||||
{
|
||||
if (Source == null) return;
|
||||
_simulationSpace.position = Source.transform.position;
|
||||
if (_stopping && Particles.All(p=>p.particleCount == 0))
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
Destroy(_simulationSpace.gameObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Random = UnityEngine.Random;
|
|||
|
||||
public class Mine : MonoBehaviour
|
||||
{
|
||||
public GridObject GridObject;
|
||||
public MeshRenderer MeshRenderer;
|
||||
public int EmissionSubmesh;
|
||||
public AnimationCurve EmissionCurve;
|
||||
|
|
@ -15,12 +16,6 @@ public class Mine : MonoBehaviour
|
|||
public float ArmedCycleDuration;
|
||||
public float ActiveEmission;
|
||||
public float ArmedEmission;
|
||||
public float RotationSpeed;
|
||||
public float GridOffset;
|
||||
public float GridAttraction;
|
||||
public float Gravity;
|
||||
public float Drag = .1f;
|
||||
public float LaunchDrag;
|
||||
public Prototype HitEffect;
|
||||
public float Lifetime;
|
||||
|
||||
|
|
@ -28,7 +23,6 @@ public class Mine : MonoBehaviour
|
|||
public float BlastRange;
|
||||
public float BlastDelay;
|
||||
|
||||
private float2 _selfVelocity;
|
||||
private float _startTime;
|
||||
private float _blastTime;
|
||||
private bool _blastCountdown;
|
||||
|
|
@ -36,9 +30,6 @@ public class Mine : MonoBehaviour
|
|||
private Material _material;
|
||||
private float _pulseLerp;
|
||||
private float _emission;
|
||||
|
||||
public Zone Zone { get; set; }
|
||||
public Vector3 Velocity { get; set; }
|
||||
public float Damage { get; set; }
|
||||
public DamageType DamageType { get; set; }
|
||||
public EntityInstance Source { get; set; }
|
||||
|
|
@ -60,25 +51,8 @@ public class Mine : MonoBehaviour
|
|||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Zone == null) return;
|
||||
|
||||
var t = transform;
|
||||
var position = t.position;
|
||||
var gridHeight = Zone.GetHeight(position.Flatland()) + GridOffset;
|
||||
Velocity += Vector3.up * (sign(gridHeight - position.y) * GridAttraction * Time.deltaTime);
|
||||
Velocity *= max(0, 1 - LaunchDrag * Time.deltaTime);
|
||||
var normal = Zone.GetNormal(position.Flatland());
|
||||
var force = new float2(normal.x, normal.z);
|
||||
var forceMagnitude = lengthsq(force);
|
||||
if (forceMagnitude > .001f)
|
||||
{
|
||||
var fa = 1 / (1 - forceMagnitude) - 1;
|
||||
_selfVelocity += normalize(force) * Zone.Settings.GravityStrength * fa * Gravity;
|
||||
}
|
||||
_selfVelocity *= max(0, 1 - Drag * Time.deltaTime);
|
||||
t.position = position + (Velocity + new Vector3(_selfVelocity.x,0,_selfVelocity.y)) * Time.deltaTime;
|
||||
t.localRotation = Quaternion.Euler(sin(Time.time-_startTime * RotationSpeed) * 90, 0, cos(Time.time-_startTime * RotationSpeed) * 90);
|
||||
|
||||
var position = transform.position;
|
||||
|
||||
if (Time.time - _startTime > ActivationDelay && !_active)
|
||||
{
|
||||
_active = true;
|
||||
|
|
@ -91,7 +65,7 @@ public class Mine : MonoBehaviour
|
|||
_pulseLerp %= 1;
|
||||
if(!_blastCountdown)
|
||||
{
|
||||
foreach (var collider in Physics.OverlapSphere(t.position, BlastRange, 1))
|
||||
foreach (var collider in Physics.OverlapSphere(position, BlastRange, 1))
|
||||
{
|
||||
var hull = collider.GetComponent<HullCollider>();
|
||||
if (hull)
|
||||
|
|
@ -106,26 +80,32 @@ public class Mine : MonoBehaviour
|
|||
Time.time - _startTime > Lifetime ||
|
||||
_blastCountdown && Time.time > _blastTime)
|
||||
{
|
||||
foreach (var collider in Physics.OverlapSphere(t.position, BlastRange, 1 | (1 << 17)))
|
||||
{
|
||||
var shield = collider.GetComponent<ShieldManager>();
|
||||
if (shield && (shield.Entity.Shield != null && shield.Entity.Shield.Item.Active.Value && shield.Entity.Shield.CanTakeHit(DamageType, Damage)))
|
||||
{
|
||||
shield.Entity.Shield.TakeHit(DamageType, Damage);
|
||||
shield.ShowHit(t.position, sqrt(Damage));
|
||||
}
|
||||
var hull = collider.GetComponent<HullCollider>();
|
||||
if (hull && !(hull.Entity.Shield != null && hull.Entity.Shield.Item.Active.Value && hull.Entity.Shield.CanTakeHit(DamageType, Damage)))
|
||||
{
|
||||
hull.SendSplash(Damage, DamageType, Source.Entity, (collider.transform.position - t.position).normalized);
|
||||
}
|
||||
}
|
||||
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.position = t.position;
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
_material.SetFloat("_Emission", _emission * EmissionCurve.Evaluate(_pulseLerp));
|
||||
}
|
||||
|
||||
public void Explode()
|
||||
{
|
||||
var position = transform.position;
|
||||
foreach (var collider in Physics.OverlapSphere(position, BlastRange, 1 | (1 << 17)))
|
||||
{
|
||||
var shield = collider.GetComponent<ShieldManager>();
|
||||
if (shield && (shield.Entity.Shield != null && shield.Entity.Shield.Item.Active.Value && shield.Entity.Shield.CanTakeHit(DamageType, Damage)))
|
||||
{
|
||||
shield.Entity.Shield.TakeHit(DamageType, Damage);
|
||||
shield.ShowHit(position, sqrt(Damage));
|
||||
}
|
||||
var hull = collider.GetComponent<HullCollider>();
|
||||
if (hull && !(hull.Entity.Shield != null && hull.Entity.Shield.Item.Active.Value && hull.Entity.Shield.CanTakeHit(DamageType, Damage)))
|
||||
{
|
||||
hull.SendSplash(Damage, DamageType, Source.Entity, (collider.transform.position - position).normalized);
|
||||
}
|
||||
}
|
||||
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.position = position;
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@ public class MineManager : InstantWeaponEffectManager
|
|||
var angle = weapon.Spread / 2;
|
||||
p.Source = source;
|
||||
p.transform.position = barrel.position;
|
||||
p.Velocity = Quaternion.Euler(
|
||||
Random.Range(-angle, angle),
|
||||
Random.Range(-angle, angle),
|
||||
Random.Range(-angle, angle)) *
|
||||
barrel.forward *
|
||||
weapon.Velocity;
|
||||
p.GridObject.Velocity = Quaternion.Euler(
|
||||
Random.Range(-angle, angle),
|
||||
Random.Range(-angle, angle),
|
||||
Random.Range(-angle, angle)) *
|
||||
barrel.forward *
|
||||
weapon.Velocity;
|
||||
if(InheritVelocity)
|
||||
p.Velocity += new Vector3(source.Entity.Velocity.x, 0, source.Entity.Velocity.y);
|
||||
p.GridObject.Velocity += new Vector3(source.Entity.Velocity.x, 0, source.Entity.Velocity.y);
|
||||
p.Damage = weapon.Damage;
|
||||
p.Range = weapon.Range;
|
||||
p.DamageType = weapon.WeaponData.DamageType;
|
||||
p.Zone = source.Entity.Zone;
|
||||
p.GridObject.Zone = source.Entity.Zone;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue