From 9cde9314734a873461cdcb78f854b1f8943ce13e Mon Sep 17 00:00:00 2001 From: SnpM Date: Mon, 15 Aug 2016 22:54:38 -0600 Subject: [PATCH 1/2] Refactor; Add ReferenceIndex (use TBD); --- Core/Game/Agents/LSAgent.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Game/Agents/LSAgent.cs b/Core/Game/Agents/LSAgent.cs index 1504e3ed..f02c1316 100755 --- a/Core/Game/Agents/LSAgent.cs +++ b/Core/Game/Agents/LSAgent.cs @@ -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 Interfacers { get { return abilityManager.Interfacers; } } From ac8f98fe97b8ff1c79f9fa87dcc5ba45cd26ad4b Mon Sep 17 00:00:00 2001 From: SnpM Date: Tue, 16 Aug 2016 20:00:23 -0600 Subject: [PATCH 2/2] Fix movement not collision stopping; Refactor and clean --- Core/Game/Abilities/Essential/Move.cs | 18 ++++++++---------- Core/Game/Grouping/MovementGroup.cs | 6 +++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Core/Game/Abilities/Essential/Move.cs b/Core/Game/Abilities/Essential/Move.cs index 90a9d1a0..8e3ca2dd 100755 --- a/Core/Game/Abilities/Essential/Move.cs +++ b/Core/Game/Abilities/Essential/Move.cs @@ -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() : @@ -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; } @@ -99,7 +99,6 @@ public long timescaledSpeed } } - private long collisionStopTreshold; private long timescaledAcceleration; [Lockstep (true)] @@ -159,8 +158,7 @@ protected override void OnSetup() cachedBody.OnContact += HandleCollision; CachedTurn = Agent.GetAbility(); CanTurn = _canTurn && CachedTurn != null; - collisionStopTreshold = FixedMath.Mul(timescaledSpeed, CollisionStopTreshold); - collisionStopTreshold *= collisionStopTreshold; + timescaledAcceleration = Acceleration * 32 / LockstepManager.FrameRate; if (timescaledAcceleration > FixedMath.One) timescaledAcceleration = FixedMath.One; @@ -181,7 +179,7 @@ protected override void OnInitialize() MyMovementGroupID = -1; CanCollisionStop = true; TempCanCollisionStop = true; - CollisionStopMultiplier = DirectStop; + StopMultiplier = DirectStop; repathCount = RepathRate; viableDestination = false; @@ -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; @@ -369,7 +367,7 @@ protected override void OnSimulate() cachedBody.VelocityChanged = true; - TempCanCollisionStop = false; + TempCanCollisionStop = true; } else { if (cachedBody.VelocityFastMagnitude > 0) @@ -524,7 +522,7 @@ private void HandleCollision(LSBody other) Move otherMover = tempAgent.GetAbility(); if (ReferenceEquals(otherMover, null) == false) { - if (IsMoving && GetFullCanCollisionStop()) + if (IsMoving && (GetFullCanCollisionStop())) { if (otherMover.MyMovementGroupID == MyMovementGroupID) { @@ -532,7 +530,7 @@ private void HandleCollision(LSBody other) { if (otherMover.CanCollisionStop == false) { - TempCanCollisionStop = true; + TempCanCollisionStop = false; } else { Arrive(); diff --git a/Core/Game/Grouping/MovementGroup.cs b/Core/Game/Grouping/MovementGroup.cs index cf71ba19..32123435 100755 --- a/Core/Game/Grouping/MovementGroup.cs +++ b/Core/Game/Grouping/MovementGroup.cs @@ -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); } } @@ -149,7 +149,7 @@ void ExecuteIndividualMove () { { Move mover = movers [i]; mover.IsFormationMoving = false; - mover.CollisionStopMultiplier = Move.DirectStop; + mover.StopMultiplier = Move.DirectStop; mover.OnGroupProcessed(Destination); } } @@ -160,7 +160,7 @@ void ExecuteGroupIndividualMove() { Move mover = movers [i]; mover.IsFormationMoving = false; - mover.CollisionStopMultiplier = Move.GroupDirectStop; + mover.StopMultiplier = Move.GroupDirectStop; mover.OnGroupProcessed(Destination); } }