Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.action.Entities.AI.AiEntityBase Class Referenceabstract

A FSM (Finite State Machine) implementation of AI More...

Inheritance diagram for essentials.action.Entities.AI.AiEntityBase:
essentials.action.Entities.Actor.PathingEntityBase essentials.action.Entities.Actor.NewtonianBase essentials.action.Entities.Actor.AttachableActorBase essentials.action.Entities.Actor.INewtonianEntity essentials.action.Entities.Actor.IRepulsiveEntity essentials.action.Entities.Actor.ActorBase essentials.action.Entities.Actor.IAttachableActor pluginbase.Objects.Syncable.Entity.IActor pluginbase.Objects.Syncable.Entity.IPositionableEntity pluginbase.Objects.Syncable.Entity.EntityBase pluginbase.Objects.Syncable.Entity.IMutableActor pluginbase.Objects.Syncable.Entity.Controllers.IComponentizedEntity pluginbase.Objects.Syncable.Entity.IActor pluginbase.Objects.Syncable.Entity.Controllers.IModelEntity pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.Entity.IPositionableEntity pluginbase.Objects.Syncable.Entity.Controllers.IModelEntity pluginbase.Objects.Syncable.Entity.Controllers.IHookedEntity pluginbase.Objects.Syncable.Entity.Controllers.ITaskedEntity pluginbase.Objects.Syncable.Entity.IMutableEntity pluginbase.Objects.Syncable.Entity.IActor pluginbase.Objects.Syncable.Entity.Controllers.IRpcEntity pluginbase.Objects.Syncable.Entity.IMutableEntity pluginbase.Objects.Syncable.SyncableObject

Classes

class  FSMInitException
 
class  FSMThoughtException
 

Protected Member Functions

FSMCondition WanderDirection (double time)
 An action that has the entity wander a random direction for an amount of time More...
 
FSMCondition WanderDirection (Rotation2d rotation, double time)
 An action that moves the entity a direction for a given amount of time More...
 
void StopMoving ()
 Stop moving the entity immediately More...
 
FSMCondition MoveNear (Vector3i pos)
 Move the entity to a given point, or as near to it as the world allows More...
 
FSMCondition MoveNear (Vector3d pos)
 Move the entity near to a given position, or as close to it as the world allows More...
 
FSMCondition WhenPosition (Vector3d position, double delta)
 A condition that triggers when the entity's position is within a delta distance of a given position More...
 
FSMCondition WhenPosition (Vector3d position)
 A condition that triggers when the entity is within 2.0 units of a given position More...
 
 AiEntityBase ()
 
abstract void InitConnections ()
 Called after the entity is initialized, but before the entity begins thinking More...
 
virtual void Tick ()
 A method that 'ticks' every second before the entity thinks about its next action More...
 
delegate bool FSMCondition ()
 
delegate FSMCondition FSMNode ()
 
virtual FSMCondition Idle ()
 Special meta-node that the entity will always return to if there are no other connections More...
 
void Connect (FSMNode fromNode, FSMCondition condition, FSMNode toNode, TimeSpan?timeout)
 Connect a given source node to a target node which is traversed when the condition resolves to be true More...
 
void Connect (FSMNode fromNode, FSMCondition condition, FSMNode toNode)
 Connect a given source node to a target node which is traversed when the condition resolves to be true More...
 
void Connect (FSMNode fromNode, FSMNode toNode)
 Connect a given source node to a target node which is traversed More...
 
void ConnectGlobal (FSMCondition condition, FSMNode toNode, bool interupt, TimeSpan?timeout)
 Connect a target node that can be transitioned to from any other state when a condition is met More...
 
void ConnectGlobal (FSMCondition condition, FSMNode toNode, bool interupt)
 Connect a target node that can be transitioned to from any other state when a condition is met More...
 
void ConnectGlobal (FSMCondition condition, FSMNode toNode)
 Connect a target node that can be transitioned to from any other state when a condition is met More...
 
void Queue (FSMCondition condition, FSMNode toNode)
 Connect to a target node when a condition is met, but only execute it a single time and then remove the connection More...
 
void Queue (FSMNode toNode)
 Connect to a target node, but only execute it a single time and then remove the connection More...
 
void Describe (FSMNode node, string name)
 Give a node a name for easier interpretation More...
 
void Interupt ()
 Stop the current action and return to idle More...
 
string ToDebugString ()
 Creates a debug string that represents the current FSM More...
 
- Protected Member Functions inherited from essentials.action.Entities.Actor.PathingEntityBase
virtual void OnPathStart (Path path)
 
virtual void OnPathNotFound ()
 
virtual void OnPathFinished ()
 
virtual void OnPathFailed ()
 
void MoveTo (Vector3i pos)
 
void StopPath ()
 
- Protected Member Functions inherited from essentials.action.Entities.Actor.NewtonianBase
virtual void SimulateClientPhysics (IFrameTimeState frameTime)
 
virtual void SimulateAudio (IFrameTimeState frameTime)
 
virtual bool ShouldOverrideAnimation (ModelAnimation animation)
 
virtual ModelAnimation GetAnimation ()
 
void SetAnimation (ModelAnimation animation)
 
void SetAnimation (string slug)
 
bool DoesCollide (Vector3d pos, double heightOffset=0.5)
 Detects whether or not the entity will collide with a block at a given point More...
 
void AddPhysicalVelocity (Vector3d vel)
 
virtual void OnCollided (Vector3d velDiff)
 
virtual void SimulateServerPhysics (IFrameTimeState timeState)
 
- Protected Member Functions inherited from essentials.action.Entities.Actor.AttachableActorBase
 AttachableActorBase ()
 
IActor GetAttachedActor ()
 
void AttachTo (uint actorId)
 
void AttachTo (IActor actor)
 
void Detach ()
 
- Protected Member Functions inherited from essentials.action.Entities.Actor.ActorBase
sealed override bool ShouldSyncWith (IPositionableEntity user)
 Gets whether or not the entity shuold sync with another entity More...
 
abstract IModelInstance CreateModel ()
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.Entity.EntityBase
void SetTransient (bool isTransient=true)
 Sets whether or not the entity will be persisted Transient entities will not be persisted More...
 
virtual void OnServerSpawn ()
 Raises the server spawn event. Will only be called once, even across reloads More...
 
virtual void OnServerDestroy ()
 Raises the server destroy event. More...
 
void InvokeRemotely (string methodName, RpcTarget target, params object[] args)
 Invoke a remote method on a target More...
 
void InvokeRemotely< T > (string methodName, RpcTarget target, Action< RpcNetworkContext, T > returnCallback, params object[] args)
 Invoke a remote method on a target More...
 
void InvokeRemotely< T > (string methodName, RpcTarget target, Action< T > returnCallback, params object[] args)
 Invoke a remote method on a target More...
 
void InvokeDirect (string methodName, params object[] args)
 Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server More...
 
void InvokeDirect< T > (string methodName, Action< RpcNetworkContext, T > returnCallback, params object[] args)
 Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server More...
 
void InvokeDirect< T > (string methodName, Action< T > returnCallback, params object[] args)
 Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server More...
 
void InvokeDirect (Expression< Action > thisExpression)
 Invokes a method on the opposite-owner. Action must act upon this More...
 
void InvokeDirect< TRet > (Expression< Func< TRet >> thisExpression, Action< TRet > returnCallback)
 Invokes a method on the opposite-owner. Action must act upon this More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableObject
sealed override void ResetWatch ()
 Reset variables watched status More...
 
sealed override void TouchRecurse ()
 Touch self, including all children of this syncable object More...
 
sealed override void EncodeTo (BinaryWriter writer, EncodeContext context)
 Encode changes to binary data More...
 
sealed override void DecodeFrom (BinaryReader reader, DecodeContext context)
 Decode changes from binary data More...
 
sealed override void Persist (IPersistObject obj)
 Build up a persistant object for this syncable, including all sync children and persist objects More...
 
sealed override void Load (IReadPersistObject obj)
 Load a given persistent object back into this instance More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableBase< T >
void Touch ()
 Touch the instance, notifying something has changed More...
 
virtual void OnChanged ()
 Raises the changed event. More...
 

Static Protected Member Functions

static FSMCondition WhenWait (TimeSpan time)
 A condition that will trigger after a specified time has passed More...
 
static FSMCondition WhenWait (double seconds)
 A condition that will trigger after a specified number of seconds has passed More...
 
static FSMCondition WhenRandom (double likelihood)
 A condition that will trigger when a random value on a given tick falls below a likelihood More...
 
static bool Always ()
 A condition that always triggers immediately More...
 
static bool Never ()
 A condition that never triggers More...
 

Static Protected Attributes

static readonly TimeSpan DEFAULT_TIMEOUT = TimeSpan.FromSeconds(30)
 

Additional Inherited Members

- Public Member Functions inherited from essentials.action.Entities.Actor.PathingEntityBase
 PathingEntityBase ()
 
- Public Member Functions inherited from essentials.action.Entities.Actor.NewtonianBase
 NewtonianBase ()
 
- Public Member Functions inherited from essentials.action.Entities.Actor.ActorBase
virtual void SetPosition (double x, double y, double z)
 Sets the position. More...
 
virtual void SetName (string name)
 
- Public Member Functions inherited from pluginbase.Objects.Syncable.Entity.EntityBase
void Destroy ()
 Marks the entity for destruction More...
 
override string ToString ()
 Gets a human-readable string representing an entity More...
 
- Public Member Functions inherited from pluginbase.Objects.Syncable.SyncableObject
 SyncableObject ()
 Initializes a new instance of the pluginbase.Objects.Syncable.SyncableObject class. More...
 
- Protected Attributes inherited from essentials.action.Entities.Actor.NewtonianBase
readonly IWorld World
 
readonly IResourceResolver EssentialsActionResources
 
readonly IBlockLookup BlockLookup
 
readonly Sync< Vector3d > UserVelocity
 
readonly Sync< Vector3d > Acceleration
 
Vector3d RequestedVelocity
 The requested velocity to be traveling Will apply if physically makes sense More...
 
Vector3d RequestedAcceleration
 Requested acceleration More...
 
- Properties inherited from essentials.action.Entities.Actor.PathingEntityBase
bool IsFollowingPath [get]
 
virtual double Speed [get]
 
- Properties inherited from essentials.action.Entities.Actor.NewtonianBase
IBlockAudioManager AudioBlocks [get]
 
IAudioManager AudioManager [get]
 
virtual SoundDescriptor FallingWindSound [get]
 
virtual double FallingWindVelocity [get]
 
virtual bool HasGravity [get]
 Gets a value indicating whether this instance has gravity. Defaults always true More...
 
IBlock HeadBlock [get]
 
IBlock OnBlock [get]
 
virtual bool OnGround [get]
 Gets a value indicating whether this user on ground. More...
 
virtual bool InLiquid [get]
 
virtual bool IsUnderwater [get]
 
virtual bool InClimbable [get]
 
virtual double EntityHeight [get]
 Gets the height of the entity. More...
 
virtual double EntityRepulsionStrength [get]
 Strength at which another entity is repulsed by this one More...
 
virtual double EntityRepulsiveModifier [get]
 The multiplicative modifier of which a repulsive entities' strength is multiplied More...
 
virtual double EntityRadius [get]
 Gets the entity radius. Used in collision More...
 
virtual double UserVelocityAcceleration [get]
 How fast can the user velocity change More...
 
virtual double UserVelocityMultiplier [get]
 How much does the user velocity affect the physical engine. Defaults to full on ground, none in air More...
 
virtual double UserAccelerationMultiplier [get]
 How much does the requested acceleration affect the game physics More...
 
virtual double ClientMovementUpdateTolerance [get]
 
Vector3d GravityVector [get]
 
virtual double Density [get]
 
Vector3d Velocity [get]
 Calculated velocity More...
 
- Properties inherited from essentials.action.Entities.Actor.AttachableActorBase
sealed override Vector3d Position [get, protected set]
 
Vector3d RelativePosition [get, protected set]
 
sealed override Rotation2d Rotation [get, protected set]
 
bool IsAttached [get]
 
- Properties inherited from essentials.action.Entities.Actor.ActorBase
virtual Vector3d Position [get, protected set]
 
bool PositionFinishedInterpolating [get]
 
virtual Rotation2d Rotation [get, protected set]
 
bool IsPlayer [get]
 
bool IsMe [get]
 
string Name [get, protected set]
 
virtual string NamePlate [get]
 
virtual double NamePlateViewDistance [get]
 
virtual Vector3d NamePlateOffset [get]
 
virtual double SyncDistance [get]
 
virtual Vector3d UpVector [get]
 
IModelInstance Model [get]
 
virtual bool Visible [get]
 
virtual bool CastShadow [get]
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.EntityBase
bool Spawned [get]
 Gets a value indicating whether this entity has been spawned More...
 
uint ObjectId [get]
 Gets or sets the object identifier. More...
 
ushort OwnerId [get]
 The ident of the owner of the obejct More...
 
sealed override ushort NetOwnerId [get]
 Who owns me?! (Net ID) This is how we pass information down to SyncableObject More...
 
bool IsServer [get]
 Is the current object instantiated on the server More...
 
ushort ObjectTypeId [get]
 The type ID of the object, as defined by the entity attribute More...
 
- Properties inherited from pluginbase.Objects.Syncable.SyncableObject
virtual ushort NetOwnerId [get]
 Gets the network owner of this object (user id) More...
 
- Properties inherited from pluginbase.Objects.Syncable.INetSyncable
INetWatcher Watcher [get, set]
 Who is watching (who to inform of a change) More...
 
bool Modified [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.INetSyncable is modified. More...
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.IEntity
uint ObjectId [get]
 Gets the object identifier. More...
 
ushort OwnerId [get]
 Gets the owner identifier. (Net Ident) More...
 
ushort ObjectTypeId [get]
 Gets the object type identifier, as defined by the attribute More...
 
bool DestroyFlag [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.Entity.IEntity is destroyable. More...
 
bool Spawned [get]
 Gets a value indicating whether this entity has been spawned More...
 
bool Transient [get]
 Gets a value indicating whether this entity is transient (Won't be saved) More...
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.IMutableActor
bool IsPlayer [set]
 
bool IsMe [set]
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.IActor
string Name [get]
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.Controllers.IModelEntity
IModelInstance Model [get]
 The instance of the model used for the entity More...
 
string NamePlate [get]
 The name plate displayed for the entity, if any More...
 
double NamePlateViewDistance [get]
 The distance the name plate can be viewed from More...
 
Vector3d NamePlateOffset [get]
 The offset of the nameplate from the position of the entity More...
 
bool Visible [get]
 Gets a value indicating whether the entity is visible More...
 
bool CastShadow [get]
 Gets a value indiciating whether the entity casts a shadow More...
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.IPositionableEntity
Vector3d Position [get]
 Gets the position. More...
 
Vector3d UpVector [get]
 Gets up vector. More...
 
Rotation2d Rotation [get]
 Gets the rotation. More...
 
- Properties inherited from essentials.action.Entities.Actor.IAttachableActor
bool IsAttached [get]
 Is attached to another entity More...
 
- Properties inherited from essentials.action.Entities.Actor.INewtonianEntity
Vector3d Velocity [get]
 
Vector3d Acceleration [get]
 
double EntityHeight [get]
 
double EntityRadius [get]
 
- Properties inherited from essentials.action.Entities.Actor.IRepulsiveEntity
double EntityRepulsionStrength [get]
 Linear strength at which this entity is repulsed by another More...
 
- Events inherited from pluginbase.Objects.Syncable.SyncableBase< T >
Action< T > Changed
 Event triggered when any change occurs on this object, either locally or over the network More...
 
Action< T > NetUpdate
 Event triggered when a change occurs resulting from a change over the network More...
 
Action< T > Touched
 Event occurs only when an object is first touched. Usually the first instance of a local-change More...
 

Detailed Description

A FSM (Finite State Machine) implementation of AI

Constructor & Destructor Documentation

essentials.action.Entities.AI.AiEntityBase.AiEntityBase ( )
protected
28  {
29  this.InjectDependencies();
30  }

Member Function Documentation

static bool essentials.action.Entities.AI.AiEntityBase.Always ( )
staticprotected

A condition that always triggers immediately

45  {
46  return true;
47  }
void essentials.action.Entities.AI.AiEntityBase.Connect ( FSMNode  fromNode,
FSMCondition  condition,
FSMNode  toNode,
TimeSpan?  timeout 
)
protected

Connect a given source node to a target node which is traversed when the condition resolves to be true

Parameters
fromNodeThe source node
conditionCondition to be satisfied to transition to this ndoe
toNodeThe target node
timeoutThe max amount of time the target node can run before returning to idle
146  {
147  Connect(fromNode, condition, toNode, timeout, false, false);
148  }
void essentials.action.Entities.AI.AiEntityBase.Connect ( FSMNode  fromNode,
FSMCondition  condition,
FSMNode  toNode 
)
protected

Connect a given source node to a target node which is traversed when the condition resolves to be true

Parameters
fromNodeThe source node
conditionCondition to be satisfied to transition to this ndoe
toNodeThe target node
157  {
158  Connect(fromNode, condition, toNode, null);
159  }
void essentials.action.Entities.AI.AiEntityBase.Connect ( FSMNode  fromNode,
FSMNode  toNode 
)
protected

Connect a given source node to a target node which is traversed

Parameters
fromNodeThe source node
toNodeThe target node
167  {
168  Connect(fromNode, Always, toNode);
169  }
static bool Always()
A condition that always triggers immediately
Definition: AiEntityBase.Conditions.cs:44
void essentials.action.Entities.AI.AiEntityBase.ConnectGlobal ( FSMCondition  condition,
FSMNode  toNode,
bool  interupt,
TimeSpan?  timeout 
)
protected

Connect a target node that can be transitioned to from any other state when a condition is met

Parameters
conditionCondition to resolve to travel to this node
toNodeTarget node
interuptIf set to true, will interrupt already running nodes
timeoutThe time before a given target node is abandoned
179  {
180  Connect(Node_Global, condition, toNode, timeout, interupt, false);
181  }
void essentials.action.Entities.AI.AiEntityBase.ConnectGlobal ( FSMCondition  condition,
FSMNode  toNode,
bool  interupt 
)
protected

Connect a target node that can be transitioned to from any other state when a condition is met

Parameters
conditionCondition to resolve to travel to this node
toNodeTarget node
interuptIf set to true, will interrupt already running nodes
190  {
191  ConnectGlobal(condition, toNode, interupt, null);
192  }
void ConnectGlobal(FSMCondition condition, FSMNode toNode, bool interupt, TimeSpan?timeout)
Connect a target node that can be transitioned to from any other state when a condition is met ...
Definition: AiEntityBase.cs:178
void essentials.action.Entities.AI.AiEntityBase.ConnectGlobal ( FSMCondition  condition,
FSMNode  toNode 
)
protected

Connect a target node that can be transitioned to from any other state when a condition is met

Parameters
conditionCondition to resolve to travel to this node
toNodeTarget node
200  {
201  ConnectGlobal(condition, toNode, false, null);
202  }
void ConnectGlobal(FSMCondition condition, FSMNode toNode, bool interupt, TimeSpan?timeout)
Connect a target node that can be transitioned to from any other state when a condition is met ...
Definition: AiEntityBase.cs:178
void essentials.action.Entities.AI.AiEntityBase.Describe ( FSMNode  node,
string  name 
)
protected

Give a node a name for easier interpretation

Parameters
nodeThe Node.
nameName.
229  {
230  GetOrCreateNode(node).Name = name;
231  }
delegate bool essentials.action.Entities.AI.AiEntityBase.FSMCondition ( )
protected
delegate FSMCondition essentials.action.Entities.AI.AiEntityBase.FSMNode ( )
protected
virtual FSMCondition essentials.action.Entities.AI.AiEntityBase.Idle ( )
protectedvirtual

Special meta-node that the entity will always return to if there are no other connections

Attribute: FSMNode("__idle")

104  { return null; }
abstract void essentials.action.Entities.AI.AiEntityBase.InitConnections ( )
protectedpure virtual

Called after the entity is initialized, but before the entity begins thinking

void essentials.action.Entities.AI.AiEntityBase.Interupt ( )
protected

Stop the current action and return to idle

246  {
247  this.ClearState();
248  ActivateNode(Idle);
249  _stateTimeout = DateTime.MaxValue;
250  }
virtual FSMCondition Idle()
Special meta-node that the entity will always return to if there are no other connections ...
Definition: AiEntityBase.cs:103
FSMCondition essentials.action.Entities.AI.AiEntityBase.MoveNear ( Vector3i  pos)
protected

Move the entity to a given point, or as near to it as the world allows

Returns
A condition that resolves when the entity has either completed moving.
Parameters
posThe position to move to.
49  {
50  const int MAX_SEARCH = 32;
51  Vector3i target = pos;
52  if (this.World.GetIBlock(pos).Solid)
53  {
54  // Look up until open
55  for (int i=1; i<MAX_SEARCH; ++i)
56  {
57  var newPos = pos + Vector3i.UnitZ * i;
58  if (!this.World.GetIBlock(newPos).Solid)
59  {
60  target = newPos;
61  break;
62  }
63  }
64  }
65  else
66  {
67  // Look down until solid
68  for (int i=1; i<MAX_SEARCH; ++i)
69  {
70  var newPos = pos - Vector3i.UnitZ * i;
71  if (this.World.GetIBlock(newPos).Solid)
72  target = newPos + Vector3i.UnitZ;
73  }
74  }
75 
76  this.MoveTo(target);
77  return () => this.IsFollowingPath;
78  }
bool IsFollowingPath
Definition: PathingEntityBase.cs:46
readonly IWorld World
Definition: NewtonianBase.cs:20
static readonly Vector3i UnitZ
Vector (0,0,1)
Definition: Vector3i.cs:79
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
void MoveTo(Vector3i pos)
Definition: PathingEntityBase.cs:57
FSMCondition essentials.action.Entities.AI.AiEntityBase.MoveNear ( Vector3d  pos)
protected

Move the entity near to a given position, or as close to it as the world allows

Returns
A condition that resolves when the entity is done moving
Parameters
posPosition to move to
86  {
87  return this.MoveNear((Vector3i)pos);
88  }
FSMCondition MoveNear(Vector3i pos)
Move the entity to a given point, or as near to it as the world allows
Definition: AiEntityBase.Actions.cs:48
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
static bool essentials.action.Entities.AI.AiEntityBase.Never ( )
staticprotected

A condition that never triggers

53  {
54  return false;
55  }
void essentials.action.Entities.AI.AiEntityBase.Queue ( FSMCondition  condition,
FSMNode  toNode 
)
protected

Connect to a target node when a condition is met, but only execute it a single time and then remove the connection

Parameters
conditionCondition to resolve to travel to this node
toNodeTarget node
210  {
211  Connect(Idle, condition, toNode, null, false, true);
212  }
virtual FSMCondition Idle()
Special meta-node that the entity will always return to if there are no other connections ...
Definition: AiEntityBase.cs:103
void essentials.action.Entities.AI.AiEntityBase.Queue ( FSMNode  toNode)
protected

Connect to a target node, but only execute it a single time and then remove the connection

Parameters
toNodeTarget node
219  {
220  Queue(Always, toNode);
221  }
void Queue(FSMCondition condition, FSMNode toNode)
Connect to a target node when a condition is met, but only execute it a single time and then remove t...
Definition: AiEntityBase.cs:209
static bool Always()
A condition that always triggers immediately
Definition: AiEntityBase.Conditions.cs:44
void essentials.action.Entities.AI.AiEntityBase.StopMoving ( )
protected

Stop moving the entity immediately

37  {
38  this.RequestedVelocity = Vector3d.Zero;
39  this.RequestedAcceleration = Vector3d.Zero;
40  this.StopPath();
41  }
void StopPath()
Definition: PathingEntityBase.cs:73
Vector3d RequestedAcceleration
Requested acceleration
Definition: NewtonianBase.cs:658
Vector3d RequestedVelocity
The requested velocity to be traveling Will apply if physically makes sense
Definition: NewtonianBase.cs:653
virtual void essentials.action.Entities.AI.AiEntityBase.Tick ( )
protectedvirtual

A method that 'ticks' every second before the entity thinks about its next action

42 {}
string essentials.action.Entities.AI.AiEntityBase.ToDebugString ( )
protected

Creates a debug string that represents the current FSM

Returns
The debug string.
359  {
360  var writer = new StringWriter();
361 
362  writer.WriteLine("Entity: {0}", this.ToString());
363  foreach(var node in _nodes)
364  {
365  writer.WriteLine(" {0}{1}({2}); Hits: {3} Connections: {4}",
366  _stateNode == node.Key ? "***" : string.Empty,
367  node.Value.Name,
368  node.Key.Method.Name,
369  node.Value.Hits,
370  node.Value.Connections.Count);
371  foreach(var connection in node.Value.Connections)
372  {
373  writer.WriteLine(" -> {0} when {1}. Traversed {2} times", GetNodeName(connection.Target), connection.Condition.Method.Name, connection.TraverseCount);
374  }
375  }
376 
377  return writer.ToString();
378  }
override string ToString()
Gets a human-readable string representing an entity
Definition: EntityBase.cs:344
FSMCondition essentials.action.Entities.AI.AiEntityBase.WanderDirection ( double  time)
protected

An action that has the entity wander a random direction for an amount of time

Returns
A condition that resolves when the time has expired
Parameters
timeTime.
16  {
17  return WanderDirection(new Rotation2d(0.0, _random.NextDouble() * MathHelper.TwoPi), time);
18  }
Rotation XZ; In radians
Definition: Rotation2d.cs:10
FSMCondition WanderDirection(double time)
An action that has the entity wander a random direction for an amount of time
Definition: AiEntityBase.Actions.cs:15
FSMCondition essentials.action.Entities.AI.AiEntityBase.WanderDirection ( Rotation2d  rotation,
double  time 
)
protected

An action that moves the entity a direction for a given amount of time

Returns
A condition that resolves when the time has expired.
Parameters
rotationRotation.
timeTime.
27  {
28  this.Rotation = rotation;
29  this.RequestedVelocity = rotation.VectorZAxis * this.Speed;
30  return WhenWait(time);
31  }
Vector3d VectorZAxis
Definition: Rotation2d.cs:72
Vector3d RequestedVelocity
The requested velocity to be traveling Will apply if physically makes sense
Definition: NewtonianBase.cs:653
virtual double Speed
Definition: PathingEntityBase.cs:103
static FSMCondition WhenWait(TimeSpan time)
A condition that will trigger after a specified time has passed
Definition: AiEntityBase.Conditions.cs:15
sealed override Rotation2d Rotation
Definition: AttachableActorBase.cs:47
FSMCondition essentials.action.Entities.AI.AiEntityBase.WhenPosition ( Vector3d  position,
double  delta 
)
protected

A condition that triggers when the entity's position is within a delta distance of a given position

Returns
The position.
Parameters
positionPosition.
deltaDelta
64  {
65  return () => (this.Position - position).Length <= delta;
66  }
float Length
Gets the length of the vector
Definition: Vector3i.cs:165
sealed override Vector3d Position
Definition: AttachableActorBase.cs:23
FSMCondition essentials.action.Entities.AI.AiEntityBase.WhenPosition ( Vector3d  position)
protected

A condition that triggers when the entity is within 2.0 units of a given position

Returns
The position.
Parameters
positionPosition.
74  {
75  return WhenPosition(position, 2.0);
76  }
FSMCondition WhenPosition(Vector3d position, double delta)
A condition that triggers when the entity's position is within a delta distance of a given position ...
Definition: AiEntityBase.Conditions.cs:63
static FSMCondition essentials.action.Entities.AI.AiEntityBase.WhenRandom ( double  likelihood)
staticprotected

A condition that will trigger when a random value on a given tick falls below a likelihood

Returns
The random.
Parameters
likelihoodLikelihood.
37  {
38  return () => _random.NextDouble() < likelihood;
39  }
static FSMCondition essentials.action.Entities.AI.AiEntityBase.WhenWait ( TimeSpan  time)
staticprotected

A condition that will trigger after a specified time has passed

Returns
The wait.
Parameters
timeTime.
16  {
17  var endWait = DateTime.UtcNow + time;
18  return () => DateTime.UtcNow >= endWait;
19  }
static FSMCondition essentials.action.Entities.AI.AiEntityBase.WhenWait ( double  seconds)
staticprotected

A condition that will trigger after a specified number of seconds has passed

Returns
The wait.
Parameters
secondsSeconds.
27  {
28  return WhenWait(TimeSpan.FromSeconds(seconds));
29  }
static FSMCondition WhenWait(TimeSpan time)
A condition that will trigger after a specified time has passed
Definition: AiEntityBase.Conditions.cs:15

Member Data Documentation

readonly TimeSpan essentials.action.Entities.AI.AiEntityBase.DEFAULT_TIMEOUT = TimeSpan.FromSeconds(30)
staticprotected

The documentation for this class was generated from the following files: