Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Game/Abilities/Essential/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void StartLookingForStopPause () {
public Vector2d AveragePosition { get; set; }

private long timescaledAcceleration;
public long timescaledDecceleration;
private long timescaledDecceleration;
bool decellerating;

private Vector2d lastTargetPos;
Expand Down
3 changes: 2 additions & 1 deletion Core/Game/Abilities/Essential/Scan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public virtual Vector3d[] ProjectileOffsets {
protected bool _trackAttackAngle = true;
[FixedNumberAngle, SerializeField]
protected long _attackAngle = FixedMath.TenDegrees;
[SerializeField]
[SerializeField, Tooltip ("Important: With Vector3d, the Z axis represents height!")]
protected Vector3d _projectileOffset;
[SerializeField]
protected Vector3d[] _secondaryProjectileOffsets;
Expand Down Expand Up @@ -516,6 +516,7 @@ public void Engage (LSAgent other)
fastRangeToTarget *= fastRangeToTarget;

if (!CheckRange ()) {
if (CanMove)
cachedMove.StartMove (Target.Body.Position);
}
}
Expand Down
31 changes: 22 additions & 9 deletions Core/Game/Abilities/Essential/Turn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protected override void OnSetup ()

turnSin = _turnRate.y;
turnCos = _turnRate.x;
collisionTurnThreshold = Agent.Body.Radius / LockstepManager.FrameRate;

collisionTurnThreshold = Agent.Body.Radius / (LockstepManager.FrameRate / 2);
collisionTurnThreshold *= collisionTurnThreshold;
Agent.Body.onContact += HandleContact;
}
Expand All @@ -41,10 +42,23 @@ protected override void OnInitialize ()
bufferStartTurn = false;
}

bool isColliding;
void CheckAutoturn () {
if (isColliding) {
isColliding = false;
//autoturn direction will be culmination of positional changes
if (targetReached == true && Agent.IsCasting == false && !(Agent.Body.Immovable || Agent.Body.IsTrigger)) {
Vector2d delta = this.Agent.Body._position - this.Agent.Body.LastPosition;
if (delta.FastMagnitude () > collisionTurnThreshold) {
delta.Normalize ();
this.StartTurnDirection (delta);
}
}
}
}
protected override void OnSimulate ()
{


if (targetReached == false) {
if (cachedBeginCheck != 0) {
{
Expand All @@ -66,13 +80,17 @@ protected override void OnSimulate ()
}
}


protected override void OnLateSimulate ()
{
if (targetReached == false) {
long check = Agent.Body._rotation.Cross (targetRotation.x, targetRotation.y);
if (check == 0 || ((cachedBeginCheck < 0) != (check < 0))) {
Arrive ();
}
} else {
CheckAutoturn ();

}
if (bufferStartTurn) {
bufferStartTurn = false;
Expand Down Expand Up @@ -136,13 +154,8 @@ protected override void OnStopCast ()

private void HandleContact (LSBody other)
{
if (targetReached == true && Agent.IsCasting == false && !(Agent.Body.Immovable || Agent.Body.IsTrigger)) {
Vector2d delta = this.Agent.Body._position - this.Agent.Body.LastPosition;
if (delta.FastMagnitude () > collisionTurnThreshold) {
delta.Normalize ();
this.StartTurnDirection (delta);
}
}
isColliding = true;

}
}
}
5 changes: 3 additions & 2 deletions Core/Game/Agents/LSAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void SetState(AnimState animState)
Animator.CurrentAnimState = animState;
}
}

public void ApplyImpulse(AnimImpulse animImpulse, int rate = 0)
{
if (Animator.IsNotNull())
Expand Down Expand Up @@ -557,7 +557,8 @@ private void LoadComponents()
{
_cachedTransform = base.transform;
_cachedGameObject = base.gameObject;
_unityBody = GetComponent<UnityLSBody>();
//TODO: Ensure that this isn't GhostLSBody or any other bodies attached to the GO
_unityBody = GetComponent<UnityLSBody> ();
_animator = GetComponent<LSAnimatorBase>();
_attachedAbilities = GetComponents<Ability>();
}
Expand Down
9 changes: 9 additions & 0 deletions Core/Game/Player/Visuals/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Core/Simulation/Grid/Core/GridNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,14 @@ public void CalculateHeuristic ()

public void Add (LSInfluencer influencer)
{
if (LinkedScanNode != null)
LinkedScanNode.Add (influencer);
}

public void Remove (LSInfluencer influencer)
{
if (LinkedScanNode != null)

LinkedScanNode.Remove (influencer);
}

Expand Down
26 changes: 26 additions & 0 deletions Core/Simulation/Math/Vector2d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,33 @@ public bool NotZero()
{
return x.MoreThanEpsilon() || y.MoreThanEpsilon();
}
public void ClampMagnitude (long min, long max) {
long mag = this.FastMagnitude ();
long fastMin;
long fastMax;
long normal;
//Check if normalization is needed and if so, set scale to normalize to
if (mag < (fastMin = min * min)) {
normal = fastMin;
} else if (mag > (fastMax = max * max)) {
normal = fastMax;
} else {
return;
}

mag = FixedMath.Sqrt (mag >> FixedMath.SHIFT_AMOUNT);

if (mag.MoreThanEpsilon ()) {
//convert from fast multiplied value
normal = FixedMath.Sqrt(normal >> FixedMath.SHIFT_AMOUNT);
//Shift unneeded as fixed fraction canceled through mul then div
x = x * normal / mag;
y = y * normal / mag;
} else {
x = 0;
y = 0;
}
}
#endregion

#region Static Math
Expand Down
49 changes: 49 additions & 0 deletions Core/Simulation/Math/Vector3d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,54 @@ public void Read (Reader reader) {
y = reader.ReadLong();
z = reader.ReadLong();
}

#region Operators

public static Vector3d operator +(Vector3d v1, Vector3d v2)
{
return new Vector3d(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}

public static Vector3d operator -(Vector3d v1, Vector3d v2)
{
return new Vector3d(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}

public static Vector3d operator *(Vector3d v1, long mag)
{
return new Vector3d((v1.x * mag) >> FixedMath.SHIFT_AMOUNT, (v1.y * mag) >> FixedMath.SHIFT_AMOUNT, (v1.z * mag) >> FixedMath.SHIFT_AMOUNT);
}

public static Vector3d operator *(Vector3d v1, int mag)
{
return new Vector3d((v1.x * mag), (v1.y * mag), (v1.z * mag));
}

public static Vector3d operator /(Vector3d v1, long div)
{
return new Vector3d(((v1.x << FixedMath.SHIFT_AMOUNT) / div), (v1.y << FixedMath.SHIFT_AMOUNT) / div, (v1.z << FixedMath.SHIFT_AMOUNT) / div);
}

public static Vector3d operator /(Vector3d v1, int div)
{
return new Vector3d((v1.x / div), v1.y / div, v1.z / div);
}

public static Vector3d operator >>(Vector3d v1, int shift)
{
return new Vector3d(v1.x >> shift, v1.y >> shift, v1.z >> shift);
}

public static bool operator ==(Vector3d v1, Vector3d v2)
{
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
}

public static bool operator !=(Vector3d v1, Vector3d v2)
{
return v1.x != v2.x || v1.y != v2.y || v1.z != v2.z;
}

#endregion
}
}
Loading