Entity Destruction

Added multiple turret enemies
Added ability to destroy enemies
Fixed bug where player could target themselves
Fixed bug where targeting new enemy freezes schematic hit animation
Fixed bug where target lock progress could persist when targeting new enemy
This commit is contained in:
Reinier Vens 2021-01-12 00:54:29 +00:00
commit e3de7158fd
13 changed files with 1937 additions and 1124 deletions

View file

@ -462,6 +462,11 @@ public class SectorRenderer : MonoBehaviour
void UnloadEntity(Entity entity)
{
if (EntityInstances[entity].Prefab.DestroyEffect != null)
{
var t = Instantiate(EntityInstances[entity].Prefab.DestroyEffect).transform;
t.position = EntityInstances[entity].Prefab.transform.position;
}
Destroy(EntityInstances[entity].Transform.gameObject);
EntityInstances.Remove(entity);
}
@ -622,8 +627,14 @@ public class SectorRenderer : MonoBehaviour
else planet.Value.Body.transform.rotation *= Quaternion.AngleAxis(Settings.PlanetRotationSpeed, Vector3.up);
}
var hitList = new List<Entity>();
foreach (var entity in EntityInstances)
{
if(entity.Key.Hull.Durability <= 0)
{
hitList.Add(entity.Key);
continue;
}
if(entity.Value is ShipInstance shipInstance)
{
for (int i = 0; i < shipInstance.Thrusters.Length; i++)
@ -648,6 +659,11 @@ public class SectorRenderer : MonoBehaviour
? (EntityInstances[entity.Key.Target.Value].Transform.position - entity.Value.Transform.position).magnitude : 10000);
entity.Value.Transform.position = entity.Key.Position;
}
foreach(var e in hitList)
{
_zone.Entities.Remove(e);
}
var fogPos = FogCameraParent.position;
SectorBoundaryBrush.material.SetFloat("_Power", Settings.PlanetSettings.ZoneDepthExponent);