Skip to content

Commit

Permalink
plunger: Adapt movement position, which is now relative to the plunge…
Browse files Browse the repository at this point in the history
…r's position.
  • Loading branch information
freezy committed Jan 30, 2025
1 parent ab4de53 commit 91c886d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public int Id
public LineZCollider JointEnd0;
public LineZCollider JointEnd1;

public float PosY;

public ColliderBounds Bounds { get; private set; }

public PlungerCollider(PlungerComponent comp, PlungerColliderComponent collComp, ColliderInfo info) : this()
Expand Down Expand Up @@ -84,6 +86,7 @@ public PlungerCollider(PlungerComponent comp, PlungerColliderComponent collComp,
JointEnd0 = new LineZCollider(new float2(x, position), zHeight, zHeight + Plunger.PlungerHeight, info);
JointEnd1 = new LineZCollider(new float2(x2, position), zHeight, zHeight + Plunger.PlungerHeight, info);

PosY = 0;
Bounds = new ColliderBounds(Header.ItemId, Header.Id, new Aabb(
new float3(-comp.Width - 10, comp.Height, 0),
new float3(comp.Width + 10, -100, 50)
Expand Down Expand Up @@ -132,6 +135,8 @@ private void Transform(PlungerCollider collider, float4x4 matrix)
LineSegEnd = collider.LineSegEnd.Transform(matrix);
JointEnd0 = collider.JointEnd0.Transform(matrix);
JointEnd1 = collider.JointEnd1.Transform(matrix);

PosY = matrix.GetTranslation().y;
}

public Aabb GetTransformedAabb(float4x4 matrix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ internal static void UpdateDisplacement(int itemId, ref PlungerMovementState mov

private static void UpdateCollider(float len, ref PlungerCollider collider)
{
collider.LineSegSide0.V1y = len;
collider.LineSegSide1.V2y = len;
var yPos = collider.PosY + len;

collider.LineSegEnd.V2y = len;
collider.LineSegEnd.V1y = len; // + 0.0001f;
collider.LineSegSide0.V1y = yPos;
collider.LineSegSide1.V2y = yPos;

collider.JointEnd0.XyY = len;
collider.JointEnd1.XyY = len; // + 0.0001f;
collider.LineSegEnd.V2y = yPos;
collider.LineSegEnd.V1y = yPos; // + 0.0001f;

collider.JointEnd0.XyY = yPos;
collider.JointEnd1.XyY = yPos; // + 0.0001f;

collider.LineSegSide0.CalcNormal();
collider.LineSegSide1.CalcNormal();
Expand Down

0 comments on commit 91c886d

Please sign in to comment.