AngeliA
Search Results for

    Show / Hide Table of Contents

    Class Physics

    Core system that handles physics of AngeliA games. Logic of the system is frame-isolated which means data from prev frame will never effect current frame.

    Properties

    IsReady

    True if the system is ready to use.

    Declaration
    public static bool IsReady { get; }

    Methods

    FillBlock(int, int, IRect, bool, Tag)

    Add a physics cell for a map block for current frame. Call this function inside Entity.FirstUpdate

    Declaration
    public static void FillBlock(int layer, int blockID, IRect globalRect, bool isTrigger = false, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int layer

    Which layer to add this cell into. (Use PhysicsLayer.XXX to get this value)

    int blockID

    ID of the source block

    IRect globalRect

    Rect position in global space

    bool isTrigger

    True if the cell should mark as trigger

    Tag tag

    What extra info this cell have

    FillEntity(int, Entity, bool, Tag)

    Add a physics cell for an entity for current frame. Call this function inside Entity.FirstUpdate

    Declaration
    public static void FillEntity(int layer, Entity entity, bool isTrigger = false, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int layer

    Which layer to add this cell into. (Use PhysicsLayer.XXX to get this value)

    Entity entity

    Source entity for this cell

    bool isTrigger

    True if the cell should mark as trigger

    Tag tag

    What extra info this cell have

    ForcePush(Rigidbody, Direction4, int)

    Make a recursive push

    Declaration
    public static void ForcePush(Rigidbody host, Direction4 direction, int distance)
    Parameters
    Type Name Description
    Rigidbody host

    Entity that pushs other

    int distance

    (in global space)

    GetEntity(int, IRect, int, Entity, OperationMode, Tag)

    Get entity instance from stage that overlap given rect

    Declaration
    public static Entity GetEntity(int typeID, IRect globalRect, int mask, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int typeID

    Type of the target entity

    IRect globalRect

    Rect position in global space

    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    GetEntity<T>(IRect, int, Entity, OperationMode, Tag)

    Get entity instance from stage that overlap given rect

    Declaration
    public static T GetEntity<T>(IRect globalRect, int mask, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    IRect globalRect

    Rect position in global space

    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    Type Parameters
    Name Description
    T

    Type of the target entity

    HasEntity<T>(IRect, int, Entity, OperationMode, Tag)

    True if any entity instance from stage that overlap given rect

    Declaration
    public static bool HasEntity<T>(IRect globalRect, int mask, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None) where T : Entity
    Parameters
    Type Name Description
    IRect globalRect

    Rect position in global space

    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    Type Parameters
    Name Description
    T

    Type of the target entity

    IgnoreOverlap(int, IRect, OperationMode)

    Remove all cells that overlap target range

    Declaration
    public static void IgnoreOverlap(int mask, IRect globalRect, OperationMode mode = OperationMode.ColliderAndTrigger)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect globalRect

    Rect position in global space

    OperationMode mode

    What type of cells are included for the operation

    Move(int, Int2, int, int, Int2, Entity)

    Perform move

    Declaration
    public static Int2 Move(int mask, Int2 from, int speedX, int speedY, Int2 size, Entity entity)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    Int2 from

    Starting position in global space

    int speedX

    (in global space)

    int speedY

    (in global space)

    Int2 size

    (in global space)

    Entity entity

    Target that is performing this movement

    Returns
    Type Description
    Int2

    New position in global space after the movement

    MoveIgnoreOneway(int, Int2, int, int, Int2, Entity)

    Perform move without oneway involved

    Declaration
    public static Int2 MoveIgnoreOneway(int mask, Int2 from, int speedX, int speedY, Int2 size, Entity entity)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    Int2 from

    Starting position in global space

    int speedX

    (in global space)

    int speedY

    (in global space)

    Int2 size

    (in global space)

    Entity entity

    Target that is performing this movement

    Returns
    Type Description
    Int2

    New position in global space after the movement

    MoveImmediately(int, Int2, Direction4, int, Int2, Entity, bool)

    Perform move without safe checks. (eg. Collide with objects in middle when moving too fast) This version saves CPU usage.

    Declaration
    public static Int2 MoveImmediately(int mask, Int2 from, Direction4 direction, int speed, Int2 size, Entity entity, bool ignoreOneway = false)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    Int2 from

    Starting position in global space

    Direction4 direction

    Which direction to move

    int speed

    (in global space)

    Int2 size

    (in global space)

    Entity entity

    Target that is performing this movement

    bool ignoreOneway

    True if oneway gates are excluded

    Returns
    Type Description
    Int2

    New position in global space after the movement

    Overlap(int, IRect, Entity, OperationMode, Tag)

    True if any cell overlap the given rect

    Declaration
    public static bool Overlap(int mask, IRect globalRect, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect globalRect

    Rect position in global space

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    Overlap(int, IRect, out PhysicsCell, Entity, OperationMode, Tag)

    True if any cell overlap the given rect

    Declaration
    public static bool Overlap(int mask, IRect globalRect, out PhysicsCell info, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect globalRect

    Rect position in global space

    PhysicsCell info

    Cell of the overlaping object

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    OverlapAll(PhysicsCell[], int, IRect, Entity, OperationMode, Tag)

    Find all cells that overlap with given rect and fill into given array

    Declaration
    public static int OverlapAll(PhysicsCell[] hits, int mask, IRect globalRect, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    PhysicsCell[] hits

    The array that will hold the result

    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect globalRect

    Rect position in global space

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    Returns
    Type Description
    int

    How many cells are founded

    OverlapAll(int, IRect, out int, Entity, OperationMode, Tag)

    Find all cells that overlap with given rect and fill into an array (The array is cached internaly. Max size 1024)

    Declaration
    public static PhysicsCell[] OverlapAll(int mask, IRect globalRect, out int count, Entity ignore = null, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect globalRect

    Rect position in global space

    int count

    How many cells are founded

    Entity ignore

    Entity that should be excluded

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    Returns
    Type Description
    PhysicsCell[]

    Cell array with the results

    RoomCheck(int, IRect, Entity, Direction4, OperationMode, Tag)

    True if there is free room founded at given direction (only Involving solid colliders)

    Declaration
    public static bool RoomCheck(int mask, IRect rect, Entity entity, Direction4 direction, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect rect

    Start location in global space

    Entity entity

    Entity that should be exclude

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    RoomCheck(int, IRect, Entity, Direction4, out PhysicsCell, OperationMode, Tag)

    True if there is free room founded at given direction (only Involving solid colliders)

    Declaration
    public static bool RoomCheck(int mask, IRect rect, Entity entity, Direction4 direction, out PhysicsCell hit, OperationMode mode = OperationMode.ColliderOnly, Tag tag = Tag.None)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect rect

    Start location in global space

    Entity entity

    Entity that should be exclude

    PhysicsCell hit

    Cell of the object that blocks the free room

    OperationMode mode

    What type of cells are included for the operation

    Tag tag

    Only cells with all tags should be included

    RoomCheckOneway(int, IRect, Entity, Direction4, out PhysicsCell, bool, bool)

    True if there is free room founded at given direction (only Involving oneway gate)

    Declaration
    public static bool RoomCheckOneway(int mask, IRect rect, Entity entity, Direction4 direction, out PhysicsCell hit, bool overlapCheck = false, bool blockOnly = false)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect rect

    Start location in global space

    Entity entity

    Entity that should be exclude

    PhysicsCell hit

    Cell of the object that blocks the free room

    bool overlapCheck

    True if oneway gates that not blocking the way (only overlap with rect) count as blocked

    bool blockOnly

    True if ignore oneway gates from entities

    RoomCheckOneway(int, IRect, Entity, Direction4, bool, bool)

    True if there is free room founded at given direction (only Involving oneway gate)

    Declaration
    public static bool RoomCheckOneway(int mask, IRect rect, Entity entity, Direction4 direction, bool overlapCheck = false, bool blockOnly = false)
    Parameters
    Type Name Description
    int mask

    What physics layers is included (use PhysicsMask.XXX to get this value)

    IRect rect

    Start location in global space

    Entity entity

    Entity that should be exclude

    bool overlapCheck

    True if oneway gates that not blocking the way (only overlap with rect) count as blocked

    bool blockOnly

    True if ignore oneway gates from entities

    Back to top ๐Ÿ„๐Ÿฆโ€โฌ›๐Ÿงฆ๐Ÿˆ๐ŸŽƒ๐Ÿ’“๐ŸŒนโ˜•๐Ÿดโ€โ˜ ๏ธ๐Ÿค