Show / Hide Table of Contents

Interface IGameObject

Base interface required for any object that has a grid position and can be added to a Map. Implements basic attributes generally common to all objects on a map, as well as properties/methods that Map needs to function. It also provides a container that you may attach arbitrary components to (via the IObjectWithComponents interface).

For a concrete implementation, see GameObject.

Inherited Members
IHasID.ID
IHasLayer.Layer
IObjectWithComponents.GoRogueComponents
IPositionable.Position
IPositionable.PositionChanging
IPositionable.PositionChanged
Namespace: GoRogue.GameFramework
Assembly: GoRogue.dll
Syntax
public interface IGameObject : IHasID, IHasLayer, IObjectWithComponents, IPositionable
Remarks

Generally, you can use GameObject instead of implementing this interface directly. However, if the need to avoid inheritance or change that implementation arises, please note that the interface contains events that you must fire appropriately when the corresponding property implementations are changed. GoRogue defines helper methods for this; it is recommended that you use GameObject as an example.

Regardless of what implementation is used, however, if ComponentCollection (or some other custom collection implementing the proper functionality) is used, this object provides support for its components to (optionally) implement IParentAwareComponent, or inherit from ParentAwareComponentBase. In this case, the Parent will be updated automatically as components are added/ removed. Typically, you will want to inherit your components from ParentAwareComponentBase<TParent>, where TParent would be IGameObject or some class implementing that interface.

Properties

View Source

CurrentMap

The current Map which this object resides on. Returns null if the object has not been added to a map. An IGameObject is allowed to reside on only one map.

Declaration
Map? CurrentMap { get; }
Property Value
Type Description
Map
View Source

IsTransparent

Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of calculating FOV.

Declaration
bool IsTransparent { get; set; }
Property Value
Type Description
bool
View Source

IsWalkable

Whether or not the object is to be considered "walkable", eg. whether or not the square it resides on can be traversed by other, non-walkable objects on the same Map. Effectively, whether or not this object collides.

Declaration
bool IsWalkable { get; set; }
Property Value
Type Description
bool

Methods

View Source

OnMapChanged(Map?)

Internal use only, do not call manually! Must, at minimum, call SafelySetCurrentMap(IGameObject, ref Map?, Map?, EventHandler<GameObjectCurrentMapChanged>?, EventHandler<GameObjectCurrentMapChanged>?) which will update the CurrentMap field of the IGameObject to reflect the change and fire map added/removed events as appropriate (or provide equivalent functionality).

Declaration
void OnMapChanged(Map? newMap)
Parameters
Type Name Description
Map newMap

New map to which the IGameObject has been added.

Events

View Source

AddedToMap

Fired when the object is added to a map.

Declaration
event EventHandler<GameObjectCurrentMapChanged>? AddedToMap
Event Type
Type Description
EventHandler<GameObjectCurrentMapChanged>
View Source

RemovedFromMap

Fired when the object is removed from a map.

Declaration
event EventHandler<GameObjectCurrentMapChanged>? RemovedFromMap
Event Type
Type Description
EventHandler<GameObjectCurrentMapChanged>
View Source

TransparencyChanged

Fired when IsTransparent is changed.

Declaration
event EventHandler<ValueChangedEventArgs<bool>>? TransparencyChanged
Event Type
Type Description
EventHandler<ValueChangedEventArgs<bool>>
View Source

TransparencyChanging

Fired when IsTransparent is about to be changed.

Declaration
event EventHandler<ValueChangedEventArgs<bool>>? TransparencyChanging
Event Type
Type Description
EventHandler<ValueChangedEventArgs<bool>>
View Source

WalkabilityChanged

Fired when IsWalkable is changed.

Declaration
event EventHandler<ValueChangedEventArgs<bool>>? WalkabilityChanged
Event Type
Type Description
EventHandler<ValueChangedEventArgs<bool>>
View Source

WalkabilityChanging

Fired when IsWalkable is about to changed.

Declaration
event EventHandler<ValueChangedEventArgs<bool>>? WalkabilityChanging
Event Type
Type Description
EventHandler<ValueChangedEventArgs<bool>>

Extension Methods

GameObjectExtensions.CanMove(IGameObject, Point)
GameObjectExtensions.CanMoveIn(IGameObject, Direction)
GameObjectExtensions.CanSetWalkability(IGameObject, bool)
GameObjectExtensions.CanToggleWalkability(IGameObject)
GameObjectExtensions.SafelySetCurrentMap(IGameObject, ref Map?, Map?, EventHandler<GameObjectCurrentMapChanged>?, EventHandler<GameObjectCurrentMapChanged>?)
Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX