Wormholes Fixed
Fixed issues when jumping to another zone: All bodies from the old zone are correctly destroyed Ship controls & UI transfer smoothly to new ship instance Animation issues are sorted
This commit is contained in:
parent
adfb200a91
commit
273095afec
8 changed files with 66 additions and 38 deletions
|
|
@ -98,7 +98,16 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
Zone = new Zone(Settings.PlanetSettings, zonePack);
|
||||
Zone.Log = s => Debug.Log($"Zone: {s}");
|
||||
|
||||
if (CurrentShip != null)
|
||||
{
|
||||
Zone.Entities.Add(CurrentShip);
|
||||
}
|
||||
|
||||
SectorRenderer.LoadZone(Zone);
|
||||
|
||||
if (CurrentShip != null)
|
||||
BindToEntity();
|
||||
}
|
||||
|
||||
void Start()
|
||||
|
|
@ -204,6 +213,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
GenerateLevel();
|
||||
CurrentShip.ExitWormhole(SectorRenderer.WormholeInstances.Keys.First().Position,
|
||||
Settings.GameplaySettings.WormholeExitVelocity * ItemManager.Random.NextFloat2Direction());
|
||||
CurrentShip.Zone = Zone;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -215,6 +225,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
AkSoundEngine.PostEvent(CurrentShip.HeatsinksEnabled ? "UI_Success" : "UI_Fail", gameObject);
|
||||
};
|
||||
|
||||
#region Targeting
|
||||
|
||||
_input.Player.TargetReticle.performed += context =>
|
||||
{
|
||||
var underReticle = Zone.Entities.Where(x => x != CurrentShip)
|
||||
|
|
@ -241,6 +253,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
var currentTargetIndex = Array.IndexOf(targets, CurrentShip.Target.Value);
|
||||
CurrentShip.Target.Value = targets[(currentTargetIndex + targets.Length - 1) % targets.Length];
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Trigger Groups
|
||||
|
||||
|
|
@ -505,32 +520,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
else if (CurrentShip.Parent.TryUndock(CurrentShip))
|
||||
{
|
||||
SectorRenderer.PerspectiveEntity = CurrentShip;
|
||||
Menu.gameObject.SetActive(false);
|
||||
DockedEntity = null;
|
||||
DockingBay = null;
|
||||
//_shipInput = new ShipInput(_input.Player, _currentShip);
|
||||
DockCamera.enabled = false;
|
||||
FollowCamera.enabled = true;
|
||||
FollowCamera.LookAt = SectorRenderer.EntityInstances[CurrentShip].LookAtPoint;
|
||||
FollowCamera.Follow = SectorRenderer.EntityInstances[CurrentShip].transform;
|
||||
_articulationGroups = CurrentShip.Equipment
|
||||
.Where(item => item.Behaviors.Any(x => x.Data is WeaponData && !(x.Data is LauncherData)))
|
||||
.GroupBy(item => SectorRenderer.EntityInstances[CurrentShip]
|
||||
.GetBarrel(CurrentShip.Hardpoints[item.Position.x, item.Position.y])
|
||||
.GetComponentInParent<ArticulationPoint>()?.Group ?? -1)
|
||||
.Select((group, index) => {
|
||||
return (
|
||||
group.Select(item => CurrentShip.Hardpoints[item.Position.x, item.Position.y]).ToArray(),
|
||||
group.Select(item => SectorRenderer.EntityInstances[CurrentShip].GetBarrel(CurrentShip.Hardpoints[item.Position.x, item.Position.y])).ToArray(),
|
||||
Crosshairs[index]
|
||||
);
|
||||
}).ToArray();
|
||||
|
||||
foreach (var crosshair in Crosshairs)
|
||||
crosshair.gameObject.SetActive(false);
|
||||
foreach (var group in _articulationGroups)
|
||||
group.crosshair.gameObject.SetActive(true);
|
||||
|
||||
BindToEntity();
|
||||
|
||||
_lockingIndicators = CurrentShip.GetBehaviors<LockWeapon>()
|
||||
.Select(x =>
|
||||
|
|
@ -571,6 +568,31 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void BindToEntity()
|
||||
{
|
||||
SectorRenderer.PerspectiveEntity = CurrentShip;
|
||||
|
||||
FollowCamera.LookAt = SectorRenderer.EntityInstances[CurrentShip].LookAtPoint;
|
||||
FollowCamera.Follow = SectorRenderer.EntityInstances[CurrentShip].transform;
|
||||
_articulationGroups = CurrentShip.Equipment
|
||||
.Where(item => item.Behaviors.Any(x => x.Data is WeaponData && !(x.Data is LauncherData)))
|
||||
.GroupBy(item => SectorRenderer.EntityInstances[CurrentShip]
|
||||
.GetBarrel(CurrentShip.Hardpoints[item.Position.x, item.Position.y])
|
||||
.GetComponentInParent<ArticulationPoint>()?.Group ?? -1)
|
||||
.Select((group, index) => {
|
||||
return (
|
||||
group.Select(item => CurrentShip.Hardpoints[item.Position.x, item.Position.y]).ToArray(),
|
||||
group.Select(item => SectorRenderer.EntityInstances[CurrentShip].GetBarrel(CurrentShip.Hardpoints[item.Position.x, item.Position.y])).ToArray(),
|
||||
Crosshairs[index]
|
||||
);
|
||||
}).ToArray();
|
||||
|
||||
foreach (var crosshair in Crosshairs)
|
||||
crosshair.gameObject.SetActive(false);
|
||||
foreach (var group in _articulationGroups)
|
||||
group.crosshair.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void SaveZone() => File.WriteAllBytes(
|
||||
Path.Combine(_filePath.FullName, $"{Zone.Data.Name}.zone"), MessagePackSerializer.Serialize(Zone.Pack()));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue