Interface IMyEntity
Inherited Members
Namespace: VRage.ModAPI
Assembly: VRage.Game.dll
Syntax
public interface IMyEntity : IMyEntity
Properties
CastShadows
Gets or sets flag CastShadows
Declaration
bool CastShadows { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
DebugAsyncLoading
Used for internal usage. Modders should not use it. Will be eventually removed
Declaration
bool DebugAsyncLoading { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
DisplayName
Gets or sets user friendly name of entity
Declaration
string DisplayName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
EntityId
Uniq id of entity.
Declaration
long EntityId { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int64 |
See Also
FastCastShadowResolve
Gets or sets flag CastShadows
Declaration
bool FastCastShadowResolve { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Flags
Gets or set some behavior of entity. EntityFlags
Declaration
EntityFlags Flags { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityFlags |
GameLogic
Gets or sets game logic for object. If there is more than 1 game logic attached it should be wrapped into MyCompositeGameLogicComponent.
Declaration
MyEntityComponentBase GameLogic { get; set; }
Property Value
| Type | Description |
|---|---|
| MyEntityComponentBase |
See Also
Hierarchy
Gets or sets Hierarchy component
Declaration
MyHierarchyComponentBase Hierarchy { get; set; }
Property Value
| Type | Description |
|---|---|
| MyHierarchyComponentBase |
InScene
Gets or set if grid is InScene. Objects that are not in scene are not updated and drawn.
Declaration
bool InScene { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
InvalidateOnMove
Gets if entity is invalidated on move When visual look of entity depends on position - then InvalidateOnMove should be true
Declaration
bool InvalidateOnMove { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsCCDForProjectiles
Declaration
bool IsCCDForProjectiles { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsVolumetric
Always returns false
Declaration
bool IsVolumetric { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LocalAABB
Gets or sets local axis aligned bounding box. Same as LocalAABBHr, LocalAABB
Declaration
BoundingBox LocalAABB { get; set; }
Property Value
| Type | Description |
|---|---|
| BoundingBox |
LocalAABBHr
Declaration
BoundingBox LocalAABBHr { get; }
Property Value
| Type | Description |
|---|---|
| BoundingBox |
LocalMatrix
Gets or sets local matrix. When entity, has parent, it's world coordinates are calculated from localMatrix and parent world matrix
Declaration
Matrix LocalMatrix { get; set; }
Property Value
| Type | Description |
|---|---|
| Matrix |
LocalVolume
Gets or sets local volume. Same as LocalVolume
Declaration
BoundingSphere LocalVolume { get; set; }
Property Value
| Type | Description |
|---|---|
| BoundingSphere |
LocalVolumeOffset
Gets or sets local volume offset. Same as LocalVolumeOffset
Declaration
Vector3 LocalVolumeOffset { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
LocationForHudMarker
Declaration
Vector3D LocationForHudMarker { get; }
Property Value
| Type | Description |
|---|---|
| Vector3D |
MarkedForClose
Checked if Close() was called
Declaration
bool MarkedForClose { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
MaxGlassDistSq
Not used in game anymore
Declaration
float MaxGlassDistSq { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Model
Gets model of block
Declaration
IMyModel Model { get; }
Property Value
| Type | Description |
|---|---|
| IMyModel |
ModelCollision
Gets collision model of block
Declaration
IMyModel ModelCollision { get; }
Property Value
| Type | Description |
|---|---|
| IMyModel |
Name
Uniq name of entity. Can be used to find entity by name
Declaration
string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
NearFlag
Gets or sets flag Near
Declaration
bool NearFlag { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
NeedsDraw
Gets or sets flag NeedsDraw
Declaration
bool NeedsDraw { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
NeedsDrawFromParent
Gets or sets flag NeedsDrawFromParent
Declaration
bool NeedsDrawFromParent { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
NeedsResolveCastShadow
Gets or sets flag NeedsResolveCastShadow
Declaration
bool NeedsResolveCastShadow { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
NeedsUpdate
Gets or sets how often the entity should be updated.
Declaration
MyEntityUpdateEnum NeedsUpdate { get; set; }
Property Value
| Type | Description |
|---|---|
| MyEntityUpdateEnum |
NeedsWorldMatrix
Gets or sets if WorldMatrix should be calculated when parent WorldMatrix is changed.
Declaration
bool NeedsWorldMatrix { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Enabling it on big amount entities may lower simulation speed
Parent
Gets parent of entity or null, if this entity doesn't have parent. Ex: character sitting in cockpit, has parent - cockpit, cockpit has parent - cube grid, connected grids also has main grid, which would be parent for other grids.
Declaration
IMyEntity Parent { get; }
Property Value
| Type | Description |
|---|---|
| IMyEntity |
PersistentFlags
Gets or sets persistent flags that are used in rendering.
Declaration
MyPersistentEntityFlags2 PersistentFlags { get; set; }
Property Value
| Type | Description |
|---|---|
| MyPersistentEntityFlags2 |
Physics
Gets or sets physics for object
Declaration
MyPhysicsComponentBase Physics { get; set; }
Property Value
| Type | Description |
|---|---|
| MyPhysicsComponentBase |
PositionComp
Gets or sets position provider logic
Declaration
MyPositionComponentBase PositionComp { get; set; }
Property Value
| Type | Description |
|---|---|
| MyPositionComponentBase |
Render
Gets or sets render logic
Declaration
MyRenderComponentBase Render { get; set; }
Property Value
| Type | Description |
|---|---|
| MyRenderComponentBase |
Save
Declaration
bool Save { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ShadowBoxLod
Gets or sets flag ShadowBoxLod
Declaration
bool ShadowBoxLod { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
SkipIfTooSmall
Gets or sets flag SkipIfTooSmall
Declaration
bool SkipIfTooSmall { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
StopPhysicsActivation
Declaration
bool StopPhysicsActivation { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Storage
Custom storage for mods. Shared with all mods.
Declaration
MyModStorageComponentBase Storage { get; set; }
Property Value
| Type | Description |
|---|---|
| MyModStorageComponentBase |
Remarks
Not synced, but saved with blueprints. Only use set accessor if value is null.
Entity.Storage = new MyModStorageComponent();
Synchronized
Gets or sets if the entity should be synced.
Declaration
bool Synchronized { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
SyncObject
Gets SyncObject used for synchronizing data over network with VRage.Sync.Sync
Declaration
MySyncComponentBase SyncObject { get; }
Property Value
| Type | Description |
|---|---|
| MySyncComponentBase |
Transparent
Gets or sets Transparency. When setting true entity would be 25% transparent
Declaration
bool Transparent { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Visible
Gets or sets flag Visible
Declaration
bool Visible { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
WorldMatrix
Gets or sets world matrix.
Declaration
MatrixD WorldMatrix { get; set; }
Property Value
| Type | Description |
|---|---|
| MatrixD |
See Also
WorldMatrixInvScaled
Get scaled, inverted world matrix. Same as GetViewMatrix(), GetWorldMatrixNormalizedInv(), WorldMatrixNormalizedInv, but not normalized
Declaration
MatrixD WorldMatrixInvScaled { get; }
Property Value
| Type | Description |
|---|---|
| MatrixD | Matrix |
WorldMatrixNormalizedInv
Get normalized, inverted world matrix. Same as GetViewMatrix(), WorldMatrixNormalizedInv
Declaration
MatrixD WorldMatrixNormalizedInv { get; }
Property Value
| Type | Description |
|---|---|
| MatrixD | Matrix |
Methods
AddToGamePruningStructure()
Declaration
void AddToGamePruningStructure()
BeforeSave()
Called before method GetObjectBuilder, when saving sector
Declaration
void BeforeSave()
Close()
This method marks this entity for close which means, that Close will be called after all entities are updated
Declaration
void Close()
DebugDraw()
Calls debug draw of entity
Declaration
void DebugDraw()
DebugDrawInvalidTriangles()
Calls special debug draw, that highlighting invalid triangles in model
Declaration
void DebugDrawInvalidTriangles()
Delete()
Performs real cleaning of entity. Should be called by game. Modders should prefer Close() method.
Declaration
void Delete()
DoOverlapSphereTest(Single, Vector3D)
Checks if intersects Works only with IMyVoxelBase
Declaration
bool DoOverlapSphereTest(float sphereRadius, Vector3D spherePos)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | sphereRadius | Radius of sphere |
| Vector3D | spherePos | World position |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if intersects |
EnableColorMaskForSubparts(Boolean)
Allows subparts have different color than their parent
Declaration
void EnableColorMaskForSubparts(bool enable)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | enable |
GetChildren(List<IMyEntity>, Func<IMyEntity, Boolean>)
Gets children of entity. Child - entity, who's Parent is this entity
Declaration
void GetChildren(List<IMyEntity> children, Func<IMyEntity, bool> collect = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<IMyEntity> | children | List, that would receive results |
| System.Func<IMyEntity, System.Boolean> | collect | When returns true - child added to list |
GetDiffuseColor()
Gets render diffuse color
Declaration
Vector3 GetDiffuseColor()
Returns
| Type | Description |
|---|---|
| Vector3 | Diffuse color |
GetDistanceBetweenCameraAndBoundingSphere()
Distance from camera to bounding sphere of this phys object. Result is always positive, even if camera is inside the sphere. (in meters)
Declaration
float GetDistanceBetweenCameraAndBoundingSphere()
Returns
| Type | Description |
|---|---|
| System.Single | Distance in meters |
GetDistanceBetweenCameraAndPosition()
Distance from camera to position of entity.
Declaration
float GetDistanceBetweenCameraAndPosition()
Returns
| Type | Description |
|---|---|
| System.Single | Distance in meters |
GetFriendlyName()
Not used. Actually not a friendly name
Declaration
string GetFriendlyName()
Returns
| Type | Description |
|---|---|
| System.String | String.Empty or "MyVoxelMap" |
GetIntersectionWithAABB(ref BoundingBoxD)
Return true if object intersects specified bounding box.
Declaration
bool GetIntersectionWithAABB(ref BoundingBoxD aabb)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBoxD | aabb | Bounding box to check |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if intersects |
GetIntersectionWithLine(ref LineD, out Nullable<MyIntersectionResultLineTriangleEx>, IntersectionFlags)
Get intersection of model with provided line
Declaration
bool GetIntersectionWithLine(ref LineD line, out Nullable<MyIntersectionResultLineTriangleEx> tri, IntersectionFlags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| LineD | line | Line that should intersect model |
| System.Nullable<VRage.Game.Models.MyIntersectionResultLineTriangleEx> | tri | Returns model first triangle that intersects |
| IntersectionFlags | flags | Mode of work |
Returns
| Type | Description |
|---|---|
| System.Boolean | True when line intersects models |
GetIntersectionWithLineAndBoundingSphere(ref LineD, Single)
Calculates intersection of line with any bounding sphere in this model instance. Center of the bounding sphere will be returned. It takes boundingSphereRadiusMultiplier argument which serves for extending the influence (radius) for interaction with line.
Declaration
Nullable<Vector3D> GetIntersectionWithLineAndBoundingSphere(ref LineD line, float boundingSphereRadiusMultiplier)
Parameters
| Type | Name | Description |
|---|---|---|
| LineD | line | Line to check |
| System.Single | boundingSphereRadiusMultiplier | Bounding sphere radius would be multiplied by this value |
Returns
| Type | Description |
|---|---|
| System.Nullable<Vector3D> | Position of intersection if of line and bounding sphere |
GetIntersectionWithSphere(ref BoundingSphereD)
Return true if object intersects specified sphere.
Declaration
bool GetIntersectionWithSphere(ref BoundingSphereD sphere)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphereD | sphere | Sphere to check |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if intersects |
GetInventory()
Simply get the MyInventoryBase component stored in this entity.
Declaration
IMyInventory GetInventory()
Returns
| Type | Description |
|---|---|
| IMyInventory | Null, or first inventory |
GetInventory(Int32)
Search for inventory component with matching index.
Declaration
IMyInventory GetInventory(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | Index of inventory, starting from 0 |
Returns
| Type | Description |
|---|---|
| IMyInventory | Null, or inventory at matching index |
GetLargestDistanceBetweenCameraAndBoundingSphere()
Largest distance from camera to bounding sphere of this phys object. Result is always positive, even if camera is inside the sphere. It's actually distance between camera and opposite side of the sphere
Declaration
float GetLargestDistanceBetweenCameraAndBoundingSphere()
Returns
| Type | Description |
|---|---|
| System.Single | Distance in meters |
GetObjectBuilder(Boolean)
Returns object builder - object representing block state, and allows restore it. Used in game save, or syncing over network.
Declaration
MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | copy | When true, Name won't be saved. Copy true comes only from MyGridClipboard/MyFloatingObjectClipboard/MyVoxelClipboard |
Returns
| Type | Description |
|---|---|
| MyObjectBuilder_EntityBase | Object builder |
GetSmallestDistanceBetweenCameraAndBoundingSphere()
Smallest distance between camera and bounding sphere of this phys object. Result is always positive, even if camera is inside the sphere.
Declaration
float GetSmallestDistanceBetweenCameraAndBoundingSphere()
Returns
| Type | Description |
|---|---|
| System.Single | Distance in meters |
GetSubpart(String)
Gets subpart by subpart name
Declaration
MyEntitySubpart GetSubpart(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of subpart. Keep in mind that subpart names, should not start with |
Returns
| Type | Description |
|---|---|
| MyEntitySubpart | Subpart if it is found, or crashes if subpart not found |
Remarks
If you press Alt+11, enable Debug draw and Model dummies then you'll see all subpart names.
GetTopMostParent(Type)
Gets top most Parent of specified type. Top most is entity that doesn't have parent (of specified type)
Declaration
IMyEntity GetTopMostParent(Type type = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of parent. When type is null, type check disabled |
Returns
| Type | Description |
|---|---|
| IMyEntity | Entity |
GetTrianglesIntersectingSphere(ref BoundingSphere, Nullable<Vector3>, Nullable<Single>, List<MyTriangle_Vertex_Normals>, Int32)
Return list of triangles intersecting specified sphere. Angle between every triangleVertexes normal vector and 'referenceNormalVector' is calculated, and if more than 'maxAngle', we ignore such triangleVertexes. Triangles are returned in 'retTriangles', and this list must be preallocated! IMPORTANT: Sphere must be in model space, so don't transform it!
Declaration
void GetTrianglesIntersectingSphere(ref BoundingSphere sphere, Nullable<Vector3> referenceNormalVector, Nullable<float> maxAngle, List<MyTriangle_Vertex_Normals> retTriangles, int maxNeighbourTriangles)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sphere | Sphere to check |
| System.Nullable<Vector3> | referenceNormalVector | Used in filtering triangles |
| System.Nullable<System.Single> | maxAngle | Max angle between referenceNormalVector and every triangleVertex of model |
| System.Collections.Generic.List<MyTriangle_Vertex_Normals> | retTriangles | Triangles would be added here |
| System.Int32 | maxNeighbourTriangles | Limit of added triangles |
GetViewMatrix()
Get normalized, inverted world matrix. Same as GetWorldMatrixNormalizedInv(), WorldMatrixNormalizedInv
Declaration
MatrixD GetViewMatrix()
Returns
| Type | Description |
|---|---|
| MatrixD | Matrix |
GetWorldMatrixNormalizedInv()
Get normalized, inverted world matrix. Same as GetViewMatrix(), WorldMatrixNormalizedInv
Declaration
MatrixD GetWorldMatrixNormalizedInv()
Returns
| Type | Description |
|---|---|
| MatrixD | Matrix |
IsVisible()
Gets or result of function IsVisible(). Function inside check for IsVisible(IMyEntity)
Declaration
bool IsVisible()
Returns
| Type | Description |
|---|---|
| System.Boolean | True if entity should be drawn |
OnAddedToScene(Object)
Adds entity to scene: init updates, render physics
Declaration
void OnAddedToScene(object source)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | source | Object that triggered adding from scene |
OnRemovedFromScene(Object)
Remove entity and it's children from scene: stops updates and render, deactivates physics. Usually called when entity deleted
Declaration
void OnRemovedFromScene(object source)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | source | Object that triggered removing from scene |
RemoveFromGamePruningStructure()
Declaration
void RemoveFromGamePruningStructure()
SetColorMaskForSubparts(Vector3)
Sets subparts custom col
Declaration
void SetColorMaskForSubparts(Vector3 colorMaskHsv)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | colorMaskHsv | Color |
SetEmissiveParts(String, Color, Single)
Sets the emissive value of a specific emissive material on entity.
Declaration
void SetEmissiveParts(string emissiveName, Color emissivePartColor, float emissivity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | emissiveName | The name of the emissive material (ie. "Emissive0") |
| Color | emissivePartColor | Color to emit |
| System.Single | emissivity | Level of emissivity (0 is off, 1 is full brightness) |
SetEmissivePartsForSubparts(String, Color, Single)
Sets the emissive value of a specific emissive material on all entity subparts.
Declaration
void SetEmissivePartsForSubparts(string emissiveName, Color emissivePartColor, float emissivity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | emissiveName | The name of the emissive material (ie. "Emissive0") |
| Color | emissivePartColor | Color to emit |
| System.Single | emissivity | Level of emissivity (0 is off, 1 is full brightness). |
SetLocalMatrix(Matrix, Object)
Sets local matrix. When entity, has parent, it's world coordinates are calculated from localMatrix and parent world matrix
Declaration
void SetLocalMatrix(Matrix localMatrix, object source = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix | localMatrix | New matrix |
| System.Object | source | Object that caused this event. Not used in anyway |
SetPosition(Vector3D)
Set WorldMatrix's Translation. Moves entity.
Declaration
void SetPosition(Vector3D pos)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3D | pos | New position of entity |
SetTextureChangesForSubparts(Dictionary<String, MyTextureChange>)
This calling is obsolete, use another version.
Declaration
void SetTextureChangesForSubparts(Dictionary<string, MyTextureChange> value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary<System.String, VRageRender.Messages.MyTextureChange> | value |
SetTextureChangesForSubparts(Dictionary<MyStringId, MyTextureChange>)
Sets subparts custom skinning. Copy values from TextureChanges, then change needed keys. You can retrieve values for exact skin with following code:
MyDefinitionManager.Static.GetAssetModifierDefinitionForRender(skinId);
Declaration
void SetTextureChangesForSubparts(Dictionary<MyStringId, MyTextureChange> value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary<MyStringId, VRageRender.Messages.MyTextureChange> | value | Key - name of texture, value - path to texture files |
SetWorldMatrix(MatrixD, Object)
Sets world matrix of entity.
Declaration
void SetWorldMatrix(MatrixD worldMatrix, object source = null)
Parameters
| Type | Name | Description |
|---|---|---|
| MatrixD | worldMatrix | New world matrix |
| System.Object | source | Object that triggered set of new matrix |
Teleport(MatrixD, Object, Boolean)
When moving entity over large distances or when entity has children, using this method preferred over SetPosition(Vector3D)
Declaration
void Teleport(MatrixD pos, object source = null, bool ignoreAssert = false)
Parameters
| Type | Name | Description |
|---|---|---|
| MatrixD | pos | Teleport destination |
| System.Object | source | Object that triggered |
| System.Boolean | ignoreAssert | Do extra validation |
TryGetSubpart(String, out MyEntitySubpart)
Gets subpart by subpart name
Declaration
bool TryGetSubpart(string name, out MyEntitySubpart subpart)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of subpart. Keep in mind that subpart names, should not start with |
| MyEntitySubpart | subpart | Subpart if it is found |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if subpart is found |
Remarks
If you press Alt+11, enable Debug draw and Model dummies then you'll see all subpart names.
UpdateGamePruningStructure()
Update position of entity in MyGamePruningStructure. Calls:
MyGamePruningStructure.Move(this)
Declaration
void UpdateGamePruningStructure()
Events
OnClose
Called when Close() is called. Order 1) OnMarkForClose 2) OnClosing 3) OnClose.
Declaration
event Action<IMyEntity> OnClose
Event Type
| Type | Description |
|---|---|
| System.Action<IMyEntity> |
Remarks
Modders should prefer OnMarkForClose or OnClosing
OnClosing
Called when Close() is called. Order 1) OnMarkForClose 2) OnClosing 3) OnClose.
Declaration
event Action<IMyEntity> OnClosing
Event Type
| Type | Description |
|---|---|
| System.Action<IMyEntity> |
Remarks
Modders should prefer OnMarkForClose or OnClosing
OnMarkForClose
Called when Close() is called. Order 1) OnMarkForClose 2) OnClosing 3) OnClose.
Declaration
event Action<IMyEntity> OnMarkForClose
Event Type
| Type | Description |
|---|---|
| System.Action<IMyEntity> |
Remarks
Modders should prefer OnMarkForClose or OnClosing. This event may not be invoked at all, when calling MyEntities.CloseAll, marking is bypassed
OnPhysicsChanged
Called when havok rigid body physics are changed: inited, closed, modified.
Declaration
event Action<IMyEntity> OnPhysicsChanged
Event Type
| Type | Description |
|---|---|
| System.Action<IMyEntity> |