C# Класс Terrarium.Game.WorldState

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddOrganism ( OrganismBase.OrganismState state ) : void

Should only be called by the GameEngine.

BuildIndex ( ) : void

Build the cell index.

ClearIndex ( ) : void

Clear the current cell index.

DuplicateMutable ( ) : object

Copies the object, but not the isImmutable bit. Makes a newly immutable copy.

FillCells ( OrganismBase.OrganismState state, int cellX, int cellY, int cellRadius, System.Boolean clear ) : void

Fills in the appropriate grid cells in our CellIndex given the organism state.

FindOrganisms ( int x1, int x2, int y1, int y2 ) : ArrayList

Find organisms with the given rectangular area.

FindOrganismsInCells ( int minGridX, int maxGridX, int minGridY, int maxGridY ) : ArrayList

Finds all organisms within a range of cells.

FindOrganismsInView ( OrganismBase.OrganismState state, int radius ) : ArrayList

Find a list of organisms within the view of the given organism.

GetAvailableLight ( OrganismBase.PlantState plant ) : int

Percentage of light reaching this plant. We assume the sun moves from east to west directly overhead We get a rough estimation like this: Get all plants with a certain radius whose radius blocks any East-West vector that intersects any part of the radius of the plant in question -- assume they block it completely Figure out which blocks it at the highest angle. Discount the amount of light the plant sees by angle / 180

GetOrganismState ( string organismID ) : OrganismBase.OrganismState

Retrieve the organism state from the world state for the given ID.

IsGridCellOccupied ( int cellX, int cellY ) : System.Boolean

Used to determine if a grid cell is occupied.

MakeImmutable ( ) : void

Makes all portions of the world state immutable including all organism state objects.

OnlyOverlapsSelf ( OrganismBase.OrganismState state ) : System.Boolean

Make sure the organism only overlaps itself and not other organisms.

RefreshOrganism ( OrganismBase.OrganismState state ) : void

Should only be called by the game engine. Should be called if the state of the organism changes.

RemoveOrganism ( string organismID ) : void

Should only be called by the game engine. Removes an organism from the world state.

WorldState ( int gridWidth, int gridHeight ) : System

Creates a new world state with the given number of grid cells.

Приватные методы

Метод Описание
buildIndexInternal ( bool isDeserializing ) : void

Builds the cell index.

Описание методов

AddOrganism() публичный Метод

Should only be called by the GameEngine.
public AddOrganism ( OrganismBase.OrganismState state ) : void
state OrganismBase.OrganismState The state of the organism to add.
Результат void

BuildIndex() публичный Метод

Build the cell index.
public BuildIndex ( ) : void
Результат void

ClearIndex() публичный Метод

Clear the current cell index.
public ClearIndex ( ) : void
Результат void

DuplicateMutable() публичный Метод

Copies the object, but not the isImmutable bit. Makes a newly immutable copy.
public DuplicateMutable ( ) : object
Результат object

FillCells() публичный Метод

Fills in the appropriate grid cells in our CellIndex given the organism state.
public FillCells ( OrganismBase.OrganismState state, int cellX, int cellY, int cellRadius, System.Boolean clear ) : void
state OrganismBase.OrganismState The state of the organism being added.
cellX int The location of the organism in cells.
cellY int The location of the organism in cells.
cellRadius int The radius in cells of the organism.
clear System.Boolean Determines if cells should be cleared or set.
Результат void

FindOrganisms() публичный Метод

Find organisms with the given rectangular area.
public FindOrganisms ( int x1, int x2, int y1, int y2 ) : ArrayList
x1 int Part of the location rectangle.
x2 int Part of the location rectangle.
y1 int Part of the location rectangle.
y2 int Part of the location rectangle.
Результат System.Collections.ArrayList

FindOrganismsInCells() публичный Метод

Finds all organisms within a range of cells.
public FindOrganismsInCells ( int minGridX, int maxGridX, int minGridY, int maxGridY ) : ArrayList
minGridX int Leftmost grid cell
maxGridX int Rightmost grid cell
minGridY int Topmost grid cell
maxGridY int Bottommost grid cell
Результат System.Collections.ArrayList

FindOrganismsInView() публичный Метод

Find a list of organisms within the view of the given organism.
public FindOrganismsInView ( OrganismBase.OrganismState state, int radius ) : ArrayList
state OrganismBase.OrganismState The state of the organism to check.
radius int The radius of vision.
Результат System.Collections.ArrayList

GetAvailableLight() публичный Метод

Percentage of light reaching this plant. We assume the sun moves from east to west directly overhead We get a rough estimation like this: Get all plants with a certain radius whose radius blocks any East-West vector that intersects any part of the radius of the plant in question -- assume they block it completely Figure out which blocks it at the highest angle. Discount the amount of light the plant sees by angle / 180
public GetAvailableLight ( OrganismBase.PlantState plant ) : int
plant OrganismBase.PlantState The plant to get light for.
Результат int

GetOrganismState() публичный Метод

Retrieve the organism state from the world state for the given ID.
public GetOrganismState ( string organismID ) : OrganismBase.OrganismState
organismID string The ID to match an organism state.
Результат OrganismBase.OrganismState

IsGridCellOccupied() публичный Метод

Used to determine if a grid cell is occupied.
public IsGridCellOccupied ( int cellX, int cellY ) : System.Boolean
cellX int The cell index.
cellY int The cell index.
Результат System.Boolean

MakeImmutable() публичный Метод

Makes all portions of the world state immutable including all organism state objects.
public MakeImmutable ( ) : void
Результат void

OnlyOverlapsSelf() публичный Метод

Make sure the organism only overlaps itself and not other organisms.
public OnlyOverlapsSelf ( OrganismBase.OrganismState state ) : System.Boolean
state OrganismBase.OrganismState The state of the organism to check.
Результат System.Boolean

RefreshOrganism() публичный Метод

Should only be called by the game engine. Should be called if the state of the organism changes.
public RefreshOrganism ( OrganismBase.OrganismState state ) : void
state OrganismBase.OrganismState The state of the organism to refresh.
Результат void

RemoveOrganism() публичный Метод

Should only be called by the game engine. Removes an organism from the world state.
public RemoveOrganism ( string organismID ) : void
organismID string The ID of the organism that needs to be removed.
Результат void

WorldState() публичный Метод

Creates a new world state with the given number of grid cells.
public WorldState ( int gridWidth, int gridHeight ) : System
gridWidth int The width of the world state in grid cells.
gridHeight int The height of the world state in grid cells.
Результат System