Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.action.Entities.AI.Interaction.NPCInteraction Class Reference
Inheritance diagram for essentials.action.Entities.AI.Interaction.NPCInteraction:
pluginbase.Objects.Game.IPluginExtension essentials.action.Entities.AI.Interaction.INpcInteraction

Public Member Functions

 NPCInteraction ()
 
IEnumerable< IInteractableFindNear (Vector3d pos, double maxDist=MAX_NEAR_DIST)
 Finds an interactable near a position More...
 
IInteractable FindFirstNear (Vector3d pos, double maxDist=MAX_NEAR_DIST)
 Finds the first entity that's interactable near a position More...
 
void InteractNear (IActor me, string key)
 Starts an interaction with an interactable near self More...
 
void InteractNear (IActor me)
 Starts an interaction with an interactable near self More...
 
void InteractWith (IActor me, IInteractable entity, string key)
 Start an interaction between self and another entity with the given conversation key More...
 
void InteractWith (IActor me, IInteractable entity)
 Start an interaction between self an another entity More...
 

Public Attributes

const double MAX_NEAR_DIST = 5.0
 

Properties

IInteractionUI UI [get, set]
 

Detailed Description

Attribute: PluginExtension("ClientInteractable", PluginExtensionScope.Client)

Attribute: Experimental

Constructor & Destructor Documentation

essentials.action.Entities.AI.Interaction.NPCInteraction.NPCInteraction ( )
37  {
38  this.InjectDependencies();
39  _server = _rpcManager.GetClass<NpcInteractionServer>();
40  this.UI = new BasicInteractionUI();
41  }
IInteractionUI UI
Definition: NPCInteraction.cs:34

Member Function Documentation

IInteractable essentials.action.Entities.AI.Interaction.NPCInteraction.FindFirstNear ( Vector3d  pos,
double  maxDist = MAX_NEAR_DIST 
)

Finds the first entity that's interactable near a position

Returns
The first near.
Parameters
posPosition.
maxDistMax dist.

Implements essentials.action.Entities.AI.Interaction.INpcInteraction.

66  {
67  return this.FindNear(pos, maxDist).FirstOrDefault();
68  }
IEnumerable< IInteractable > FindNear(Vector3d pos, double maxDist=MAX_NEAR_DIST)
Finds an interactable near a position
Definition: NPCInteraction.cs:58
IEnumerable<IInteractable> essentials.action.Entities.AI.Interaction.NPCInteraction.FindNear ( Vector3d  pos,
double  maxDist = MAX_NEAR_DIST 
)

Finds an interactable near a position

Returns
The near.
Parameters
posPosition.
maxDistMax dist.

Implements essentials.action.Entities.AI.Interaction.INpcInteraction.

59  {
60  return _entityManager.KnownEntities
61  .OfType<IInteractable>()
62  .Where(x => (pos - x.Position).Length <= maxDist);
63  }
IEnumerable< IEntity > KnownEntities
Returns an enumerable of all entities the game knows about
Definition: ILocalEntities.cs:20
void essentials.action.Entities.AI.Interaction.NPCInteraction.InteractNear ( IActor  me,
string  key 
)

Starts an interaction with an interactable near self

Parameters
meMe.
keyKey.

Implements essentials.action.Entities.AI.Interaction.INpcInteraction.

71  {
72  var with = FindFirstNear(me.Position);
73  if (with != null)
74  {
75  InteractWith(me, with, key);
76  }
77  }
IInteractable FindFirstNear(Vector3d pos, double maxDist=MAX_NEAR_DIST)
Finds the first entity that's interactable near a position
Definition: NPCInteraction.cs:65
void InteractWith(IActor me, IInteractable entity, string key)
Start an interaction between self and another entity with the given conversation key ...
Definition: NPCInteraction.cs:84
Vector3d Position
Gets the position.
Definition: IPositionableEntity.cs:17
void essentials.action.Entities.AI.Interaction.NPCInteraction.InteractNear ( IActor  me)

Starts an interaction with an interactable near self

Parameters
meMe.

Implements essentials.action.Entities.AI.Interaction.INpcInteraction.

80  {
81  InteractNear(me, string.Empty);
82  }
void InteractNear(IActor me, string key)
Starts an interaction with an interactable near self
Definition: NPCInteraction.cs:70
void essentials.action.Entities.AI.Interaction.NPCInteraction.InteractWith ( IActor  me,
IInteractable  entity,
string  key 
)

Start an interaction between self and another entity with the given conversation key

Parameters
meMe.
entityEntity.
keyKey.

Implements essentials.action.Entities.AI.Interaction.INpcInteraction.

85  {
86  _server.Invoke<InteractContract>("Interact", RpcTarget.Server, InteractCallback, me.ObjectId, entity.ObjectId, key);
87  }
void Invoke(string name, RpcTarget target, params object[] args)
Invokes a remoted method by name, at a target
uint ObjectId
Gets the object identifier.
Definition: IEntity.cs:16
static readonly RpcTarget Server
Static that only targets the server
Definition: RpcTarget.cs:174
Class that specifies the target of an RPC class
Definition: RpcTarget.cs:21
void essentials.action.Entities.AI.Interaction.NPCInteraction.InteractWith ( IActor  me,
IInteractable  entity 
)

Start an interaction between self an another entity

Parameters
meMe.
entityEntity.

Implements essentials.action.Entities.AI.Interaction.INpcInteraction.

90  {
91  this.InteractWith(me, entity, string.Empty);
92  }
void InteractWith(IActor me, IInteractable entity, string key)
Start an interaction between self and another entity with the given conversation key ...
Definition: NPCInteraction.cs:84

Member Data Documentation

const double essentials.action.Entities.AI.Interaction.NPCInteraction.MAX_NEAR_DIST = 5.0

Property Documentation

IInteractionUI essentials.action.Entities.AI.Interaction.NPCInteraction.UI
getset

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