Animal Methods |
The Animal type exposes the following members.
Name | Description | |
---|---|---|
![]() | BeginAttacking | Method used to command your creature to start attacking another creature. You can only attack one creature per round, and a single call to BeginAttacking will only attack a target creature in the upcoming tick. Calling BeginAttacking multiple times in the same turn will only result in your creature attacking the target specified in the last call to BeginAttacking. Attacking is asynchronous so you'll need to handle the AttackCompleted event in order to get the status of your attack. A single attack might not kill a target enemy so you should detect if the enemy is still alive and call BeginAttacking once per round until the target creature is either dead or has escaped. |
![]() | BeginDefending | Method used to command a creature to begin defending against a specific target creature. You can only defend against one creature at a time, so only the final call to BeginDefending will actually be used in the upcoming turn. Once your creature has finished defending, the DefendCompleted event will be fired and your event handler will be called if you provided one. You can use this event to determine the results of your defense. |
![]() | BeginEating | Method used to command your creature to start eating another creature. You can only eat one target creature per round, and a single call to BeginEating will only attack a target creature in the upcoming tick. Calling BeginEating multiple times in the same turn will only result in your creature eating the target specified in the last call to BeginEating. Eating is asynchronous so you'll need to handle the EatCompleted event in order to get the status of the bite. A single bite might not produce enough energy for your creature so you'll have to make multiple bites against the same target until it is completed eaten. |
![]() | BeginMoving | Method used to command a creature to begin moving towards a specific location at a specific speed. The actual movement operation may take several turns, but is always initiated using this method. Your movement location should be within the world boundary and your movement speed should be less than or equal to your creature's Species.MaximumSpeed. Once called the creature will begin moving towards the specified point. This movement will continue until you issue a different BeginMoving command to your creature, it reaches its destination, or becomes blocked by something. Any calls to BeginMoving will clear out any previous calls, so care should be taken when issuing multi-part path movements. Once the movement is completed the MoveCompleted event will be fired and your event handler for this function will be called if you've provided one. The event handler will provide full information about the results of an attempted movement operation. |
![]() | BeginReproduction | Use this function to command your creature to reproduce. There are many conditions on whether your creature can reproduce. If these conditions are not met, an exception will be thrown. The easiest way to make sure all pre-existing conditions have been met is to check the CanReproduce property. If you call this method multiple times in the same turn, then the last call will be used, and all previous calls will be ignored. This method is also asynchronous, and a ReproduceCompletedEvent will be fired when your creature has actually given birth. The time between start and completion is 10 ticks. |
![]() | CanAttack | Used to determine if your creature can attack another creature. This will return true all the time for a Carnivore since they can always attack. For Herbivores this will return true if they are hungry enough to be aggressive. Herbivores may also attack a creature in the upcoming round if that creature attacked them in the previous round. The best place to attack a creature that is attacking you is to handle the Attacked event. |
![]() | DeserializeAnimal | This method should be overridden by any class inheriting from Animal. This method is called with a MemoryStream that the user can read any data from that was written during the call to SerializeAnimal. Care should be taken when reading from a MemoryStream since the values may have been truncated at 8000bytes if more than 8000bytes were originally written. |
![]() | DistanceTo | Calculates the linear distance between your creature and another using various API's defined by the Vector class. |
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetThenErasePendingActions | (Inherited from Organism.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Initialize |
The Initialize method is called immediately after instantiating a new creature.
The developer should override this method to set up event handlers for the
creature and do any first time initialization that needs to be done to set
up member variables.
(Inherited from Organism.) |
![]() | InternalAnimalDeserialize |
Implemented by the Animal class in order to allow
deserialization of any private members required for the
class to operate properly after deserialization.
|
![]() | InternalAnimalSerialize |
Implemented by the Animal class in order to allow
serialization of any private members required for the
class to operate properly after deserialization.
|
![]() | InternalMain |
Provides all of the per tick processing for an Animal. This method
fires all of the events that make a creature tick. Some events
are fired every tick, while other events are only fired whenever
certain actions complete. This method can be called in order to
process Animal code without processing the developer code in the
instance they are being skipped for using too much time.
(Overrides OrganismInternalMain(Boolean).) |
![]() | InternalOrganismDeserialize | (Inherited from Organism.) |
![]() | InternalOrganismSerialize | (Inherited from Organism.) |
![]() | IsMySpecies | Allows a creature to determine if the OrganismState of another creature represents the same species. This can be used to determine whether you should attack/defend against another creature. Creatures of the same species often don't fight one another, defend against one another, and kill one another. They often help their own species in fights against other species. Carnivores of the same species may sacrifice themselves as food once they become too old to members of their species. |
![]() | LookFor | Tries to return an updated OrganismState given a creature's state OrganismState. This function may return null if the creature can't be found or was hidden by camouflage. You may call this method multiple times and get different results. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | RefreshState | Tries to return an updated OrganismState given a creature's ID. This function may return null if the creature can't be found or was hidden by camouflage. You may call this method multiple times just like the LookFor method and get different results. |
![]() | Scan | Scans the world around your creature's current location in a circular area and returns an ArrayList of OrganismState objects representing what was seen. The radius scanned by your creature is dependent upon the number of points placed into the EyesightPoints attribute. Animals may also hide within your radius by using camouflage. This means that more points placed into the EyesightPoints attribute will yield a better vision of hidden creatures. Because of camouflage and the random aspect of hiding vs. being seen by another creature, multiple calls to Scan might returns different results. However, each call to Scan also takes additional time from your creature's total timeslice. It is recommended that you hold onto the OrganismState objects, determine your target creature, and then use the LookFor method to update the state rather than calling the Scan method again. The LookFor method also takes into account camouflage and may not work the first time, but is much less expensive timewise than Scan. |
![]() | SerializeAnimal | This method should be overridden by any class inheriting from Animal. This method is called with a MemoryStream that the user can place any data on they wish to Serialize during save games or while being teleported. The complement of this method is the DeserializeAnimal method which is called to deserialize the data when the creature is restored. Authors should be careful when writing to a MemoryStream since it will be truncated at 8000bytes. |
![]() | SetWorldBoundary | (Inherited from Organism.) |
![]() | StopMoving | Clears any pending movement operations your creature might be performing. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | WithinAttackingRange | Used to determine if your creature is within range to attack another target creature. This method does not attempt to validate the position of the organismState with respect to the current world state. If you pass a stale object in then you may get stale results. Make sure you use the LookFor method to get the most up-to-date results. |
![]() | WithinEatingRange | Used to determine if your creature is within range to eat another target creature. This method does not attempt to validate the position of the organismState with respect to the current world state. If you pass a stale object in then you may get stale results. Make sure you use the LookFor method to get the most up-to-date results. |
![]() | WriteTrace(Object) | Writes a trace to the Terrarium trace window for debugging. The Tracing routines take a *very* small amount of time if you're not monitoring them. They are on the order of 12 nSec per call. To meet this performance requirement there are several overloads taking a varying number of parameters rather than a single variable argument parameter. |
![]() | WriteTrace(Object, Object) | Writes a trace to the Terrarium trace window for debugging. The Tracing routines take a *very* small amount of time if you're not monitoring them. They are on the order of 12 nSec per call. To meet this performance requirement there are several overloads taking a varying number of parameters rather than a single variable argument parameter. |
![]() | WriteTrace(Object, Object, Object) | Writes a trace to the Terrarium trace window for debugging. The Tracing routines take a *very* small amount of time if you're not monitoring them. They are on the order of 12 nSec per call. To meet this performance requirement there are several overloads taking a varying number of parameters rather than a single variable argument parameter. |
![]() | WriteTrace(Object, Object, Object, Object) | Writes a trace to the Terrarium trace window for debugging. The Tracing routines take a *very* small amount of time if you're not monitoring them. They are on the order of 12 nSec per call. To meet this performance requirement there are several overloads taking a varying number of parameters rather than a single variable argument parameter. |