C# Class PunkX.World

Inheritance: Tweener
ファイルを表示 Open project: RichardMarks/PunkX

Public Properties

Property Type Description
camera Microsoft.Xna.Framework.Vector2
visible System.Boolean

Public Methods

Method Description
World ( ) : System

constructor

add ( Entity e ) : Entity

Adds the Entity to the World at the end of the frame.

addGraphic ( Graphic graphic, int layer, float x, float y ) : Entity

Adds an Entity to the World with the Graphic object.

addList ( ) : void

Adds multiple Entities to the world.

addMask ( Mask mask, string type, float x, float y ) : Entity

Adds an Entity to the World with the Mask object.

begin ( ) : void

Override this; called when World is switch to, and set to the currently active world.

bringForward ( Entity e ) : System.Boolean

Shifts the Entity one place towards the front of its contained layer.

bringToFront ( Entity e ) : System.Boolean

Brings the Entity to the front of its contained layer.

classCount ( string name ) : uint

Returns the amount of Entities of the Class are in the World.

classFirst ( string name ) : Entity

The first Entity of the Class.

clearRecycled ( string classType ) : void

Clears stored reycled Entities of the Class type.

clearRecycledAll ( ) : void

Clears stored recycled Entities of all Class types.

collideLine ( string type, int fromX, int fromY, int toX, int toY, int precision = 1, PunkX p = null ) : Entity

Returns the first Entity found that collides with the line.

collidePoint ( string type, float pX, float pY ) : Entity

Returns the first Entity found that collides with the position.

collidePointInto ( string type, float pX, float pY, Object &into ) : void

Populates an array with all Entities that collide with the position. This function does not empty the array, that responsibility is left to the user.

collideRect ( string type, float rX, float rY, int rWidth, int rHeight ) : Entity

Returns the first Entity that collides with the rectangular area.

collideRectInto ( string type, float rX, float rY, int rWidth, int rHeight, Object &into ) : void

Populates an array with all Entities that collide with the rectangle. This function does not empty the array, that responsibility is left to the user.

create ( string classType, System.Boolean addToWorld = true ) : Entity

Returns a new Entity, or a stored recycled Entity if one exists.

end ( ) : void

Override this; called when World is changed, and the active world is no longer this.

getAll ( Object &into ) : void

Pushes all Entities in the World into the array.

getClass ( string name, Object &into ) : void

Pushes all Entities in the World of the Class into the Array or Vector.

getLayer ( int layer, Object &into ) : void

Pushes all Entities in the World on the layer into the Array or Vector.

getType ( string type, Object &into ) : void

Pushes all Entities in the World of the type into the Array or Vector.

isAtBack ( Entity e ) : System.Boolean

If the Entity as at the back of its layer.

isAtFront ( Entity e ) : System.Boolean

If the Entity as at the front of its layer.

layerCount ( int layer ) : uint

Returns the amount of Entities are on the layer in the World.

layerFirst ( int layer ) : Entity

The first Entity on the Layer.

layerLast ( int layer ) : Entity

The last Entity on the Layer.

nearestToEntity ( string type, Entity e, System.Boolean useHitboxes = false ) : Entity

Finds the Entity nearest to another.

nearestToPoint ( string type, float x, float y, System.Boolean useHitboxes = false ) : Entity

Finds the Entity nearest to the position.

nearestToRect ( string type, float x, float y, int width, int height ) : Entity

Finds the Entity nearest to the rectangle.

recycle ( Entity e ) : Entity

Removes the Entity from the World at the end of the frame and recycles it. The recycled Entity can then be fetched again by calling the create() function.

remove ( Entity e ) : Entity

Removes the Entity from the World at the end of the frame.

removeAll ( ) : void

Removes all Entities from the World at the end of the frame.

removeList ( ) : void

Removes multiple Entities from the world.

render ( ) : void

Performed by the game loop, renders all contained Entities. If you override this to give your World render code, remember to call super.render() or your Entities will not be rendered.

sendBackward ( Entity e ) : System.Boolean

Shifts the Entity one place towards the back of its contained layer.

sendToBack ( Entity e ) : System.Boolean

Sends the Entity to the back of its contained layer.

typeCount ( string type ) : uint

Returns the amount of Entities of the type are in the World.

typeFirst ( string type ) : Entity

The first Entity of the type.

update ( ) : void

Performed by the game loop, updates all contained Entities. If you override this to give your World update code, remember to call super.update() or your Entities will not be updated.

updateLists ( ) : void

Updates the add/remove lists at the end of the frame.

Private Methods

Method Description
addRender ( Entity e ) : void

Adds Entity to the render list.

addType ( Entity e ) : void

Adds Entity to the type list.

addUpdate ( Entity e ) : void

Adds Entity to the update list.

removeRender ( Entity e ) : void

Removes Entity from the render list.

removeType ( Entity e ) : void

Removes Entity from the type list.

removeUpdate ( Entity e ) : void

Removes Entity from the update list.

squarePointRect ( float px, float py, float rx, float ry, int rw, int rh ) : float

Calculates the squared distance between a rectangle and a point.

squarePoints ( float x1, float y1, float x2, float y2 ) : float

Calculates the squared distance between two points.

squareRects ( float x1, float y1, int w1, int h1, float x2, float y2, int w2, int h2 ) : float

Calculates the squared distance between two rectangles.

Method Details

World() public method

constructor
public World ( ) : System
return System

add() public method

Adds the Entity to the World at the end of the frame.
public add ( Entity e ) : Entity
e Entity Entity object you want to add.
return Entity

addGraphic() public method

Adds an Entity to the World with the Graphic object.
public addGraphic ( Graphic graphic, int layer, float x, float y ) : Entity
graphic Graphic Graphic to assign the Entity.
layer int Layer of the Entity.
x float X position of the Entity.
y float Y position of the Entity.
return Entity

addList() public method

Adds multiple Entities to the world.
public addList ( ) : void
return void

addMask() public method

Adds an Entity to the World with the Mask object.
public addMask ( Mask mask, string type, float x, float y ) : Entity
mask Mask Mask to assign the Entity.
type string Collision type of the Entity.
x float X position of the Entity.
y float Y position of the Entity.
return Entity

begin() public method

Override this; called when World is switch to, and set to the currently active world.
public begin ( ) : void
return void

bringForward() public method

Shifts the Entity one place towards the front of its contained layer.
public bringForward ( Entity e ) : System.Boolean
e Entity The Entity to shift.
return System.Boolean

bringToFront() public method

Brings the Entity to the front of its contained layer.
public bringToFront ( Entity e ) : System.Boolean
e Entity The Entity to shift.
return System.Boolean

classCount() public method

Returns the amount of Entities of the Class are in the World.
public classCount ( string name ) : uint
name string The Class type to count.
return uint

classFirst() public method

The first Entity of the Class.
public classFirst ( string name ) : Entity
name string The Class type to check.
return Entity

clearRecycled() public method

Clears stored reycled Entities of the Class type.
public clearRecycled ( string classType ) : void
classType string The Class type to clear.
return void

clearRecycledAll() public method

Clears stored recycled Entities of all Class types.
public clearRecycledAll ( ) : void
return void

collideLine() public method

Returns the first Entity found that collides with the line.
public collideLine ( string type, int fromX, int fromY, int toX, int toY, int precision = 1, PunkX p = null ) : Entity
type string The Entity type to check for.
fromX int Start x of the line.
fromY int Start y of the line.
toX int End x of the line.
toY int End y of the line.
precision int fixme
p PunkX fixme
return Entity

collidePoint() public method

Returns the first Entity found that collides with the position.
public collidePoint ( string type, float pX, float pY ) : Entity
type string The Entity type to check for.
pX float X position.
pY float Y position.
return Entity

collidePointInto() public method

Populates an array with all Entities that collide with the position. This function does not empty the array, that responsibility is left to the user.
public collidePointInto ( string type, float pX, float pY, Object &into ) : void
type string The Entity type to check for.
pX float X position.
pY float Y position.
into Object The Array or Vector to populate with collided Entities.
return void

collideRect() public method

Returns the first Entity that collides with the rectangular area.
public collideRect ( string type, float rX, float rY, int rWidth, int rHeight ) : Entity
type string The Entity type to check for.
rX float X position of the rectangle.
rY float Y position of the rectangle.
rWidth int Width of the rectangle.
rHeight int Height of the rectangle.
return Entity

collideRectInto() public method

Populates an array with all Entities that collide with the rectangle. This function does not empty the array, that responsibility is left to the user.
public collideRectInto ( string type, float rX, float rY, int rWidth, int rHeight, Object &into ) : void
type string The Entity type to check for.
rX float X position of the rectangle.
rY float Y position of the rectangle.
rWidth int Width of the rectangle.
rHeight int Height of the rectangle.
into Object The Array or Vector to populate with collided Entities.
return void

create() public method

Returns a new Entity, or a stored recycled Entity if one exists.
public create ( string classType, System.Boolean addToWorld = true ) : Entity
classType string The Class of the Entity you want to add.
addToWorld System.Boolean Add it to the World immediately.
return Entity

end() public method

Override this; called when World is changed, and the active world is no longer this.
public end ( ) : void
return void

getAll() public method

Pushes all Entities in the World into the array.
public getAll ( Object &into ) : void
into Object The Array or Vector to populate.
return void

getClass() public method

Pushes all Entities in the World of the Class into the Array or Vector.
public getClass ( string name, Object &into ) : void
name string The Class type to check.
into Object The Array or Vector to populate.
return void

getLayer() public method

Pushes all Entities in the World on the layer into the Array or Vector.
public getLayer ( int layer, Object &into ) : void
layer int The layer to check.
into Object The Array or Vector to populate.
return void

getType() public method

Pushes all Entities in the World of the type into the Array or Vector.
public getType ( string type, Object &into ) : void
type string The type to check.
into Object The Array or Vector to populate.
return void

isAtBack() public method

If the Entity as at the back of its layer.
public isAtBack ( Entity e ) : System.Boolean
e Entity The Entity to check.
return System.Boolean

isAtFront() public method

If the Entity as at the front of its layer.
public isAtFront ( Entity e ) : System.Boolean
e Entity The Entity to check.
return System.Boolean

layerCount() public method

Returns the amount of Entities are on the layer in the World.
public layerCount ( int layer ) : uint
layer int The layer to count Entities on.
return uint

layerFirst() public method

The first Entity on the Layer.
public layerFirst ( int layer ) : Entity
layer int The layer to check.
return Entity

layerLast() public method

The last Entity on the Layer.
public layerLast ( int layer ) : Entity
layer int The layer to check.
return Entity

nearestToEntity() public method

Finds the Entity nearest to another.
public nearestToEntity ( string type, Entity e, System.Boolean useHitboxes = false ) : Entity
type string The Entity type to check for.
e Entity The Entity to find the nearest to.
useHitboxes System.Boolean If the Entities' hitboxes should be used to determine the distance. If false, their x/y coordinates are used.
return Entity

nearestToPoint() public method

Finds the Entity nearest to the position.
public nearestToPoint ( string type, float x, float y, System.Boolean useHitboxes = false ) : Entity
type string The Entity type to check for.
x float X position.
y float Y position.
useHitboxes System.Boolean If the Entities' hitboxes should be used to determine the distance. If false, their x/y coordinates are used.
return Entity

nearestToRect() public method

Finds the Entity nearest to the rectangle.
public nearestToRect ( string type, float x, float y, int width, int height ) : Entity
type string The Entity type to check for.
x float X position of the rectangle.
y float Y position of the rectangle.
width int Width of the rectangle.
height int Height of the rectangle.
return Entity

recycle() public method

Removes the Entity from the World at the end of the frame and recycles it. The recycled Entity can then be fetched again by calling the create() function.
public recycle ( Entity e ) : Entity
e Entity The Entity to recycle.
return Entity

remove() public method

Removes the Entity from the World at the end of the frame.
public remove ( Entity e ) : Entity
e Entity Entity object you want to remove.
return Entity

removeAll() public method

Removes all Entities from the World at the end of the frame.
public removeAll ( ) : void
return void

removeList() public method

Removes multiple Entities from the world.
public removeList ( ) : void
return void

render() public method

Performed by the game loop, renders all contained Entities. If you override this to give your World render code, remember to call super.render() or your Entities will not be rendered.
public render ( ) : void
return void

sendBackward() public method

Shifts the Entity one place towards the back of its contained layer.
public sendBackward ( Entity e ) : System.Boolean
e Entity The Entity to shift.
return System.Boolean

sendToBack() public method

Sends the Entity to the back of its contained layer.
public sendToBack ( Entity e ) : System.Boolean
e Entity The Entity to shift.
return System.Boolean

typeCount() public method

Returns the amount of Entities of the type are in the World.
public typeCount ( string type ) : uint
type string The type (or Class type) to count.
return uint

typeFirst() public method

The first Entity of the type.
public typeFirst ( string type ) : Entity
type string The type to check.
return Entity

update() public method

Performed by the game loop, updates all contained Entities. If you override this to give your World update code, remember to call super.update() or your Entities will not be updated.
public update ( ) : void
return void

updateLists() public method

Updates the add/remove lists at the end of the frame.
public updateLists ( ) : void
return void

Property Details

camera public_oe property

Point used to determine drawing offset in the render loop.
public Microsoft.Xna.Framework.Vector2 camera
return Microsoft.Xna.Framework.Vector2

visible public_oe property

If the render() loop is performed.
public Boolean,System visible
return System.Boolean