Skip to content

Commit

Permalink
Merge pull request #2944 from CombatExtended-Continued/VirtualizeProj…
Browse files Browse the repository at this point in the history
…ectileMovement

virtualized something for fiddling with projectile movement
  • Loading branch information
N7Huntsman authored Jan 13, 2024
2 parents 9abd25f + 0f33630 commit 4e37bb9
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public virtual float DamageAmount

#endregion

private float suppressionAmount;
protected float suppressionAmount;
public Thing mount; // GiddyUp compatibility, ignore collisions with pawns the launcher is mounting
public float AccuracyFactor;

#region Height
private int lastHeightTick = -1;
private float heightInt = 0f;
protected int lastHeightTick = -1;
protected float heightInt = 0f;
/// <summary>
/// If lastHeightTick is not FlightTicks, Height calculates the quadratic formula (g/2)t^2 + (-v_0y)t + (y-y0) for {g -> gravity, v_0y -> shotSpeed * Mathf.Sin(shotAngle), y0 -> shotHeight, t -> seconds} to find y rounded to the nearest 3 decimals.
///
Expand Down Expand Up @@ -227,7 +227,7 @@ public float fTicks
#endregion

#region Position
private Vector2 Vec2Position(float ticks = -1f)
protected virtual Vector2 Vec2Position(float ticks = -1f)
{
if (ticks < 0)
{
Expand Down Expand Up @@ -258,7 +258,7 @@ public virtual Vector3 ExactPosition
}
}

public Vector2 DrawPosV2
public virtual Vector2 DrawPosV2
{
get
{
Expand All @@ -278,7 +278,7 @@ public override Vector3 DrawPos
private Vector3 lastExactPos = new Vector3(-1000, 0, 0);
public Vector3 LastPos
{
private set
protected set
{
lastExactPos = value;
}
Expand Down Expand Up @@ -397,8 +397,8 @@ private float GravityFactor



private Material[] shadowMaterial;
private Material ShadowMaterial
protected Material[] shadowMaterial;
protected Material ShadowMaterial
{
get
{
Expand Down Expand Up @@ -584,7 +584,7 @@ public virtual void RayCast(Thing launcher, VerbProperties verbProps, Vector2 or
}
}

private void RayCastSuppression(IntVec3 muzzle, IntVec3 destination, Map map = null)
protected void RayCastSuppression(IntVec3 muzzle, IntVec3 destination, Map map = null)
{
if (muzzle == destination)
{
Expand Down Expand Up @@ -668,7 +668,7 @@ public virtual void InterceptProjectile(object interceptor, Vector3 shieldPositi
InterceptProjectile(interceptor, BlockerRegistry.GetExactPosition(OriginIV3.ToVector3(), ExactPosition, shieldPosition, shieldRadius * shieldRadius));
}

private bool CheckIntercept(Thing interceptorThing, CompProjectileInterceptor interceptorComp, bool withDebug = false)
protected bool CheckIntercept(Thing interceptorThing, CompProjectileInterceptor interceptorComp, bool withDebug = false)
{
Vector3 shieldPosition = interceptorThing.Position.ToVector3ShiftedWithAltitude(0.5f);
float radius = interceptorComp.Props.radius;
Expand Down Expand Up @@ -762,7 +762,7 @@ private bool CheckIntercept(Thing interceptorThing, CompProjectileInterceptor in
}

//Removed minimum collision distance
private bool CheckForCollisionBetween()
protected bool CheckForCollisionBetween()
{
bool collided = false;
Map localMap = this.Map; // Saving the map in case CheckCellForCollision->...->Impact destroys the projectile, thus setting this.Map to null
Expand Down Expand Up @@ -837,7 +837,7 @@ private bool CheckForCollisionBetween()
/// </summary>
/// <param name="cell">Where to check for collisions in</param>
/// <returns>True if collision occured, false otherwise</returns>
private bool CheckCellForCollision(IntVec3 cell)
protected bool CheckCellForCollision(IntVec3 cell)
{
if (BlockerRegistry.CheckCellForCollisionCallback(this, cell, launcher))
{
Expand Down Expand Up @@ -937,7 +937,7 @@ private bool CheckCellForCollision(IntVec3 cell)
return false;
}

private bool TryCollideWithRoof(IntVec3 cell)
protected bool TryCollideWithRoof(IntVec3 cell)
{
if (!cell.Roofed(Map))
{
Expand Down Expand Up @@ -968,7 +968,7 @@ private bool TryCollideWithRoof(IntVec3 cell)
Impact(null);
return true;
}
private bool CanCollideWith(Thing thing, out float dist)
protected bool CanCollideWith(Thing thing, out float dist)
{
dist = -1f;
if (globalTargetInfo.IsValid)
Expand Down Expand Up @@ -996,7 +996,7 @@ private bool CanCollideWith(Thing thing, out float dist)
/// </summary>
/// <param name="thing">What to impact</param>
/// <returns>True if impact occured, false otherwise</returns>
private bool TryCollideWith(Thing thing)
protected bool TryCollideWith(Thing thing)
{

if (!CanCollideWith(thing, out var dist))
Expand Down Expand Up @@ -1469,7 +1469,7 @@ public virtual void Impact(Thing hitThing)
/// </summary>
/// <param name="ticks">Integer ticks, since the only time value which is not an integer (accessed by StartingTicksToImpact) has height zero by definition.</param>
/// <returns>Projectile height at time ticks in ticks.</returns>
private float GetHeightAtTicks(int ticks)
protected virtual float GetHeightAtTicks(int ticks)
{
var seconds = ((float)ticks) / GenTicks.TicksPerRealSecond;
return (float)Math.Round(shotHeight + shotSpeed * Mathf.Sin(shotAngle) * seconds - (GravityFactor * seconds * seconds) / 2f, 3);
Expand All @@ -1482,7 +1482,7 @@ private float GetHeightAtTicks(int ticks)
/// <param name="angle">Shot angle in radians off the ground.</param>
/// <param name="shotHeight">Height from which the projectile is fired in vertical cells.</param>
/// <returns>Time in seconds that the projectile will take to traverse the given arc.</returns>
private float GetFlightTime()
protected float GetFlightTime()
{
//Calculates quadratic formula (g/2)t^2 + (-v_0y)t + (y-y0) for {g -> gravity, v_0y -> vSin, y -> 0, y0 -> shotHeight} to find t in fractional ticks where height equals zero.
return (Mathf.Sin(shotAngle) * shotSpeed + Mathf.Sqrt(Mathf.Pow(Mathf.Sin(shotAngle) * shotSpeed, 2f) + 2f * GravityFactor * shotHeight)) / GravityFactor;
Expand Down Expand Up @@ -1519,7 +1519,7 @@ public static float GetShotAngle(float velocity, float range, float heightDiffer
}
#endregion

private static Material[] GetShadowMaterial(Graphic_Collection g)
protected static Material[] GetShadowMaterial(Graphic_Collection g)
{
var collection = g.subGraphics;
var shadows = collection.Select(item => item.GetColoredVersion(ShaderDatabase.Transparent, Color.black, Color.black).MatSingle).ToArray();
Expand Down

0 comments on commit 4e37bb9

Please sign in to comment.