Skip to content

Commit

Permalink
you put da line in da coconut
Browse files Browse the repository at this point in the history
yes I meant line instead of lime
  • Loading branch information
ari-steas committed Jan 7, 2024
1 parent 4d51f84 commit e6ff92c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
1 change: 1 addition & 0 deletions Heart Module/Data/Scripts/HeartModule/HeartData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal class HeartData
public const ushort HeartNetworkId = (ushort)(65198749845 % ushort.MaxValue);

public bool IsSuspended = false;
public bool IsPaused = false;
public HeartNetwork Net = new HeartNetwork();
public HeartLog Log = new HeartLog();
public int SyncRange = MyAPIGateway.Session.SessionSettings.SyncDistance;
Expand Down
6 changes: 6 additions & 0 deletions Heart Module/Data/Scripts/HeartModule/HeartLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ public override void UpdateAfterSimulation()
{
if (HeartData.I.IsSuspended)
return;
HeartData.I.IsPaused = false;
}
catch (Exception ex)
{
SoftHandle.RaiseException(ex);
}
}

public override void UpdatingStopped()
{
HeartData.I.IsPaused = true;
}

protected override void UnloadData()
{
handle.UnloadData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Heart_Module.Data.Scripts.HeartModule.Projectiles.StandardClasses;
using VRage.Utils;

namespace Heart_Module.Data.Scripts.HeartModule.Projectiles
{
Expand Down Expand Up @@ -26,7 +27,7 @@ internal class ProjectileDefinitionManager
},
PhysicalProjectile = new PhysicalProjectile()
{
Velocity = 100,
Velocity = 1000,
Acceleration = 0,
Health = -1,
MaxTrajectory = 800,
Expand All @@ -35,8 +36,11 @@ internal class ProjectileDefinitionManager
Visual = new Visual()
{
Model = "",
TrailTexture = "",
TrailFadeTime = 0,
TrailTexture = MyStringId.GetOrCompute("WeaponLaser"),
TrailFadeTime = 2,
TrailLength = 1,
TrailWidth = 0.1f,
TrailColor = new VRageMath.Vector4(255, 255, 255, 255),
AttachedParticle = "Smoke_Missile",
ImpactParticle = "Explosion_LargeCaliberShell_Backup",
VisibleChance = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Heart_Module.Data.Scripts.HeartModule.Debug;
using Sandbox.ModAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using VRage;
using VRage.Game;
using VRage.Game.Entity;
using VRageMath;
Expand All @@ -13,6 +17,7 @@ partial class Projectile
MyEntity ProjectileEntity;
MyParticleEffect ProjectileEffect;
uint RenderId = 0;
Dictionary<MyTuple<Vector3D, Vector3D>, long> TrailFade = new Dictionary<MyTuple<Vector3D, Vector3D>, long>();

internal void InitDrawing()
{
Expand All @@ -24,21 +29,36 @@ internal void InitDrawing()
public void DrawUpdate(float delta)
{
Vector3D visualPosition = Position + (InheritedVelocity + Direction * (Velocity + Definition.PhysicalProjectile.Acceleration * delta)) * delta;
MatrixD matrix = MatrixD.CreateWorld(visualPosition, Direction, Vector3D.Cross(Direction, Vector3D.Up));

// Temporary debug draw
//DebugDraw.AddPoint(visualPosition, Color.Green, 0.000001f);

if (Definition.Visual.AttachedParticle != "")
if (Definition.Visual.AttachedParticle != "" && !HeartData.I.IsPaused)
{
MatrixD matrix = MatrixD.CreateWorld(visualPosition, Direction, Vector3D.Cross(Direction, Vector3D.Up));

if (ProjectileEffect == null)
{
MyParticlesManager.TryCreateParticleEffect(Definition.Visual.AttachedParticle, ref matrix, ref visualPosition, RenderId, out ProjectileEffect);
}
else
{
ProjectileEffect.WorldMatrix = matrix;
}
}

if (Definition.Visual.TrailTexture != null && !HeartData.I.IsPaused)
TrailFade.Add(new MyTuple<Vector3D, Vector3D>(visualPosition, visualPosition + Direction * Definition.Visual.TrailLength), DateTime.Now.Ticks + (long)(TimeSpan.TicksPerSecond * Definition.Visual.TrailFadeTime));
UpdateTrailFade();
}

/// <summary>
/// Updates trail fade for this projectile.
/// </summary>
private void UpdateTrailFade()
{
foreach (var positionTuple in TrailFade.Keys.ToList())
{
float percentage = (TrailFade[positionTuple] - DateTime.Now.Ticks) / (Definition.Visual.TrailFadeTime * TimeSpan.TicksPerSecond);
Vector4 fadedColor = Definition.Visual.TrailColor * percentage;
MySimpleObjectDraw.DrawLine(positionTuple.Item1, positionTuple.Item2, Definition.Visual.TrailTexture, ref fadedColor, Definition.Visual.TrailWidth);
if (TrailFade[positionTuple] <= DateTime.Now.Ticks)
TrailFade.Remove(positionTuple);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public override void UpdateAfterSimulation()
}

private void SyncPlayerProjectiles(IMyPlayer player)
{
{ // NOTE - BEAMS SHOULD NOT BE SYNCED ASIDE FROM ON SHOOT.
int numSyncs = 0;

for (int i = 0; i < MaxProjectilesSynced && i < ProjectileSyncStream[player.SteamUserId].Count; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using VRage.Game.Entity;
using VRage.Utils;
using VRageMath;

namespace Heart_Module.Data.Scripts.HeartModule.Projectiles.StandardClasses
{
Expand Down Expand Up @@ -72,7 +74,10 @@ public struct PhysicalProjectile
public struct Visual
{
[ProtoMember(1)] public string Model;
[ProtoMember(2)] public string TrailTexture;
[ProtoMember(2)] public MyStringId TrailTexture;
[ProtoMember(7)] public float TrailLength;
[ProtoMember(9)] public float TrailWidth;
[ProtoMember(8)] public Vector4 TrailColor;
[ProtoMember(3)] public float TrailFadeTime;
[ProtoMember(4)] public string AttachedParticle;
[ProtoMember(5)] public string ImpactParticle;
Expand Down

0 comments on commit e6ff92c

Please sign in to comment.