Interface IMyCubeBlock
Describes base block interface (mod interface)
Also known as fatblock
Inherited Members
Namespace: VRage.Game.ModAPI
Assembly: VRage.Game.dll
Syntax
public interface IMyCubeBlock : IMyCubeBlock, IMyEntity, IMyEntity
Properties
CheckConnectionAllowed
Whether the grid should call the ConnectionAllowed method for this block (ConnectionAllowed checks mount points and other per-block requirements)
Declaration
bool CheckConnectionAllowed { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
CubeGrid
Grid in which the block is placed
Declaration
IMyCubeGrid CubeGrid { get; }
Property Value
Type | Description |
---|---|
IMyCubeGrid |
ResourceSink
Resource sink (draws power)
Declaration
MyResourceSinkComponentBase ResourceSink { get; set; }
Property Value
Type | Description |
---|---|
MyResourceSinkComponentBase |
Remarks
Cast to MyResourceSinkComponent as needed.
SlimBlock
Gets the SlimBlock associated with this block
Declaration
IMySlimBlock SlimBlock { get; }
Property Value
Type | Description |
---|---|
IMySlimBlock |
UpgradeValues
Get all values changed by upgrade modules Should only be used as read-only
Declaration
Dictionary<string, float> UpgradeValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Single> |
Methods
AddUpgradeValue(String, Single)
Preferred way of registering a block for upgrades Adding directly to the dictionary can have unintended consequences when multiple mods are involved.
Declaration
void AddUpgradeValue(string upgrade, float defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | upgrade | Name of upgrade. Example: Productivity/PowerEfficiency/Effectiveness |
System.Single | defaultValue | Default value for this upgrade |
CalcLocalMatrix(out Matrix, out String)
Calculates local matrix, and currentModel
Declaration
void CalcLocalMatrix(out Matrix localMatrix, out string currModel)
Parameters
Type | Name | Description |
---|---|---|
Matrix | localMatrix | Returns local matrix |
System.String | currModel | Returns currently used model |
CalculateCurrentModel(out Matrix)
Calculates model currently used by block depending on its build progress and other factors
Declaration
string CalculateCurrentModel(out Matrix orientation)
Parameters
Type | Name | Description |
---|---|---|
Matrix | orientation | Model orientation |
Returns
Type | Description |
---|---|
System.String | Model path |
GetObjectBuilderCubeBlock(Boolean)
Returns block object builder which can be serialized or added to grid
Declaration
MyObjectBuilder_CubeBlock GetObjectBuilderCubeBlock(bool copy = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | copy | Set if creating a copy of block |
Returns
Type | Description |
---|---|
MyObjectBuilder_CubeBlock | Block object builder |
Init()
Reloads block model and interactive objects (doors, terminals, etc...)
Declaration
void Init()
Init(MyObjectBuilder_CubeBlock, IMyCubeGrid)
Initializes block state from object builder
Declaration
void Init(MyObjectBuilder_CubeBlock builder, IMyCubeGrid cubeGrid)
Parameters
Type | Name | Description |
---|---|---|
MyObjectBuilder_CubeBlock | builder | Object builder of block (should correspond with block type) |
IMyCubeGrid | cubeGrid | Owning grid |
OnBuildSuccess(Int64)
Method called when a block has been built (after adding to the grid). This is called right after placing the block and it doesn't matter whether it is fully built (creative mode) or is only construction site. Note that it is not called for blocks which do not create FatBlock at that moment.
Declaration
void OnBuildSuccess(long builtBy)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | builtBy |
OnBuildSuccess(Int64, Boolean)
Method called when a block has been built (after adding to the grid). This is called right after placing the block and it doesn't matter whether it is fully built (creative mode) or is only construction site. Note that it is not called for blocks which do not create FatBlock at that moment.
Declaration
void OnBuildSuccess(long builtBy, bool instantBuild)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | builtBy | IdentityId of a builder |
System.Boolean | instantBuild | Defines if block was instantly built. Used in blocks such piston, rotor, hinge, motor suspension to define if top part should be instantly built |
OnDestroy()
Called when block is destroyed before being removed from grid
Declaration
void OnDestroy()
OnModelChange()
Called when the model referred by the block is changed
Declaration
void OnModelChange()
OnRegisteredToGridSystems()
Called at the end of registration from grid systems (after block has been registered).
Declaration
void OnRegisteredToGridSystems()
OnRemovedByCubeBuilder()
Method called when user removes a cube block from grid. Useful when block has to remove some other attached block (like motors).
Declaration
void OnRemovedByCubeBuilder()
OnUnregisteredFromGridSystems()
Called at the end of unregistration from grid systems (after block has been unregistered).
Declaration
void OnUnregisteredFromGridSystems()
RaycastDetectors(Vector3D, Vector3D)
Gets the name of interactive object intersected by defined line
Declaration
string RaycastDetectors(Vector3D worldFrom, Vector3D worldTo)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | worldFrom | Line from point in world coordinates |
Vector3D | worldTo | Line to point in world coordinates |
Returns
Type | Description |
---|---|
System.String | Name of intersected detector (interactive object) |
ReloadDetectors(Boolean)
Reloads detectors (interactive objects) in model
Declaration
void ReloadDetectors(bool refreshNetworks = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | refreshNetworks | ie conveyor network |
RemoveEffect(String, Int32)
Removes active effect set with SetEffect
Declaration
int RemoveEffect(string effectName, int exception = -1)
Parameters
Type | Name | Description |
---|---|---|
System.String | effectName | Name of effect |
System.Int32 | exception | Index of effect that should be ignored. Starting from 0, use -1 to remove all effects with specified name |
Returns
Type | Description |
---|---|
System.Int32 | The number of effects removed |
SetDamageEffect(Boolean)
Start or stop damage effect on cube block
Declaration
void SetDamageEffect(bool start)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | start |
SetEffect(String, Boolean)
Activate block effect listed in definition
Declaration
bool SetEffect(string effectName, bool stopPrevious = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | effectName | Name of effect |
System.Boolean | stopPrevious | Defines if previous effect should be stopped |
Returns
Type | Description |
---|---|
System.Boolean | true if effect was started; false otherwise |
SetEffect(String, Single, Boolean, Boolean, Boolean)
Activate block effect with parameters listed in definition See: Sandbox.Definitions.CubeBlockEffectBase
Declaration
bool SetEffect(string effectName, float parameter, bool stopPrevious = false, bool ignoreParameter = false, bool removeSameNameEffects = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | effectName | Name of effect |
System.Single | parameter | When this value more than CubeBlockEffectBase.ParameterMin and less than CubeBlockEffectBase.ParameterMax, effect can be added |
System.Boolean | stopPrevious | Defines if previous effect should be stopped |
System.Boolean | ignoreParameter | When true effect always added |
System.Boolean | removeSameNameEffects | When true effect with same name are removed |
Returns
Type | Description |
---|---|
System.Boolean | true if effect was started; false otherwise |
Events
CubeGridChanged
Triggers when blocks cube grid is changed
Declaration
event Action<IMyCubeGrid> CubeGridChanged
Event Type
Type | Description |
---|---|
System.Action<IMyCubeGrid> |
IsWorkingChanged
Called when "WorkingState" is changed.
Declaration
event Action<IMyCubeBlock> IsWorkingChanged
Event Type
Type | Description |
---|---|
System.Action<IMyCubeBlock> |
OnUpgradeValuesChanged
Event called when upgrade values are changed Either upgrades were built or destroyed, or they become damaged or unpowered
Declaration
event Action OnUpgradeValuesChanged
Event Type
Type | Description |
---|---|
System.Action |