Show / Hide Table of Contents

Interface IMyGridGroups

ModAPI interface giving access to grid-groups

Namespace: VRage.Game.ModAPI
Assembly: VRage.Game.dll
Syntax
public interface IMyGridGroups

Methods

AddGridGroupLogic<T>(GridLinkTypeEnum, Func<IMyGridGroupData, T>)

Generates MyGridGroupsDefaultEventHandler each time grid group connected with provided linking is created

Declaration
void AddGridGroupLogic<T>(GridLinkTypeEnum type, Func<IMyGridGroupData, T> creator)
    where T : MyGridGroupsDefaultEventHandler
Parameters
Type Name Description
GridLinkTypeEnum type

Type of linking

System.Func<IMyGridGroupData, T> creator

Function that creates grid group logic

Type Parameters
Name Description
T

Type of grid group logic

FindConnection(GridLinkTypeEnum, IMyCubeGrid, Func<IMyCubeGrid, IMyCubeGrid, Int64, Boolean>)

Dijkstra search over grid-to-grid connections until searcher is return true NOTE: pretty expensive function on large grid-groups, don't call it often.

Declaration
List<KeyValuePair<long, IMyCubeGrid>> FindConnection(GridLinkTypeEnum linking, IMyCubeGrid from, Func<IMyCubeGrid, IMyCubeGrid, long, bool> searcher)
Parameters
Type Name Description
GridLinkTypeEnum linking

Type of grid-group connection

IMyCubeGrid from

Initial grid, from which search would start

System.Func<IMyCubeGrid, IMyCubeGrid, System.Int64, System.Boolean> searcher

When this function returns true - search is stopped, and result is returned.

First arg - new grid

Second - previous grid

Last - block, that creates connection between those 2 grids. Note: There could be only one block per Grid-Grid connection

Note: first call would be called with (from, null, 0)

Returns
Type Description
System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.Int64, IMyCubeGrid>>

Null if linking is linking is incorrect.

Null if searcher hasn't returned true.

Otherwise list of connections, where long is block entityId, and IMyCubeGrid - grid, where search is hopped

Note: first element would be always (from, 0)

GetGridGroup(GridLinkTypeEnum, IMyCubeGrid)

Gets grid-group for provided grid

Declaration
IMyGridGroupData GetGridGroup(GridLinkTypeEnum linking, IMyCubeGrid grid)
Parameters
Type Name Description
GridLinkTypeEnum linking

Type of linking

IMyCubeGrid grid

One part of grid-group

Returns
Type Description
IMyGridGroupData

Grid group interface

GetGridGroups<T>(GridLinkTypeEnum, T)

Gets all grid groups, that exists in the world

Declaration
T GetGridGroups<T>(GridLinkTypeEnum linking, T grids)
    where T : ICollection<IMyGridGroupData>
Parameters
Type Name Description
GridLinkTypeEnum linking

Type of linking

T grids

Collection would be filled with results

Returns
Type Description
T

Provided collection

Type Parameters
Name Description
T

Type of collection

GetGroup(IMyCubeGrid, GridLinkTypeEnum)

OBSOLETE: Use GetGroup with passing your own collection, it is better for simulation speed. Returns all grids connected to the given grid by the specified link type. Array always contains node.

Declaration
List<IMyCubeGrid> GetGroup(IMyCubeGrid node, GridLinkTypeEnum type)
Parameters
Type Name Description
IMyCubeGrid node

One of grid group

GridLinkTypeEnum type

Type of linking

Returns
Type Description
System.Collections.Generic.List<IMyCubeGrid>

New list of connected grids

GetGroup(IMyCubeGrid, GridLinkTypeEnum, ICollection<IMyCubeGrid>)

Returns all grids connected to the given grid by the specified link type. Array always contains node.

Declaration
void GetGroup(IMyCubeGrid node, GridLinkTypeEnum type, ICollection<IMyCubeGrid> collection)
Parameters
Type Name Description
IMyCubeGrid node

One of grid

GridLinkTypeEnum type

Type of grid linking

System.Collections.Generic.ICollection<IMyCubeGrid> collection

Collection where connected grids would be added

HasConnection(IMyCubeGrid, IMyCubeGrid, GridLinkTypeEnum)

Checks if two grids are connected by the given link type.

Declaration
bool HasConnection(IMyCubeGrid grid1, IMyCubeGrid grid2, GridLinkTypeEnum type)
Parameters
Type Name Description
IMyCubeGrid grid1

Grid 1

IMyCubeGrid grid2

Grid 2

GridLinkTypeEnum type

Type of connection

Returns
Type Description
System.Boolean

True when 2 grids connected with specified grid linking

Events

OnGridGroupCreated

Called when new grid-group was created. Example 1: 1 large grid-group splitted into 2 parts. Example 2: new grid created

Declaration
event Action<IMyGridGroupData> OnGridGroupCreated
Event Type
Type Description
System.Action<IMyGridGroupData>

OnGridGroupDestroyed

Called when grid-group was destroyed. Example 1: 2 small grids-groups joined into larger one. Example 2: grid, not connected to any other grid, was destroyed

Declaration
event Action<IMyGridGroupData> OnGridGroupDestroyed
Event Type
Type Description
System.Action<IMyGridGroupData>
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾