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
18 changes: 8 additions & 10 deletions Core/Game/Abilities/Essential/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class Move : ActiveAbility
private const int MinimumOtherStopTime = (int)(LockstepManager.FrameRate / 4);
private const int repathRate = (int)LockstepManager.FrameRate;
private const int CollisionStopCount = LockstepManager.FrameRate * 2;
private const long CollisionStopTreshold = FixedMath.One / 2;

public int GridSize {get {return cachedBody.Radius <= FixedMath.One ?
(cachedBody.Radius * 2).CeilToInt() :
Expand Down Expand Up @@ -55,13 +54,14 @@ private int StraightRepathRate

public bool GetFullCanCollisionStop()
{

return CanCollisionStop && TempCanCollisionStop;
}
public bool CanCollisionStop { get; set; }

public bool TempCanCollisionStop { get; set;}

public long CollisionStopMultiplier { get; set; }
public long StopMultiplier { get; set; }

private bool forcePathfind { get; set; }

Expand Down Expand Up @@ -99,7 +99,6 @@ public long timescaledSpeed
}
}

private long collisionStopTreshold;
private long timescaledAcceleration;

[Lockstep (true)]
Expand Down Expand Up @@ -159,8 +158,7 @@ protected override void OnSetup()
cachedBody.OnContact += HandleCollision;
CachedTurn = Agent.GetAbility<Turn>();
CanTurn = _canTurn && CachedTurn != null;
collisionStopTreshold = FixedMath.Mul(timescaledSpeed, CollisionStopTreshold);
collisionStopTreshold *= collisionStopTreshold;

timescaledAcceleration = Acceleration * 32 / LockstepManager.FrameRate;
if (timescaledAcceleration > FixedMath.One)
timescaledAcceleration = FixedMath.One;
Expand All @@ -181,7 +179,7 @@ protected override void OnInitialize()
MyMovementGroupID = -1;
CanCollisionStop = true;
TempCanCollisionStop = true;
CollisionStopMultiplier = DirectStop;
StopMultiplier = DirectStop;

repathCount = RepathRate;
viableDestination = false;
Expand Down Expand Up @@ -343,7 +341,7 @@ protected override void OnSimulate()
} else
{
StopTimer = 0;
if (distance < FixedMath.Mul(closingDistance, CollisionStopMultiplier))
if (distance < FixedMath.Mul(closingDistance, StopMultiplier))
{
Arrive();
return;
Expand All @@ -369,7 +367,7 @@ protected override void OnSimulate()

cachedBody.VelocityChanged = true;

TempCanCollisionStop = false;
TempCanCollisionStop = true;
} else
{
if (cachedBody.VelocityFastMagnitude > 0)
Expand Down Expand Up @@ -524,15 +522,15 @@ private void HandleCollision(LSBody other)
Move otherMover = tempAgent.GetAbility<Move>();
if (ReferenceEquals(otherMover, null) == false)
{
if (IsMoving && GetFullCanCollisionStop())
if (IsMoving && (GetFullCanCollisionStop()))
{
if (otherMover.MyMovementGroupID == MyMovementGroupID)
{
if (otherMover.IsMoving == false && otherMover.Arrived && otherMover.stopTime > MinimumOtherStopTime)
{
if (otherMover.CanCollisionStop == false)
{
TempCanCollisionStop = true;
TempCanCollisionStop = false;
}
else {
Arrive();
Expand Down
4 changes: 3 additions & 1 deletion Core/Game/Agents/LSAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public LSBusStop BusStop
public bool Selectable { get { return _selectable; } }
public bool CanSelect { get { return Selectable && IsVisible; } }

public ushort TypeIndex;
public ushort TypeIndex { get; set;}

public int ReferenceIndex { get; set;}

public Vector2 Position2 { get { return new Vector2(CachedTransform.position.x, CachedTransform.position.z); } }
public FastList<AbilityDataItem> Interfacers { get { return abilityManager.Interfacers; } }
Expand Down
6 changes: 3 additions & 3 deletions Core/Game/Grouping/MovementGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void ExecuteGroupMove () {
{
Move mover = movers [i];
mover.IsFormationMoving = true;
mover.CollisionStopMultiplier = Move.FormationStop;
mover.StopMultiplier = Move.FormationStop;
mover.OnGroupProcessed(mover.Position + groupDirection);
}
}
Expand All @@ -149,7 +149,7 @@ void ExecuteIndividualMove () {
{
Move mover = movers [i];
mover.IsFormationMoving = false;
mover.CollisionStopMultiplier = Move.DirectStop;
mover.StopMultiplier = Move.DirectStop;
mover.OnGroupProcessed(Destination);
}
}
Expand All @@ -160,7 +160,7 @@ void ExecuteGroupIndividualMove()
{
Move mover = movers [i];
mover.IsFormationMoving = false;
mover.CollisionStopMultiplier = Move.GroupDirectStop;
mover.StopMultiplier = Move.GroupDirectStop;
mover.OnGroupProcessed(Destination);
}
}
Expand Down