Click or drag to resize
OrganismState Class

All properties of an organism that are used by the game are on this object. Each OrganismState is immutable and references can be held as long as the organism needs them.

This object only represents the state of a creature for a given turn and is not dynamically updated. Creatures should use the LookFor method in order to get the latest state of another creature.

Inheritance Hierarchy

Namespace: Terrarium.Sdk.Classes.State
Assembly: Terrarium.Sdk (in Terrarium.Sdk.dll) Version: 1.1.0.0 (1.1.0.0)
Syntax
[SerializableAttribute]
public abstract class OrganismState : IComparable

The OrganismState type exposes the following members.

Methods
  NameDescription
Public methodAddIncubationTick
Add a single tick to the current incubation period. Called by the game engine each tick after the creature starts reproducing. Once the amount of ticks hits the limit for the amount of time required to incubate a child, the creature is born, and incubation is no longer required.
Public methodAddTickToAge
Adds a single tick to the creature's current age. This is also responsible for ticking down other counters like growth and reproduction. When ticks hits the LifeSpan the creature dies, but when the other counters reach 0 the action becomes available.
Public methodBurnEnergy
Used by the game engine to burn a creature's energy depending on the various actions they perform including movement, reproduction, and growth.
Public methodCloneMutable
Derived classes must override this to return an instance of their class type that has the same state (by calling CopyStateInto)
Public methodCompareTo
Compares two organism state objects together. This method takes into account the Y position for graphical Z-Ordering purposes and can be used to sort creatures for back to front rendering.
Protected methodCopyStateInto
Derived classes must override (and call Base.CopyStateInto) if they have additional state
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGrow
This returns a clone because we need the radius to be editable and the object may not allow this because it is already in the index the object returned will have the same events as the original
Public methodHealDamage
Required override for other state classes. This method gives the creature a chance to heal some previously inflicted damage.
Public methodIncreaseRadiusTo
Used by the game engine to increase the radius of a creature to a new radius amount. Each time a creature grows this method is called to set the new radius. The new radius must be larger than the previous one, so creatures can't shrink. The radius can be increased by more than a single unit, but the current Terrarium only encompasses methods that increase a radius by a single unit.
Public methodIsAdjacentOrOverlapping

Determines if a creature is immediately next to or overlapping another creature using grid cells comparisons.

Public methodIsWithinRect
Used to compute whether or not a given state object is in an adjacent or overlapping grid cell. The extra radius can be used to extend the area used for the function to find a match and so can be used for functions like visibiliy.
Public methodKill
Called by the game engine in order to kill the current creature. Since this method can only be called when the state is mutable player's can't use the method to arbitrarily kill competing organisms.
Public methodLockSizeAndPosition
Performs a special type of immutability lock for the size and position related properties only. This is to ensure that the area of a creature isn't changed after the creature's index array position has been found in the game world.
Public methodMakeImmutable
Makes all properties immutable. Ensures that the organism state cannot be changed at all by creatures with access to the state.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodResetGrowthWait
Used by the game engine to reset the amount of time the creature must wait before growing. The wait time is based on the creature's species class which uses the creature's lifepsan as a base for the growth period. This should be called after a creature has been given the chance to grow, and must wait before growing again.
Public methodResetReproductionWait
Sets the current reproduction wait of the creature to the wait time specified by the creature's species. This value will be set based on the creature's lifespan and creature type (whether carnivore or herbivore). This is called by the engine after reproduction has completed.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUpperBoundaryForEnergyState

Returns the amount of energy required to be at the top of a given EnergyState. It's recommended that the actual EnergyState property be used to determine the current energy bucket a creature is in.

Top
Fields
  NameDescription
Protected fieldcurrentFoodChunks
The amount of food chunks this creature represents. This is important for plants and dead animals.
Top
Properties
  NameDescription
Public propertyActualDirection

Determines the direction the creature is moving in degrees. This along with Speed can be used to calculate where a creature will be in the future.

Public propertyCellRadius

Determines the number of game cells a creature uses on the screen. Each grid cell is 8 pixels in width and height.

Public propertyCurrentMoveToAction
Retrieves information about the creature's current movement vector. If the creature is moving this value will always be non null, and null if the creature isn't currently moving. This is used by the game engine since movement can encompass many turns.
Public propertyCurrentReproduceAction
Used to obtain or modify the current action representing the creature's reproduction status. If this value is not null then the creature is reproducing.
Public propertyDeathReason

Describes the reason why the creature died. This is most often OldAge, Starvation, Killed, or Sickness. If the creature is not dead yet then the value will be NotDead.

Public propertyEnergyState

Determine the current energy state of a creature by comparing the current amount of stored energy versus the various energy buckets.

Public propertyFoodChunks

Determines the amount of food value this creature represents. This can be used to determine if attacking a creature will be worth the effort.

Public propertyGeneration

Generation will be 0 the first time a creature is introduced. Each offspring of a creature will be labeled with its generation plus one. This helps define the longevity of a creature.

Public propertyGridX

Retrieves the creature's current grid location. This is useful for movement algorithms and is used by the engine for computing organism location in a fast and memory efficient manner.

Public propertyGridY

Retrieves the creature's current grid location. This is useful for movement algorithms and is used by the engine for computing organism location in a fast and memory efficient manner.

Public propertyGrowthWait

Determines the amount of time in game ticks a creature must wait before they are able to grow. If a creature is not yet mature, and the GrowthWait is 0, then it is possible the creature does not have enough energy or enough space in order to grow. This should be remedied quickly.

Public propertyID

A string number in the form of a GUID that uniquely represents this creature in the EcoSystem.

Public propertyIncubationTicks

Determines the number of ticks the creature must wait before it has finished reproducing. If your creature just needs to know if it's currently reproducing use the IsIncubating property.

Public propertyIsAlive

Determines if the creature is alive or dead. This is used by Carnivores so they can find food in the form of corpses.

Public propertyIsImmutable
Determines if the current creature state is immutable.
Public propertyIsIncubating

Determines if the creature is in the process of reproduction. Use IncubationTicks to find out exactly how long the creature has left to incubate.

Public propertyIsMature

Determines if the creature is mature by comparing the current Radius to the Radius it will have when mature.

Public propertyIsStopped

Determines if the creature is moving or is completely stopped.

Public propertyOrganismEvents
When events are completed the completion actions get listed into a collection of completed events. These are then used by the processing functions to fire off events on the creature.
Public propertyPercentEnergy

Determines the decimal percentage of the amount of energy a creature currently has, versus the total amount of energy the creature can store.

Public propertyPercentInjured
Must be overriden in derived classes and compute a factor that can be used to represent the injury done to the creature.
Public propertyPercentLifespanRemaining

Determines the decimal percentage of the amount of life remaining a creature currently has, versus the total amount of LifeSpan.

Public propertyPosition

Returns the creature's current position as a Point.

Public propertyPreviousDisplayAction
Returns the action that the organism was performing between the last state and this one. I.e. what ended on this state.
Public propertyRadius

Determines the actual radius of the creature. This is used to determine how close to maturity a creature has gotten or in various computations on attack, defense, and movement.

Public propertyReadyToReproduce

Determines if a creature is ready to reproduce based on the elapsed time since its previous reproduction. Use ReproductionWait to determine exactly how long the creature has to go.

Public propertyRenderInfo
This property remains mutable even though the rest of the object is immutable because it is used by the renderer and maintains rendering state across worldstate instances (like whether the organism is selected or not).
Public propertyReproductionWait

Determines the number of ticks the creature must wait before reproducing again. If your creature just needs to know if it's ready the ReadyToReproduce property can be used instead.

Public propertySpecies

Describes the characteristics of a creature through the use of the ISpecies interface.

Public propertySpeed

Determines the speed at which the creature is moving. Useful in calculating overtake speeds for Carnivores and run-away speeds for Herbivores.

Public propertyStoredEnergy

Determines how much energy a creature has stored. This is used to compute the energy state of the creature.

Public propertyTickAge

Represents the age of a creature in game ticks. Once a creature reaches a TickAge identical to its LifeSpan the creature will die from PopulationChangeReason.OldAge.

Top
See Also