Class Creature
Class that represents all creatures in the game.
Inherited Members
Namespace: Fibula.Creatures
Assembly: Fibula.Creatures.dll
Syntax
public abstract class Creature : Thing, ICreatureThatSensesOthers, ICreature, IThing, IContainedThing, IEquatable<IThing>, IThingContainer, ILocatable, IEquatable<ICreature>
Constructors
| Improve this Doc View SourceCreature(String, String, UInt16, UInt16, UInt16)
Initializes a new instance of the Creature class.
Declaration
protected Creature(string name, string article, ushort maxHitpoints, ushort corpseTypeId = 0, ushort hitpoints = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of this creature. |
System.String | article | An article for the name of this creature. |
System.UInt16 | maxHitpoints | The maximum hitpoints of the creature. |
System.UInt16 | corpseTypeId | The corpse of the creature. |
System.UInt16 | hitpoints | The current hitpoints of the creature. |
Properties
| Improve this Doc View SourceArticle
Gets the article in the name of the creature.
Declaration
public string Article { get; }
Property Value
Type | Description |
---|---|
System.String |
BloodType
Gets or sets this creature's blood type.
Declaration
public BloodType BloodType { get; protected set; }
Property Value
Type | Description |
---|---|
BloodType |
CanWalk
Gets a value indicating whether this creature can walk.
Declaration
public bool CanWalk { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CarryLocation
Gets the location where this thing is being carried at, which is null for creatures.
Declaration
public override Location? CarryLocation { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Location> |
Overrides
| Improve this Doc View SourceCorpseTypeId
Gets the corpse of the creature.
Declaration
public ushort CorpseTypeId { get; }
Property Value
Type | Description |
---|---|
System.UInt16 |
Direction
Gets or sets the direction that this creature is facing.
Declaration
public Direction Direction { get; set; }
Property Value
Type | Description |
---|---|
Direction |
EmittedLightColor
Gets or sets this creature's light color.
Declaration
public byte EmittedLightColor { get; protected set; }
Property Value
Type | Description |
---|---|
System.Byte |
EmittedLightLevel
Gets or sets this creature's light level.
Declaration
public byte EmittedLightLevel { get; protected set; }
Property Value
Type | Description |
---|---|
System.Byte |
Flags
Gets this creature's flags.
Declaration
public uint Flags { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Id
Gets the creature's in-game id.
Declaration
public uint Id { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Inventory
Gets or sets the inventory for the creature.
Declaration
public abstract IInventory Inventory { get; protected set; }
Property Value
Type | Description |
---|---|
IInventory |
IsDead
Gets a value indicating whether the creature is considered dead.
Declaration
public bool IsDead { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LastMovementCostModifier
Gets or sets the creature's last move modifier.
Declaration
public decimal LastMovementCostModifier { get; set; }
Property Value
Type | Description |
---|---|
System.Decimal |
Name
Gets the name of the creature.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
Outfit
Gets or sets the outfit of this creature.
Declaration
public Outfit Outfit { get; set; }
Property Value
Type | Description |
---|---|
Outfit |
Speed
Gets or sets this creature's speed.
Declaration
public abstract ushort Speed { get; protected set; }
Property Value
Type | Description |
---|---|
System.UInt16 |
Stats
Gets the current stats information for the creature.
Declaration
public IDictionary<CreatureStat, IStat> Stats { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<CreatureStat, IStat> |
Remarks
The key is a CreatureStat, and the value is an IStat.
TrackedCreatures
Gets the creatures who are sensed by this creature.
Declaration
public IEnumerable<ICreature> TrackedCreatures { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ICreature> |
TypeId
Gets the type id of this creature.
Declaration
public override ushort TypeId { get; }
Property Value
Type | Description |
---|---|
System.UInt16 |
Overrides
| Improve this Doc View SourceVariableSpeed
Gets or sets this creature's variable speed.
Declaration
public int VariableSpeed { get; protected set; }
Property Value
Type | Description |
---|---|
System.Int32 |
WalkPlan
Gets or sets this creature's walk plan.
Declaration
public WalkPlan WalkPlan { get; set; }
Property Value
Type | Description |
---|---|
WalkPlan |
Methods
| Improve this Doc View SourceAddContent(IThingFactory, IThing, Byte)
Attempts to add a IThing to this container.
Declaration
public (bool result, IThing remainder) AddContent(IThingFactory thingFactory, IThing thing, byte index = 255)
Parameters
Type | Name | Description |
---|---|---|
IThingFactory | thingFactory | A reference to the factory of things to use. |
IThing | thing | The IThing to add to the container. |
System.Byte | index | Optional. The index at which to add the IThing. Defaults to byte.MaxValue, which instructs to add the IThing at any free index. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, IThing> | A tuple with a value indicating whether the attempt was at least partially successful, and false otherwise. If the result was only partially successful, a remainder of the thing may be returned. |
CalculateMovementSpeed()
Calculates the movement speed of the creature.
Declaration
protected virtual ushort CalculateMovementSpeed()
Returns
Type | Description |
---|---|
System.UInt16 | The movement speed of the creature. |
CanSee(Location)
Checks if this creature can see a given location.
Declaration
public bool CanSee(Location location)
Parameters
Type | Name | Description |
---|---|---|
Location | location | The location to check against. |
Returns
Type | Description |
---|---|
System.Boolean | True if this creature can see the given location, false otherwise. |
CanSee(ICreature)
Checks if this creature can see a given creature.
Declaration
public bool CanSee(ICreature otherCreature)
Parameters
Type | Name | Description |
---|---|---|
ICreature | otherCreature | The creature to check against. |
Returns
Type | Description |
---|---|
System.Boolean | True if this creature can see the given creature, false otherwise. |
DescribeForLogger()
Provides a string describing the current creature for logging purposes.
Declaration
public override string DescribeForLogger()
Returns
Type | Description |
---|---|
System.String | The string to log. |
Overrides
| Improve this Doc View SourceEquals(ICreature)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(ICreature other)
Parameters
Type | Name | Description |
---|---|---|
ICreature | other | The other object to compare against. |
Returns
Type | Description |
---|---|
System.Boolean | True if the current object is equal to the other parameter, false otherwise. |
FindThingAtIndex(Byte)
Attempts to find an IThing whitin this container.
Declaration
public IThing FindThingAtIndex(byte index)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | index | The index at which to look for the IThing. |
Returns
Type | Description |
---|---|
IThing | The IThing found at the index, if any was found. |
RaiseStatChange(CreatureStat, UInt32, Byte)
Raises the StatChanged event for this creature on the given stat.
Declaration
protected void RaiseStatChange(CreatureStat forStat, uint previousLevel, byte previousPercent)
Parameters
Type | Name | Description |
---|---|---|
CreatureStat | forStat | The stat that changed. |
System.UInt32 | previousLevel | The previous stat value. |
System.Byte | previousPercent | The previous percent value of the stat. |
RemoveContent(IThingFactory, ref IThing, Byte, Byte)
Attempts to remove a thing from this container.
Declaration
public (bool result, IThing remainder) RemoveContent(IThingFactory thingFactory, ref IThing thing, byte index = 255, byte amount = 1)
Parameters
Type | Name | Description |
---|---|---|
IThingFactory | thingFactory | A reference to the factory of things to use. |
IThing | thing | The IThing to remove from the container. |
System.Byte | index | Optional. The index from which to remove the IThing. Defaults to byte.MaxValue, which instructs to remove the IThing if found at any index. |
System.Byte | amount | Optional. The amount of the |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, IThing> | A tuple with a value indicating whether the attempt was at least partially successful, and false otherwise. If the result was only partially successful, a remainder of the thing may be returned. |
ReplaceContent(IThingFactory, IThing, IThing, Byte, Byte)
Attempts to replace a IThing from this container with another.
Declaration
public (bool result, IThing remainderToChange) ReplaceContent(IThingFactory thingFactory, IThing fromThing, IThing toThing, byte index = 255, byte amount = 1)
Parameters
Type | Name | Description |
---|---|---|
IThingFactory | thingFactory | A reference to the factory of things to use. |
IThing | fromThing | The IThing to remove from the container. |
IThing | toThing | The IThing to add to the container. |
System.Byte | index | Optional. The index from which to replace the IThing. Defaults to byte.MaxValue, which instructs to replace the IThing if found at any index. |
System.Byte | amount | Optional. The amount of the |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, IThing> | A tuple with a value indicating whether the attempt was at least partially successful, and false otherwise. If the result was only partially successful, a remainder of the thing may be returned. |
StartSensingCreature(ICreature)
Flags a creature as being sensed.
Declaration
public void StartSensingCreature(ICreature creature)
Parameters
Type | Name | Description |
---|---|---|
ICreature | creature | The creature which is sensed. |
StopSensingCreature(ICreature)
Flags a creature as no longed being sensed.
Declaration
public void StopSensingCreature(ICreature creature)
Parameters
Type | Name | Description |
---|---|---|
ICreature | creature | The creature that is lost. |
Events
| Improve this Doc View SourceCreatureLost
Event called when this creature loses track of a sensed creature.
Declaration
public event OnCreatureLost CreatureLost
Event Type
Type | Description |
---|---|
OnCreatureLost |
CreatureSeen
Event called when this creature sees another.
Declaration
public event OnCreatureSeen CreatureSeen
Event Type
Type | Description |
---|---|
OnCreatureSeen |
CreatureSensed
Event called when this creature senses another.
Declaration
public event OnCreatureSensed CreatureSensed
Event Type
Type | Description |
---|---|
OnCreatureSensed |
StatChanged
Event triggered when this creature's stat has changed.
Declaration
public event OnCreatureStatChanged StatChanged
Event Type
Type | Description |
---|---|
OnCreatureStatChanged |