C# Class SGDE.Physics.Collision.CollisionUnit

Defines the collision properties and methods to check collisions for an Entity.
Inheritance: SceneNode
Datei anzeigen Open project: sgdc/sgdc-old Class Usage Examples

Public Methods

Method Description
AddCollision ( CollisionUnit other ) : void

Add a collision to with another unit.

ClearCheckedUnits ( ) : void

Clear the list of checked units.

ClearCollisions ( ) : void

Clear any collisions, whether they occured or not.

CollidesWith ( CollisionUnit other ) : bool

Determine if this CollisionUnit collides with another.

CollisionUnit ( System.Entity owner, Vector2 location, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System

Instantiate a new CollisionUnit. This constructor is for circle based collisions.

CollisionUnit ( System.Entity owner, Vector2 point1, Vector2 point2, CollisionType collisionType, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System

Instantiate a new CollisionUnit. This constructor is for line and box based collisions.

CollisionUnit ( System.Entity owner, Vector2 center, int radius, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System

Instantiate a new CollisionUnit. This constructor is for circle based collisions.

CollisionsChanged ( int timeStamp ) : bool

Get if collisions changed since the last time checked.

CollisionsChanged ( bool bChanged ) : void

Set if collisions changed on this unit.

GetCheckTimeStamp ( ) : int

Get the last time that the collision unit was checked.

GetCheckedUnits ( ) : List

Get the last CollisionUnits that this collision unit was checked with.

GetCircleCenter ( ) : Vector2

For circle based collisions, get the circle center.

GetCircleRadius ( ) : int

For circle based collisions, get the circle radius.

GetCollisionPoint ( CollisionUnit other ) : Vector2

Get the point of collision with the other CollisionUnit. This does not do any real collision checks so the returned value might not be the actual collision point.

GetCollisionType ( ) : CollisionType

Get the CollisionUnit type.

GetCollisions ( ) : List

Get a list of all collisions.

GetFullCheckTimeStamp ( ) : int

Get the last time the collision unit was updated.

GetHeight ( ) : int

For box based collisions, get the height of the box. For circle based collisions, get the circle diameter.

GetLastCheckedBy ( ) : CollisionUnit

Get the last collision unit that was checked with this collision unit.

GetLineEnd ( ) : Vector2

For line based collisions, get the line end.

GetLineStart ( ) : Vector2

For line based collisions, get the line start.

GetLowerRight ( ) : Vector2

For box based collisions, get the lower-right corner of the box. For circle based collisions, get the lower-right bound of the circle.

GetOwner ( ) : System.Entity

Get the "owner" Entity of this CollisionUnit.

GetUpperLeft ( ) : Vector2

For box based collisions, get the upper-left corner of the box. For circle based collisions, get the upper-left bound of the circle.

GetWidth ( ) : int

For box based collisions, get the width of the box. For circle based collisions, get the circle diameter.

HasCollisions ( ) : bool

Get if the CollisionUnit has collisions.

IsSolid ( ) : bool

Get if the collision unit is solid.

NeedsCollisionUpdate ( ) : bool

Get if the CollisionUnit needs to be updated.

NeedsCollisionUpdate ( bool needsUpdate ) : void

Set if the CollisionUnit needs to be updated.

RemoveCollision ( CollisionUnit other ) : void

Remove a collision with another unit.

Rotate ( float rotation ) : void

Rotate the CollisionUnit a specified amount.

Scale ( Vector2 scale ) : void

Scale the CollisionUnit a specified amount.

SetCheckTimeStamp ( int timeStamp ) : void

Set the last time the collision unit was checked.

SetFullCheckTimeStamp ( int timeStamp ) : void

Set the last time the collision unit was updated.

SetLastCheckedBy ( CollisionUnit unit ) : void

Set the last collision unit to be checked with this collision unit.

SetSolid ( bool blockOthers ) : void

Set if the collision unit is solid.

Translate ( Vector2 translation ) : void

Translate the CollisionUnit a specified amount.

UpdateCollisionsWith ( CollisionUnit other ) : void

Update the collision status between this and the other CollisionUnit.

UsesPixelCollision ( ) : bool

Get is pixel-perfect collisions are enabled.

Private Methods

Method Description
CalculateCircle ( Vector2 location ) : void
CircleBoxCollision ( Vector2 circleCenter, int circleRadius, Vector2 boxUpperLeft, Vector2 boxLowerRight ) : bool
InitializeCommonStuff ( System.Entity owner, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : void

Method Details

AddCollision() public method

Add a collision to with another unit.
public AddCollision ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit that was collided with.
return void

ClearCheckedUnits() public method

Clear the list of checked units.
public ClearCheckedUnits ( ) : void
return void

ClearCollisions() public method

Clear any collisions, whether they occured or not.
public ClearCollisions ( ) : void
return void

CollidesWith() public method

Determine if this CollisionUnit collides with another.
public CollidesWith ( CollisionUnit other ) : bool
other CollisionUnit The CollisionUnit to check for collision.
return bool

CollisionUnit() public method

Instantiate a new CollisionUnit. This constructor is for circle based collisions.
public CollisionUnit ( System.Entity owner, Vector2 location, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System
owner System.Entity The "owner" Entity that this CollisionUnit will be for.
location Vector2 The top-left corner of the .
collisionMask Microsoft.Xna.Framework.Graphics.Texture2D Collision mask for the object.
bUsePixelCollision bool Is pixel-perfect collisions should be used.
return System

CollisionUnit() public method

Instantiate a new CollisionUnit. This constructor is for line and box based collisions.
public CollisionUnit ( System.Entity owner, Vector2 point1, Vector2 point2, CollisionType collisionType, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System
owner System.Entity The "owner" Entity that this COllisionUnit will be for.
point1 Vector2 A point on the line or a corner of the box. For line, this is the start. For box, this is the upper-left corner.
point2 Vector2 A point on the line or a corner of the box. For line, this is the end. For box, this is the lower-right corner.
collisionType CollisionType /// The collision type to use. The only accepted value is , which makes this a line based collision unit. All other values default to box based collision. ///
collisionMask Microsoft.Xna.Framework.Graphics.Texture2D Collision mask for the object.
bUsePixelCollision bool Is pixel-perfect collisions should be used.
return System

CollisionUnit() public method

Instantiate a new CollisionUnit. This constructor is for circle based collisions.
public CollisionUnit ( System.Entity owner, Vector2 center, int radius, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System
owner System.Entity The "owner" Entity that this CollisionUnit will be for.
center Vector2 The location of the circle center.
radius int The radius of the circle.
collisionMask Microsoft.Xna.Framework.Graphics.Texture2D Collision mask for the object.
bUsePixelCollision bool Is pixel-perfect collisions should be used.
return System

CollisionsChanged() public method

Get if collisions changed since the last time checked.
public CollisionsChanged ( int timeStamp ) : bool
timeStamp int The current timestamp.
return bool

CollisionsChanged() public method

Set if collisions changed on this unit.
public CollisionsChanged ( bool bChanged ) : void
bChanged bool true if the collisions changed, false if otherwise.
return void

GetCheckTimeStamp() public method

Get the last time that the collision unit was checked.
public GetCheckTimeStamp ( ) : int
return int

GetCheckedUnits() public method

Get the last CollisionUnits that this collision unit was checked with.
public GetCheckedUnits ( ) : List
return List

GetCircleCenter() public method

For circle based collisions, get the circle center.
public GetCircleCenter ( ) : Vector2
return Vector2

GetCircleRadius() public method

For circle based collisions, get the circle radius.
public GetCircleRadius ( ) : int
return int

GetCollisionPoint() public method

Get the point of collision with the other CollisionUnit. This does not do any real collision checks so the returned value might not be the actual collision point.
public GetCollisionPoint ( CollisionUnit other ) : Vector2
other CollisionUnit The CollisionUnit to get the collision point from.
return Vector2

GetCollisionType() public method

Get the CollisionUnit type.
public GetCollisionType ( ) : CollisionType
return CollisionType

GetCollisions() public method

Get a list of all collisions.
public GetCollisions ( ) : List
return List

GetFullCheckTimeStamp() public method

Get the last time the collision unit was updated.
public GetFullCheckTimeStamp ( ) : int
return int

GetHeight() public method

For box based collisions, get the height of the box. For circle based collisions, get the circle diameter.
public GetHeight ( ) : int
return int

GetLastCheckedBy() public method

Get the last collision unit that was checked with this collision unit.
public GetLastCheckedBy ( ) : CollisionUnit
return CollisionUnit

GetLineEnd() public method

For line based collisions, get the line end.
public GetLineEnd ( ) : Vector2
return Vector2

GetLineStart() public method

For line based collisions, get the line start.
public GetLineStart ( ) : Vector2
return Vector2

GetLowerRight() public method

For box based collisions, get the lower-right corner of the box. For circle based collisions, get the lower-right bound of the circle.
public GetLowerRight ( ) : Vector2
return Vector2

GetOwner() public method

Get the "owner" Entity of this CollisionUnit.
public GetOwner ( ) : System.Entity
return System.Entity

GetUpperLeft() public method

For box based collisions, get the upper-left corner of the box. For circle based collisions, get the upper-left bound of the circle.
public GetUpperLeft ( ) : Vector2
return Vector2

GetWidth() public method

For box based collisions, get the width of the box. For circle based collisions, get the circle diameter.
public GetWidth ( ) : int
return int

HasCollisions() public method

Get if the CollisionUnit has collisions.
public HasCollisions ( ) : bool
return bool

IsSolid() public method

Get if the collision unit is solid.
public IsSolid ( ) : bool
return bool

NeedsCollisionUpdate() public method

Get if the CollisionUnit needs to be updated.
public NeedsCollisionUpdate ( ) : bool
return bool

NeedsCollisionUpdate() public method

Set if the CollisionUnit needs to be updated.
public NeedsCollisionUpdate ( bool needsUpdate ) : void
needsUpdate bool true if the unit needs to be updated, false if otherwise.
return void

RemoveCollision() public method

Remove a collision with another unit.
public RemoveCollision ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit to remove the collision from.
return void

Rotate() public method

Rotate the CollisionUnit a specified amount.
public Rotate ( float rotation ) : void
rotation float The delta rotation of the CollisionUnit, in radians.
return void

Scale() public method

Scale the CollisionUnit a specified amount.
public Scale ( Vector2 scale ) : void
scale Vector2 The delta scale of the CollisionUnit.
return void

SetCheckTimeStamp() public method

Set the last time the collision unit was checked.
public SetCheckTimeStamp ( int timeStamp ) : void
timeStamp int The last time the collision unit was checked.
return void

SetFullCheckTimeStamp() public method

Set the last time the collision unit was updated.
public SetFullCheckTimeStamp ( int timeStamp ) : void
timeStamp int The last time the collision unit was updated.
return void

SetLastCheckedBy() public method

Set the last collision unit to be checked with this collision unit.
public SetLastCheckedBy ( CollisionUnit unit ) : void
unit CollisionUnit The last checked collision unit.
return void

SetSolid() public method

Set if the collision unit is solid.
public SetSolid ( bool blockOthers ) : void
blockOthers bool true if the collision unit is solid, false if otherwise.
return void

Translate() public method

Translate the CollisionUnit a specified amount.
public Translate ( Vector2 translation ) : void
translation Vector2 The delta translation to move the unit.
return void

UpdateCollisionsWith() public method

Update the collision status between this and the other CollisionUnit.
public UpdateCollisionsWith ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit to update.
return void

UsesPixelCollision() public method

Get is pixel-perfect collisions are enabled.
public UsesPixelCollision ( ) : bool
return bool