Interface IGameObject
An interface that defines the entire public interface of GameObject. Generally, you should NOT implement these functions yourself, however it can be used in conjunction with a private, backing field of type GameObject to store items in a map, where that object cannot directly inherit from GameObject.
Inherited Members
Namespace: GoRogue.GameFramework
Assembly: GoRogue.dll
Syntax
public interface IGameObject : IHasID, IHasLayer, IHasComponents
Remarks
Generally, you will never implement the items in this interface manually, but rather do so through a private, backing field of type GameObject. There is an example of this type of implementation here.
Properties
| Improve this Doc View SourceCurrentMap
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 |
IsStatic
Whether or not the object is "static". Static objects CANNOT be moved, and only static objects may be placed on layer 0 of a Map.
Declaration
bool IsStatic { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsTransparent
Whether or not the object is considered "transparent", eg. whether or not light passes through it for the sake of calculating the FOV of a Map.
Declaration
bool IsTransparent { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
---|---|
System.Boolean |
Position
The position of this object on the grid. Any time this value is changed, the Moved event is fired.
Declaration
Coord Position { get; set; }
Property Value
Type | Description |
---|---|
Coord |
Remarks
This property may be overriden to implement custom functionality, however it is highly recommended that you call the base set in the overridden setter, as it performs collision detection.
Methods
| Improve this Doc View SourceMoveIn(Direction)
Attempts to move the object in the given direction, and returns true if the object was successfully moved, false otherwise.
Declaration
bool MoveIn(Direction direction)
Parameters
Type | Name | Description |
---|---|---|
Direction | direction | The direction in which to try to move the object. |
Returns
Type | Description |
---|---|
System.Boolean | True if the object was successfully moved, false otherwise. |
OnMapChanged(Map)
Internal use only, do not call manually! Must, at minimum, update the CurrentMap field of the IGameObject to reflect the change.
Declaration
void OnMapChanged(Map newMap)
Parameters
Type | Name | Description |
---|---|---|
Map | newMap | New map to which the IGameObject has been added. |
Events
| Improve this Doc View SourceMoved
Event fired whenever this object's grid position is successfully changed. Fired regardless of whether the object is part of a Map.
Declaration
event EventHandler<ItemMovedEventArgs<IGameObject>> Moved
Event Type
Type | Description |
---|---|
System.EventHandler<ItemMovedEventArgs<IGameObject>> |