Class Game
Class that represents the game instance.
Inheritance
Implements
Inherited Members
Namespace: Fibula.Mechanics
Assembly: Fibula.Mechanics.dll
Syntax
public class Game : IGame, IHostedService, IGameOperationsApi, ICombatOperationsApi
Constructors
| Improve this Doc View SourceGame(ILogger, IApplicationContext, IMapDescriptor, IMap, ICreatureManager, IItemFactory, ICreatureFactory, IContainerManager, IPathFinder, IPredefinedItemSet, IMonsterSpawnLoader, IScheduler)
Initializes a new instance of the Game class.
Declaration
public Game(ILogger logger, IApplicationContext applicationContext, IMapDescriptor mapDescriptor, IMap map, ICreatureManager creatureManager, IItemFactory itemFactory, ICreatureFactory creatureFactory, IContainerManager containerManager, IPathFinder pathFinderAlgo, IPredefinedItemSet predefinedItemSet, IMonsterSpawnLoader monsterSpawnsLoader, IScheduler scheduler)
Parameters
Type | Name | Description |
---|---|---|
Serilog.ILogger | logger | A reference to the logger in use. |
IApplicationContext | applicationContext | A reference to the application context. |
IMapDescriptor | mapDescriptor | A reference to the map descriptor in use. |
IMap | map | A reference to the map. |
ICreatureManager | creatureManager | A reference to the creature manager in use. |
IItemFactory | itemFactory | A reference to the item factory in use. |
ICreatureFactory | creatureFactory | A reference to the creature factory in use. |
IContainerManager | containerManager | A reference to the container manager in use. |
IPathFinder | pathFinderAlgo | A reference to the path finding algorithm in use. |
IPredefinedItemSet | predefinedItemSet | A reference to the predefined item set declared. |
IMonsterSpawnLoader | monsterSpawnsLoader | A reference to the monster spawns loader. |
IScheduler | scheduler | A reference to the global scheduler instance. |
Properties
| Improve this Doc View SourceWorldInfo
Gets the game world's information.
Declaration
public IWorldInformation WorldInfo { get; }
Property Value
Type | Description |
---|---|
IWorldInformation |
Methods
| Improve this Doc View SourceAfterThingLocationChanged(IThing, Location)
Handles the aftermath of a location change from a thing.
Declaration
public void AfterThingLocationChanged(IThing thing, Location previousLocation)
Parameters
Type | Name | Description |
---|---|---|
IThing | thing | The thing which's location changed. |
Location | previousLocation | The previous location of the thing. |
CancelPlayerActions(IPlayer, Type, Boolean)
Cancels all actions that a player has pending.
Declaration
public void CancelPlayerActions(IPlayer player, Type typeOfActionToCancel = null, bool async = false)
Parameters
Type | Name | Description |
---|---|---|
IPlayer | player | The player to cancel actions for. |
System.Type | typeOfActionToCancel | Optional. The specific type of action to cancel. |
System.Boolean | async | Optional. A value indicating whether to execute the cancellation asynchronously. |
CombatantAttackTargetChanged(ICombatant, ICombatant)
Handles an attack target change from a combatant.
Declaration
public void CombatantAttackTargetChanged(ICombatant combatant, ICombatant oldTarget)
Parameters
Type | Name | Description |
---|---|---|
ICombatant | combatant | The combatant that died. |
ICombatant | oldTarget | The previous attack target, which can be null. |
CombatantDeath(ICombatant)
Handles the death of a combatant.
Declaration
public void CombatantDeath(ICombatant combatant)
Parameters
Type | Name | Description |
---|---|---|
ICombatant | combatant | The combatant that died. |
CreateItemAtLocation(Location, IItemTypeEntity, (ItemAttribute, IConvertible)[])
Creates item at the specified location.
Declaration
public void CreateItemAtLocation(Location location, IItemTypeEntity itemType, params (ItemAttribute, IConvertible)[] additionalAttributes)
Parameters
Type | Name | Description |
---|---|---|
Location | location | The location at which to create the item. |
IItemTypeEntity | itemType | The type of item to create. |
System.ValueTuple<ItemAttribute, System.IConvertible>[] | additionalAttributes | Optional. Additional item attributes to set on the new item. |
CreateItemAtLocation(Location, UInt16, (ItemAttribute, IConvertible)[])
Creates a new item at the specified location.
Declaration
public void CreateItemAtLocation(Location location, ushort itemTypeId, params (ItemAttribute, IConvertible)[] additionalAttributes)
Parameters
Type | Name | Description |
---|---|---|
Location | location | The location at which to create the item. |
System.UInt16 | itemTypeId | The type id of the item to create. |
System.ValueTuple<ItemAttribute, System.IConvertible>[] | additionalAttributes | Optional. Additional item attributes to set on the new item. |
CreatureFollowTargetChanged(ICombatant, ICreature)
Handles a follow target change from a combatant.
Declaration
public void CreatureFollowTargetChanged(ICombatant combatant, ICreature oldTarget)
Parameters
Type | Name | Description |
---|---|---|
ICombatant | combatant | The creature that changed follow target. |
ICreature | oldTarget | The old follow target, if any. |
CreatureHasLostCreature(ICreatureThatSensesOthers, ICreature)
Handles the event when a creature has lost another creature.
Declaration
public void CreatureHasLostCreature(ICreatureThatSensesOthers creature, ICreature creatureLost)
Parameters
Type | Name | Description |
---|---|---|
ICreatureThatSensesOthers | creature | The monster that sees the other. |
ICreature | creatureLost | The creature that was lost. |
CreatureHasSeenCreature(ICreatureThatSensesOthers, ICreature)
Handles the event when a creature has seen another creature.
Declaration
public void CreatureHasSeenCreature(ICreatureThatSensesOthers creature, ICreature creatureSeen)
Parameters
Type | Name | Description |
---|---|---|
ICreatureThatSensesOthers | creature | The monster that sees the other. |
ICreature | creatureSeen | The creature that was seen. |
CreatureSpeech(UInt32, SpeechType, ChatChannelType, String, String)
Handles creature speech.
Declaration
public void CreatureSpeech(uint creatureId, SpeechType speechType, ChatChannelType channelType, string content, string receiver = "")
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | creatureId | The id of the creature. |
SpeechType | speechType | The type of speech. |
ChatChannelType | channelType | The type of channel of the speech. |
System.String | content | The content of the speech. |
System.String | receiver | Optional. The receiver of the speech, if any. |
CreatureStatChanged(ICreature, IStat, UInt32, Byte)
Handles a stat change event from a creature.
Declaration
public void CreatureStatChanged(ICreature creature, IStat statThatChanged, uint previousValue, byte previousPercent)
Parameters
Type | Name | Description |
---|---|---|
ICreature | creature | The creature for which the stat changed. |
IStat | statThatChanged | The stat that changed. |
System.UInt32 | previousValue | The previous stat value. |
System.Byte | previousPercent | The previous percent for the stat. |
CreatureTurn(UInt32, ICreature, Direction)
Turns a creature to a direction.
Declaration
public void CreatureTurn(uint requestorId, ICreature creature, Direction direction)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | requestorId | The id of the creature. |
ICreature | creature | The creature to turn. |
Direction | direction | The direction to turn to. |
LogPlayerIn(IClient, ICreatureCreationMetadata)
Logs a player into the game.
Declaration
public void LogPlayerIn(IClient client, ICreatureCreationMetadata creatureCreationMetadata)
Parameters
Type | Name | Description |
---|---|---|
IClient | client | The client from which the player is connecting. |
ICreatureCreationMetadata | creatureCreationMetadata | The metadata for the player's creation. |
LogPlayerOut(IPlayer)
Logs a player out of the game.
Declaration
public void LogPlayerOut(IPlayer player)
Parameters
Type | Name | Description |
---|---|---|
IPlayer | player | The player to log out. |
LookAt(UInt16, Location, Byte, IPlayer)
Describes a thing for a player that is looking at it.
Declaration
public void LookAt(ushort thingId, Location location, byte stackPosition, IPlayer player)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | thingId | The id of the thing to describe. |
Location | location | The location of the thing to describe. |
System.Byte | stackPosition | The position in the stack within the location of the thing to describe. |
IPlayer | player | The player for which to describe the thing for. |
Movement(UInt32, UInt16, Location, Byte, UInt32, Location, UInt32, Byte)
Moves a thing.
Declaration
public void Movement(uint requestorId, ushort clientThingId, Location fromLocation, byte fromIndex, uint fromCreatureId, Location toLocation, uint toCreatureId, byte amount = 1)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | requestorId | The id of the creature requesting the move. |
System.UInt16 | clientThingId | The id of the thing being moved. |
Location | fromLocation | The location from which the thing is being moved. |
System.Byte | fromIndex | The index within the location from which the thing is being moved. |
System.UInt32 | fromCreatureId | The id of the creature from which the thing is being moved, if any. |
Location | toLocation | The location to which the thing is being moved. |
System.UInt32 | toCreatureId | The id of the creature to which the thing is being moved. |
System.Byte | amount | Optional. The amount of the thing to move. Defaults to 1. |
PlaceMonsterAt(String, Location)
Places a new monster of the given race, at the given location.
Declaration
public void PlaceMonsterAt(string raceId, Location location)
Parameters
Type | Name | Description |
---|---|---|
System.String | raceId | The id of race of monster to place. |
Location | location | The location at which to place the monster. |
ResetCreatureDynamicWalkPlan(ICreature, ICreature, WalkPlanStrategy, Int32, Boolean)
Resets a given creature's walk plan and kicks it off.
Declaration
public void ResetCreatureDynamicWalkPlan(ICreature creature, ICreature targetCreature, WalkPlanStrategy strategy = WalkPlanStrategy.ConservativeRecalculation, int targetDistance = 1, bool excludeCurrentLocation = false)
Parameters
Type | Name | Description |
---|---|---|
ICreature | creature | The creature to reset the walk plan of. |
ICreature | targetCreature | The creature towards which the walk plan will be generated to. |
WalkPlanStrategy | strategy | Optional. The strategy to follow in the plan. |
System.Int32 | targetDistance | Optional. The target distance to calculate from the target creature. |
System.Boolean | excludeCurrentLocation | Optional. A value indicating whether to exclude the current creature's location from being the goal location. |
ResetCreatureStaticWalkPlan(ICreature, Direction[], WalkPlanStrategy)
Resets a given creature's walk plan and kicks it off.
Declaration
public void ResetCreatureStaticWalkPlan(ICreature creature, Direction[] directions, WalkPlanStrategy strategy = WalkPlanStrategy.DoNotRecalculate)
Parameters
Type | Name | Description |
---|---|---|
ICreature | creature | The creature to reset the walk plan of. |
Direction[] | directions | The directions for the new plan. |
WalkPlanStrategy | strategy | Optional. The strategy to follow in the plan. |
SendHeartbeat(IPlayer)
Sends a heartbeat to the player's client.
Declaration
public void SendHeartbeat(IPlayer player)
Parameters
Type | Name | Description |
---|---|---|
IPlayer | player | The player which to send the heartbeat to. |
SendHeartbeatResponse(IPlayer)
Sends a heartbeat response to the player's client.
Declaration
public void SendHeartbeatResponse(IPlayer player)
Parameters
Type | Name | Description |
---|---|---|
IPlayer | player | The player which to send the heartbeat response to. |
SetCombatantAttackTarget(ICombatant, ICombatant)
Re-sets the attack target of the attacker and it's (possibly new) target.
Declaration
public void SetCombatantAttackTarget(ICombatant attacker, ICombatant target)
Parameters
Type | Name | Description |
---|---|---|
ICombatant | attacker | The attacker. |
ICombatant | target | The new target. |
SetCombatantFollowTarget(ICombatant, ICombatant)
Re-sets the follow target of the combatant and it's (possibly new) target.
Declaration
public void SetCombatantFollowTarget(ICombatant combatant, ICombatant target)
Parameters
Type | Name | Description |
---|---|---|
ICombatant | combatant | The attacker. |
ICombatant | target | The new target. |
SetCombatantModes(ICombatant, FightMode, ChaseMode, Boolean)
Sets the fight, chase and safety modes of a combatant.
Declaration
public void SetCombatantModes(ICombatant combatant, FightMode fightMode, ChaseMode chaseMode, bool safeModeOn)
Parameters
Type | Name | Description |
---|---|---|
ICombatant | combatant | The combatant that update modes. |
FightMode | fightMode | The fight mode to change to. |
ChaseMode | chaseMode | The chase mode to change to. |
System.Boolean | safeModeOn | A value indicating whether the attack safety lock is on. |
SkilledCreatureSkillChanged(ICreatureWithSkills, ISkill, UInt32, Byte)
Handles a skill level change from a skilled creature.
Declaration
public void SkilledCreatureSkillChanged(ICreatureWithSkills skilledCreature, ISkill skillThatChanged, uint previousLevel, byte previousPercent)
Parameters
Type | Name | Description |
---|---|---|
ICreatureWithSkills | skilledCreature | The skilled creature for which the skill changed. |
ISkill | skillThatChanged | The skill that changed. |
System.UInt32 | previousLevel | The previous skill level. |
System.Byte | previousPercent | The previous percent of completion to next level. |
StartAsync(CancellationToken)
Runs the main game processing thread which begins advancing time on the game engine.
Declaration
public Task StartAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | A token to observe for cancellation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
StopAsync(CancellationToken)
Declaration
public Task StopAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |