Class Operation
Class that represents a common base between game operations.
Inheritance
Inherited Members
Namespace: Fibula.Mechanics.Operations
Assembly: Fibula.Mechanics.dll
Syntax
public abstract class Operation : BaseEvent, IEquatable<BaseEvent>, IOperation, IEvent
Constructors
| Improve this Doc View SourceOperation(UInt32)
Initializes a new instance of the Operation class.
Declaration
protected Operation(uint requestorId)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | requestorId | The id of the creature requesting the movement. |
Properties
| Improve this Doc View SourceAssociatedExhaustion
Gets or sets the information about the exhaustion that this operation produces.
Declaration
public (ConditionType Type, TimeSpan Cost)? AssociatedExhaustion { get; protected set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.ValueTuple<ConditionType, System.TimeSpan>> |
CanBeCancelled
Gets or sets a value indicating whether the event can be cancelled.
Declaration
public override bool CanBeCancelled { get; protected set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
Methods
| Improve this Doc View SourceAddContentToContainerOrFallback(IOperationContext, IThingContainer, ref IThing, Byte, Boolean, ICreature)
Attempts to add content to the first possible parent container that accepts it, on a chain of parent containers.
Declaration
protected bool AddContentToContainerOrFallback(IOperationContext context, IThingContainer thingContainer, ref IThing remainder, byte addIndex = 255, bool includeTileAsFallback = true, ICreature requestorCreature = null)
Parameters
Type | Name | Description |
---|---|---|
IOperationContext | context | A reference to the operation context. |
IThingContainer | thingContainer | The first thing container to add to. |
IThing | remainder | The remainder content to add, which overflows to the next container in the chain. |
System.Byte | addIndex | The index at which to attempt to add, only for the first attempted container. |
System.Boolean | includeTileAsFallback | Optional. A value for whether to include tiles in the fallback chain. |
ICreature | requestorCreature | Optional. The creature requesting the addition of content. |
Returns
Type | Description |
---|---|
System.Boolean | True if the content was successfully added, false otherwise. |
DispatchTextNotification(IOperationContext, String)
Sends a TextMessageNotification to the requestor of the operation, if there is one and it is a player.
Declaration
protected void DispatchTextNotification(IOperationContext context, string message = "Sorry, not possible.")
Parameters
Type | Name | Description |
---|---|---|
IOperationContext | context | A reference to the operation context. |
System.String | message | Optional. The message to send. Defaults to NotPossible. |
Execute(IOperationContext)
Executes the operation's logic.
Declaration
protected abstract void Execute(IOperationContext context)
Parameters
Type | Name | Description |
---|---|---|
IOperationContext | context | The execution context for this operation. |
Execute(IEventContext)
Executes the event logic.
Declaration
public override void Execute(IEventContext context)
Parameters
Type | Name | Description |
---|---|---|
IEventContext | context | The execution context. |
Overrides
| Improve this Doc View SourceGetRequestor(ICreatureFinder)
Gets the creature that is requesting the event, if known.
Declaration
public ICreature GetRequestor(ICreatureFinder creatureFinder)
Parameters
Type | Name | Description |
---|---|---|
ICreatureFinder | creatureFinder | A reference to the creature finder in use. |
Returns
Type | Description |
---|---|
ICreature | The creature that requested the operation, or null if there wasn't any. |
SendNotification(IOperationContext, INotification)
Sends a notification synchronously.
Declaration
protected void SendNotification(IOperationContext context, INotification notification)
Parameters
Type | Name | Description |
---|---|---|
IOperationContext | context | A reference to the operation context. |
INotification | notification | The notification to send. |