Show / Hide Table of Contents

Class MyComponentContainerExtension

TODO: This should be later ideally some factory rather than just an extension on the MyComponentContainer

Inheritance
System.Object
MyComponentContainerExtension
Namespace: Sandbox.Game.Entities
Assembly: Sandbox.Game.dll
Syntax
public static class MyComponentContainerExtension : Object

Methods

FindComponentBuilder(MyContainerDefinition.DefaultComponent, MyObjectBuilder_ComponentContainer)

Declaration
public static MyObjectBuilder_ComponentBase FindComponentBuilder(MyContainerDefinition.DefaultComponent component, MyObjectBuilder_ComponentContainer builder)
Parameters
Type Name Description
MyContainerDefinition.DefaultComponent component
MyObjectBuilder_ComponentContainer builder
Returns
Type Description
MyObjectBuilder_ComponentBase

InitComponents(IMyComponentContainer, MyObjectBuilderType, MyStringHash, MyObjectBuilder_ComponentContainer)

Tries to retrieve entity definition of the entity owning this container, check if the definition has some DefaultComponents, tries to retrieve these components definitions, create these components instances and add them

TODO: This should be ideally a behavior of the MyEntityComponentContainer when it is initialized (deserialized).. or by the factory, for now, this is an extension method

Declaration
public static void InitComponents(this IMyComponentContainer container, MyObjectBuilderType type, MyStringHash subtypeName, MyObjectBuilder_ComponentContainer builder)
Parameters
Type Name Description
VRage.Game.Components.Interfaces.IMyComponentContainer container
MyObjectBuilderType type
MyStringHash subtypeName
MyObjectBuilder_ComponentContainer builder

TryAddComponent(Int64, String, String)

This will try to parse strings to types and create an instance of the component type. Don't use this in retail code, use for debug, modding etc.

Declaration
public static bool TryAddComponent(long entityId, string instanceTypeStr, string componentTypeStr)
Parameters
Type Name Description
System.Int64 entityId

Id of entity which should get the component

System.String instanceTypeStr

Type of the component instance, no the base type

System.String componentTypeStr

The base type of the component to be added

Returns
Type Description
System.Boolean

true on success

TryAddComponent(Int64, MyDefinitionId)

This will look for the component definition and if found, it will create its instance and add to the entity with the give id

Declaration
public static bool TryAddComponent(long entityId, MyDefinitionId componentDefinitionId)
Parameters
Type Name Description
System.Int64 entityId
MyDefinitionId componentDefinitionId
Returns
Type Description
System.Boolean

true on success

TryGetComponentDefinition(MyObjectBuilderType, MyStringHash, out MyComponentDefinitionBase)

Declaration
public static bool TryGetComponentDefinition(MyObjectBuilderType type, MyStringHash subtypeName, out MyComponentDefinitionBase componentDefinition)
Parameters
Type Name Description
MyObjectBuilderType type
MyStringHash subtypeName
MyComponentDefinitionBase componentDefinition
Returns
Type Description
System.Boolean

TryGetContainerDefinition(MyObjectBuilderType, MyStringHash, out MyContainerDefinition)

Declaration
public static bool TryGetContainerDefinition(MyObjectBuilderType type, MyStringHash subtypeName, out MyContainerDefinition definition)
Parameters
Type Name Description
MyObjectBuilderType type
MyStringHash subtypeName
MyContainerDefinition definition
Returns
Type Description
System.Boolean

TryGetEntityComponentTypes(Int64, out List<Type>)

This will retrieve component types in the entity container. This method allocates, use only for debugging etc.

Declaration
public static bool TryGetEntityComponentTypes(long entityId, out List<Type> components)
Parameters
Type Name Description
System.Int64 entityId
System.Collections.Generic.List<System.Type> components
Returns
Type Description
System.Boolean

true if success

TryRemoveComponent(Int64, Type)

Declaration
public static bool TryRemoveComponent(long entityId, Type componentType)
Parameters
Type Name Description
System.Int64 entityId
System.Type componentType
Returns
Type Description
System.Boolean
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾