Delete Unity weapon effect authority
This commit is contained in:
parent
11e43a0d3f
commit
d687e275d8
29 changed files with 59 additions and 1498 deletions
|
|
@ -1,106 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ConstantLaser : MonoBehaviour
|
||||
{
|
||||
public AnimationCurve StartCurve;
|
||||
public AnimationCurve EndCurve;
|
||||
public AnimationCurve IntensityCurve;
|
||||
public float WidthMultiplier = 1;
|
||||
public float StartDuration;
|
||||
public float FadeDuration;
|
||||
public float CycleDuration;
|
||||
public LineRenderer LineRenderer;
|
||||
|
||||
public float ImpactIntensity { get; set; } = 1;
|
||||
public Entity SourceEntity { get; set; }
|
||||
public ZoneRenderer ZoneRenderer { get; set; }
|
||||
public float Range { get; set; }
|
||||
|
||||
private float _intensity;
|
||||
private float _stopIntensity;
|
||||
private bool _starting;
|
||||
private bool _stopping;
|
||||
private float _startTime;
|
||||
private float _cycleStartTime;
|
||||
private readonly Vector3[] _zeros = {Vector3.zero, Vector3.zero};
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_stopping = false;
|
||||
_starting = true;
|
||||
_startTime = Time.time;
|
||||
LineRenderer.SetPositions(_zeros);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_stopping)
|
||||
{
|
||||
var lerp = (Time.time - _startTime) / FadeDuration;
|
||||
LineRenderer.widthMultiplier = EndCurve.Evaluate(lerp) * _stopIntensity * WidthMultiplier;
|
||||
|
||||
if (lerp > 1)
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var lerp = (Time.time - _startTime) / StartDuration;
|
||||
if (lerp > 1)
|
||||
{
|
||||
if (_starting)
|
||||
{
|
||||
_starting = false;
|
||||
_cycleStartTime = Time.time;
|
||||
}
|
||||
_intensity = IntensityCurve.Evaluate((Time.time - _cycleStartTime) / CycleDuration % CycleDuration);
|
||||
LineRenderer.widthMultiplier = _intensity * WidthMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
LineRenderer.widthMultiplier = StartCurve.Evaluate(lerp) * WidthMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
LineRenderer.SetPosition(0, transform.position);
|
||||
var hitFound = false;
|
||||
if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls(
|
||||
ZoneRenderer,
|
||||
SourceEntity,
|
||||
transform.position,
|
||||
transform.forward,
|
||||
Range,
|
||||
0,
|
||||
out var hits))
|
||||
{
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
var hull = hit.Hull;
|
||||
var entity = hull.Entity;
|
||||
if (entity.Shield != null && entity.Shield.Item.Active.Value)
|
||||
{
|
||||
hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity));
|
||||
LineRenderer.SetPosition(1, hit.Point);
|
||||
hitFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
LineRenderer.SetPosition(1, hit.Point);
|
||||
hitFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hitFound)
|
||||
LineRenderer.SetPosition(1, transform.position + transform.forward * Range);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_stopping = true;
|
||||
_stopIntensity = _intensity;
|
||||
_startTime = Time.time;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0fdff1d9c6e4a574f987f8cecdb87f36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 90
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConstantLaserManager : ConstantWeaponEffectManager
|
||||
{
|
||||
public Prototype LaserPrototype;
|
||||
|
||||
private Dictionary<EquippedItem, ConstantLaser> _lasers = new Dictionary<EquippedItem, ConstantLaser>();
|
||||
|
||||
public override void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = LaserPrototype.Instantiate<ConstantLaser>();
|
||||
p.SourceEntity = source.Entity;
|
||||
p.ZoneRenderer = source.ZoneRenderer;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
p.Range = weapon.Range;
|
||||
var t = p.transform;
|
||||
t.SetParent(barrel);
|
||||
t.forward = barrel.forward;
|
||||
t.position = barrel.position;
|
||||
p.ImpactIntensity = 1;
|
||||
_lasers.Add(item, p);
|
||||
}
|
||||
|
||||
public override void StopFiring(EquippedItem item)
|
||||
{
|
||||
_lasers[item].Stop();
|
||||
_lasers.Remove(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1a62592df67e114d880374819659914
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ConstantLightning : MonoBehaviour
|
||||
{
|
||||
public LightningCompute Lightning;
|
||||
public float HitRadius;
|
||||
public AnimationCurve FadeCurve;
|
||||
public float StartWidth = 1;
|
||||
public float EndWidth = 1;
|
||||
public float FadeDuration;
|
||||
|
||||
public Transform Barrel { get; set; }
|
||||
public float ImpactIntensity { get; set; } = 1;
|
||||
public EntityInstance Source { get; set; }
|
||||
public float Range { get; set; }
|
||||
|
||||
private bool _stopping;
|
||||
private float _startTime;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_stopping = false;
|
||||
Lightning.StartAnimation();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Barrel == null) return;
|
||||
if (_stopping)
|
||||
{
|
||||
var lerp = (Time.time - _startTime) / FadeDuration;
|
||||
Lightning.StartWidth = FadeCurve.Evaluate(lerp) * StartWidth;
|
||||
Lightning.EndWidth = FadeCurve.Evaluate(lerp) * EndWidth;
|
||||
|
||||
if (lerp > 1)
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Lightning.StartWidth = StartWidth;
|
||||
Lightning.EndWidth = EndWidth;
|
||||
}
|
||||
|
||||
Lightning.FixedEndpoint = false;
|
||||
if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls(
|
||||
Source?.ZoneRenderer,
|
||||
Source?.Entity,
|
||||
Barrel.position,
|
||||
Barrel.forward,
|
||||
Range,
|
||||
HitRadius,
|
||||
out var hits))
|
||||
{
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
var hull = hit.Hull;
|
||||
var entity = hull.Entity;
|
||||
if (entity.Shield != null && entity.Shield.Item.Active.Value)
|
||||
{
|
||||
hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity));
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
Lightning.FixedEndpoint = true;
|
||||
Lightning.EndPosition = hit.Point;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Lightning.FixedEndpoint)
|
||||
Lightning.EndPosition = Barrel.position + Barrel.forward * Range;
|
||||
|
||||
Lightning.StartPosition = Barrel.position;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_stopping = true;
|
||||
_startTime = Time.time;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b184352ea3694b8d892f1402b8d51153
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 55
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class ConstantLightningManager : ConstantWeaponEffectManager
|
||||
{
|
||||
public Prototype LightningPrototype;
|
||||
|
||||
private Dictionary<EquippedItem, ConstantLightning> _bolts = new Dictionary<EquippedItem, ConstantLightning>();
|
||||
|
||||
public override void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = LightningPrototype.Instantiate<ConstantLightning>();
|
||||
p.Source = source;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
p.Barrel = barrel;
|
||||
p.Range = weapon.Range;
|
||||
p.ImpactIntensity = 1;
|
||||
_bolts.Add(item, p);
|
||||
}
|
||||
|
||||
public override void StopFiring(EquippedItem item)
|
||||
{
|
||||
_bolts[item].Stop();
|
||||
_bolts.Remove(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ecabe4f078a147459bba6172582d7bc8
|
||||
timeCreated: 1612491892
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConstantParticleWeapon : MonoBehaviour
|
||||
{
|
||||
public ParticleSystem[] Particles;
|
||||
public float CastRadius = 0.25f;
|
||||
|
||||
public float Range { get; set; }
|
||||
public EntityInstance Source { get; set; }
|
||||
public EntityInstance Target { get; set; }
|
||||
|
||||
private bool _stopping;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
foreach(var p in Particles)
|
||||
{
|
||||
var emission = p.emission;
|
||||
emission.enabled = true;
|
||||
}
|
||||
_stopping = false;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
foreach(var p in Particles)
|
||||
{
|
||||
var main = p.main;
|
||||
main.simulationSpace = ParticleSystemSimulationSpace.Custom;
|
||||
main.customSimulationSpace = Source.LocalSpace;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Source == null) return;
|
||||
if (_stopping && Particles.All(p=>p.particleCount == 0))
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stopping || Target == null || Range <= 0)
|
||||
return;
|
||||
|
||||
if (AetheriaYmirPhysicsBridge.Instance.TryCastTargetHulls(
|
||||
Target,
|
||||
transform.position,
|
||||
transform.forward,
|
||||
Range,
|
||||
CastRadius,
|
||||
out var hits))
|
||||
{
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
foreach(var p in Particles)
|
||||
{
|
||||
var emission = p.emission;
|
||||
emission.enabled = false;
|
||||
}
|
||||
_stopping = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 200b7ae77af3480e98184bdffe2c0103
|
||||
timeCreated: 1612570252
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConstantParticleWeaponManager : ConstantWeaponEffectManager
|
||||
{
|
||||
public Prototype WeaponPrototype;
|
||||
|
||||
private Dictionary<EquippedItem, ConstantParticleWeapon> _weapons = new Dictionary<EquippedItem, ConstantParticleWeapon>();
|
||||
|
||||
public override void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = WeaponPrototype.Instantiate<ConstantParticleWeapon>();
|
||||
p.Source = source;
|
||||
p.Target = target;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
var t = p.transform;
|
||||
t.SetParent(barrel);
|
||||
t.forward = barrel.forward;
|
||||
t.position = barrel.position;
|
||||
p.Range = weapon.Range;
|
||||
_weapons.Add(item, p);
|
||||
p.Initialize();
|
||||
}
|
||||
|
||||
public override void StopFiring(EquippedItem item)
|
||||
{
|
||||
_weapons[item].Stop();
|
||||
_weapons.Remove(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7559cc5b68bf4495ae2643dc8d1b742b
|
||||
timeCreated: 1612570303
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ConstantWeaponEffectManager : MonoBehaviour
|
||||
{
|
||||
public abstract void StartFiring(ConstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target);
|
||||
public abstract void StopFiring(EquippedItem item);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38df809a0cf4b7748bad88620bb7b3ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class HitscanEffect : MonoBehaviour
|
||||
{
|
||||
public float Duration;
|
||||
public AnimationCurve IntensityCurve;
|
||||
public LineRenderer Line;
|
||||
public ParticleSystem LineEffect;
|
||||
public Prototype HitEffect;
|
||||
|
||||
public float ImpactIntensity { get; set; } = 1;
|
||||
public Entity SourceEntity { get; set; }
|
||||
public ZoneRenderer ZoneRenderer { get; set; }
|
||||
public float Range { get; set; }
|
||||
|
||||
private float _startTime;
|
||||
private bool _active = false;
|
||||
|
||||
public void Fire()
|
||||
{
|
||||
_startTime = Time.time;
|
||||
var hitFound = false;
|
||||
if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls(
|
||||
ZoneRenderer,
|
||||
SourceEntity,
|
||||
transform.position,
|
||||
transform.forward,
|
||||
Range,
|
||||
0,
|
||||
out var hits))
|
||||
{
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
var hull = hit.Hull;
|
||||
var entity = hull.Entity;
|
||||
if (entity.Shield != null && entity.Shield.Item.Active.Value)
|
||||
{
|
||||
hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity));
|
||||
hitFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hitFound = true;
|
||||
}
|
||||
|
||||
if (hitFound && HitEffect != null)
|
||||
{
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.SetParent(hull.transform);
|
||||
ht.position = hit.Point;
|
||||
}
|
||||
|
||||
var length = (hit.Point - transform.position).magnitude;
|
||||
Line.SetPosition(1, Vector3.forward * length);
|
||||
var emission = LineEffect.emission;
|
||||
emission.rateOverTimeMultiplier = length;
|
||||
var shape = LineEffect.shape;
|
||||
shape.position = Vector3.forward * (length / 2);
|
||||
shape.scale = Vector3.one * (length / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hitFound)
|
||||
{
|
||||
Line.SetPosition(1, Vector3.forward * Range);
|
||||
var emission = LineEffect.emission;
|
||||
emission.rateOverTimeMultiplier = Range;
|
||||
var shape = LineEffect.shape;
|
||||
shape.position = Vector3.forward * (Range / 2);
|
||||
shape.scale = Vector3.one * (Range / 2);
|
||||
}
|
||||
LineEffect.Play(true);
|
||||
_active = true;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!_active) return;
|
||||
var lerp = (Time.time - _startTime) / Duration;
|
||||
if (lerp > 1)
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
return;
|
||||
}
|
||||
|
||||
Line.widthMultiplier = IntensityCurve.Evaluate(lerp);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f8555514e892b2c438fe085da1fdf89d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class HitscanManager : InstantWeaponEffectManager
|
||||
{
|
||||
public Prototype Prototype;
|
||||
public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = Prototype.Instantiate<HitscanEffect>();
|
||||
p.SourceEntity = source.Entity;
|
||||
p.ZoneRenderer = source.ZoneRenderer;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
var t = p.transform;
|
||||
t.SetParent(barrel, false);
|
||||
t.localRotation = Quaternion.identity;
|
||||
t.localPosition = Vector3.zero;
|
||||
// t.position = barrel.position;
|
||||
// t.forward = barrel.forward;
|
||||
p.Range = weapon.Range;
|
||||
p.ImpactIntensity = 1;
|
||||
p.Fire();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 90fe995fff18457987112f6f96b45a17
|
||||
timeCreated: 1611954267
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Laser : MonoBehaviour
|
||||
{
|
||||
public AnimationCurve IntensityCurve;
|
||||
public float Duration;
|
||||
public LineRenderer LineRenderer;
|
||||
|
||||
public float ImpactIntensity { get; set; } = 1;
|
||||
public Entity SourceEntity { get; set; }
|
||||
public ZoneRenderer ZoneRenderer { get; set; }
|
||||
public float Range { get; set; }
|
||||
|
||||
private float _startTime;
|
||||
private readonly Vector3[] _zeros = {Vector3.zero, Vector3.zero};
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_startTime = Time.time;
|
||||
LineRenderer.SetPositions(_zeros);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var lerp = (Time.time - _startTime) / Duration;
|
||||
if (lerp > 1)
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
return;
|
||||
}
|
||||
|
||||
LineRenderer.SetPosition(0, transform.position);
|
||||
var hitFound = false;
|
||||
if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls(
|
||||
ZoneRenderer,
|
||||
SourceEntity,
|
||||
transform.position,
|
||||
transform.forward,
|
||||
Range,
|
||||
0,
|
||||
out var hits))
|
||||
{
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
var hull = hit.Hull;
|
||||
var entity = hull.Entity;
|
||||
if (entity.Shield != null && entity.Shield.Item.Active.Value)
|
||||
{
|
||||
hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity));
|
||||
LineRenderer.SetPosition(1, hit.Point);
|
||||
hitFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
LineRenderer.SetPosition(1, hit.Point);
|
||||
hitFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hitFound)
|
||||
LineRenderer.SetPosition(1, transform.position + transform.forward * Range);
|
||||
|
||||
LineRenderer.widthMultiplier = IntensityCurve.Evaluate(lerp);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 166b726996e49bd4b87608739a5af815
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 80
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LaserManager : InstantWeaponEffectManager
|
||||
{
|
||||
public Prototype ProjectilePrototype;
|
||||
|
||||
public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = ProjectilePrototype.Instantiate<Laser>();
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
var t = p.transform;
|
||||
t.SetParent(barrel);
|
||||
t.forward = barrel.forward;
|
||||
t.position = barrel.position;
|
||||
p.SourceEntity = source.Entity;
|
||||
p.ZoneRenderer = source.ZoneRenderer;
|
||||
p.Range = weapon.Range;
|
||||
p.ImpactIntensity = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5745a5be5f0c02b4b88bd094ea609c13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Lightning : MonoBehaviour
|
||||
{
|
||||
public LightningCompute LightningCompute;
|
||||
public float HitRadius;
|
||||
|
||||
public float ImpactIntensity { get; set; } = 1;
|
||||
public EntityInstance Source { get; set; }
|
||||
public float Range { get; set; }
|
||||
public EntityInstance Target { get; set; }
|
||||
public Transform Barrel { get; set; }
|
||||
|
||||
private bool _colliderHit;
|
||||
private Vector3 _colliderLocalPosition;
|
||||
private Transform _colliderTransform;
|
||||
private Vector3 _endpoint;
|
||||
|
||||
public void Fire()
|
||||
{
|
||||
_colliderHit = false;
|
||||
LightningCompute.OnLeaderComplete = null;
|
||||
LightningCompute.FixedEndpoint = false;
|
||||
_endpoint = Barrel.position + Barrel.forward * Range;
|
||||
if (AetheriaYmirPhysicsBridge.Instance.TryCastZoneHulls(
|
||||
Source?.ZoneRenderer,
|
||||
Source?.Entity,
|
||||
Barrel.position,
|
||||
Barrel.forward,
|
||||
Range,
|
||||
HitRadius,
|
||||
out var hits))
|
||||
{
|
||||
foreach (var hit in hits)
|
||||
{
|
||||
var hull = hit.Hull;
|
||||
var entity = hull.Entity;
|
||||
if (entity.Shield != null && entity.Shield.Item.Active.Value)
|
||||
{
|
||||
LightningCompute.OnLeaderComplete = () =>
|
||||
{
|
||||
hit.Shield?.ShowHit(hit.Point, Mathf.Max(0.01f, ImpactIntensity));
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
LightningCompute.OnLeaderComplete = null;
|
||||
}
|
||||
|
||||
_colliderHit = true;
|
||||
_colliderLocalPosition = hull.transform.InverseTransformPoint(hit.Point);
|
||||
_colliderTransform = hull.transform;
|
||||
LightningCompute.FixedEndpoint = true;
|
||||
_endpoint = hit.Point;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LightningCompute.OnPulseComplete = () =>
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
LightningCompute.StartAnimation();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Barrel == null) return;
|
||||
|
||||
if (_colliderHit)
|
||||
{
|
||||
if (_colliderTransform) _endpoint = _colliderTransform.TransformPoint(_colliderLocalPosition);
|
||||
}
|
||||
|
||||
LightningCompute.EndPosition = _endpoint;
|
||||
LightningCompute.StartPosition = Barrel.position;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5c75d76a7b418d3479761187b2d420bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 54
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LightningGunManager : InstantWeaponEffectManager
|
||||
{
|
||||
public Prototype Prototype;
|
||||
|
||||
public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = Prototype.Instantiate<Lightning>();
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
p.Barrel = barrel;
|
||||
p.Source = source;
|
||||
p.Range = weapon.Range;
|
||||
p.ImpactIntensity = 1;
|
||||
p.Target = target;
|
||||
p.Fire();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9aff863873a6a6d41a619e63a0898c3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue