Skip to content

Commit

Permalink
Missiles aren't registering hits properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-steas committed Mar 20, 2024
1 parent 1f2fef2 commit e33d309
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,33 @@ public static void AddLine(Vector3D origin, Vector3D destination, Color color, f

public override void Draw()
{
foreach (var key in QueuedPoints.Keys.ToList())
try
{
DrawPoint0(key, QueuedPoints[key].Item2);
foreach (var key in QueuedPoints.Keys.ToList())
{
DrawPoint0(key, QueuedPoints[key].Item2);

if (DateTime.UtcNow.Ticks > QueuedPoints[key].Item1)
QueuedPoints.Remove(key);
}
if (DateTime.UtcNow.Ticks > QueuedPoints[key].Item1)
QueuedPoints.Remove(key);
}

foreach (var key in QueuedGridPoints.Keys.ToList())
{
DrawGridPoint0(key, QueuedGridPoints[key].Item3, QueuedGridPoints[key].Item2);
foreach (var key in QueuedGridPoints.Keys.ToList())
{
DrawGridPoint0(key, QueuedGridPoints[key].Item3, QueuedGridPoints[key].Item2);

if (DateTime.UtcNow.Ticks > QueuedGridPoints[key].Item1)
QueuedGridPoints.Remove(key);
}
if (DateTime.UtcNow.Ticks > QueuedGridPoints[key].Item1)
QueuedGridPoints.Remove(key);
}

foreach (var key in QueuedLinePoints.Keys.ToList())
{
DrawLine0(key.Item1, key.Item2, QueuedLinePoints[key].Item2);
foreach (var key in QueuedLinePoints.Keys.ToList())
{
DrawLine0(key.Item1, key.Item2, QueuedLinePoints[key].Item2);

if (DateTime.UtcNow.Ticks > QueuedLinePoints[key].Item1)
QueuedLinePoints.Remove(key);
if (DateTime.UtcNow.Ticks > QueuedLinePoints[key].Item1)
QueuedLinePoints.Remove(key);
}
}
catch { } // Icky no error logging
}

private void DrawPoint0(Vector3D globalPos, Color color)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class HeartData
public ulong SteamId = 0;
public List<IMyPlayer> Players = new List<IMyPlayer>();
public bool DegradedMode = false;
public int DegradedModeTicks = 30;
public int DegradedModeTicks = 20;
public Action<IMyCubeGrid> OnGridAdd = (a) => { };
public Action<IMyCubeGrid> OnGridRemove = (a) => { };
public GuiBlockCategoryHelper OrreryBlockCategory = new GuiBlockCategoryHelper("[Orrery Combat Framework]", "OrreryBlockCategory");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Heart_Module.Data.Scripts.HeartModule.ExceptionHandler;
using Heart_Module.Data.Scripts.HeartModule.Debug;
using Heart_Module.Data.Scripts.HeartModule.ExceptionHandler;
using ParallelTasks;
using Sandbox.Game.Entities;
using Sandbox.ModAPI;
Expand Down Expand Up @@ -44,6 +45,9 @@ public void Update()

MyAPIGateway.Utilities.ShowNotification("PPT Sim: " + Math.Round(1/60d/DeltaTick, 2), 1000/60);

foreach (var p in ProjectileManager.I.ActiveProjectiles.Values)
DebugDraw.AddLine(p.Position, p.NextMoveStep, VRageMath.Color.Red, 0);

if (thisTask.IsComplete)
{
// Update thread-safe buffer lists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Heart_Module.Data.Scripts.HeartModule.ErrorHandler;
using Heart_Module.Data.Scripts.HeartModule.Debug;
using Heart_Module.Data.Scripts.HeartModule.ErrorHandler;
using Heart_Module.Data.Scripts.HeartModule.Projectiles.GuidanceHelpers;
using Heart_Module.Data.Scripts.HeartModule.Projectiles.StandardClasses;
using Sandbox.Game.Entities;
Expand Down Expand Up @@ -309,19 +310,21 @@ private void PerformRaycastRecursive(double length)
if (entities.Count == 0)
return;

MyAPIGateway.Physics.CastRayParallel(ref Position, ref NextMoveStep, DefaultCollisionLayer, (hitInfo) =>
MyAPIGateway.Physics.CastRayParallel(ref Position, ref NextMoveStep, 0, (hitInfo) =>
{
if (RemainingImpacts <= 0 || hitInfo.HitEntity.EntityId == Firer)
return;

DebugDraw.AddLine(hitInfo.Position, hitInfo.Position - hitInfo.Normal, VRageMath.Color.Blue, 2);

MaxBeamLength = (float) (hitInfo.Fraction * length);

if (MyAPIGateway.Session.IsServer)
{
if (hitInfo.HitEntity is IMyCubeGrid)
DamageHandler.QueueEvent(new DamageEvent(hitInfo.HitEntity, DamageEvent.DamageEntType.Grid, this, hitInfo.Position, hitInfo.Normal, hitInfo.Position, hitInfo.Position - hitInfo.Normal));
DamageHandler.QueueEvent(new DamageEvent(hitInfo.HitEntity, DamageEvent.DamageEntType.Grid, this, hitInfo.Position, hitInfo.Normal, hitInfo.Position + hitInfo.Normal, hitInfo.Position - hitInfo.Normal));
else if (hitInfo.HitEntity is IMyCharacter)
DamageHandler.QueueEvent(new DamageEvent(hitInfo.HitEntity, DamageEvent.DamageEntType.Character, this, hitInfo.Position, hitInfo.Normal, hitInfo.Position, hitInfo.Position - hitInfo.Normal));
DamageHandler.QueueEvent(new DamageEvent(hitInfo.HitEntity, DamageEvent.DamageEntType.Character, this, hitInfo.Position, hitInfo.Normal, hitInfo.Position + hitInfo.Normal, hitInfo.Position - hitInfo.Normal));
}

if (MyAPIGateway.Session.IsServer)
Expand Down

0 comments on commit e33d309

Please sign in to comment.