Class Shape
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
The base shape for all json objects.
[JsonObject(MemberSerialization.OptIn)]
public class Shape
- Inheritance
-
Shape
- Inherited Members
- Extension Methods
Fields
Animations
The animations for the shape.
[JsonProperty]
public Animation[] Animations
Field Value
AnimationsByCrc32
public Dictionary<uint, Animation> AnimationsByCrc32
Field Value
Elements
The elements of the shape.
[JsonProperty]
public ShapeElement[] Elements
Field Value
JointsById
public Dictionary<int, AnimationJoint> JointsById
Field Value
TextureHeight
The height of the texture (default: 16)
[JsonProperty]
public int TextureHeight
Field Value
TextureSizes
[JsonProperty]
public Dictionary<string, int[]> TextureSizes
Field Value
- Dictionary<string, int[]>
TextureWidth
The width of the texture. (default: 16)
[JsonProperty]
public int TextureWidth
Field Value
Textures
The collection of textures in the shape.
[JsonProperty]
public Dictionary<string, AssetLocation> Textures
Field Value
Methods
CacheInvTransforms()
public void CacheInvTransforms()
CacheInvTransforms(ShapeElement[])
public static void CacheInvTransforms(ShapeElement[] elements)
Parameters
elements
ShapeElement[]
Clone()
Creates a deep copy of the shape. If the shape has animations, then it also resolves references and joints to ensure the cloned shape is fully initialized
public Shape Clone()
Returns
CloneAnimations()
public Animation[] CloneAnimations()
Returns
CloneElements()
public ShapeElement[] CloneElements()
Returns
CollectElements(ShapeElement[], Dictionary<string, ShapeElement>)
Collects all the elements in the shape recursively.
public void CollectElements(ShapeElement[] elements, Dictionary<string, ShapeElement> elementsByName)
Parameters
elements
ShapeElement[]elementsByName
Dictionary<string, ShapeElement>
GetElementByName(string, StringComparison)
Recursively searches the element by name from the shape.
public ShapeElement GetElementByName(string name, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase)
Parameters
name
stringThe name of the element to get.
stringComparison
StringComparison
Returns
- ShapeElement
The shape element or null if none was found
InitForAnimations(ILogger, string, params string[])
public void InitForAnimations(ILogger logger, string shapeNameForLogging, params string[] requireJointsForElements)
Parameters
RemoveElementByName(string, StringComparison)
Removes all elements with given name
public bool RemoveElementByName(string name, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase)
Parameters
name
stringstringComparison
StringComparison
Returns
RemoveElements(string[])
public void RemoveElements(string[] elementNames)
Parameters
elementNames
string[]
ResolveAndFindJoints(ILogger, string, params string[])
Resolves all joints and loads them.
public void ResolveAndFindJoints(ILogger errorLogger, string shapeName, params string[] requireJointsForElements)
Parameters
ResolveAndLoadJoints(params string[])
[Obsolete("Must call ResolveAndFindJoints(errorLogger, shapeName, joints) instead")]
public void ResolveAndLoadJoints(params string[] requireJointsForElements)
Parameters
requireJointsForElements
string[]
ResolveReferences(ILogger, string)
Attempts to resolve all references within the shape. Logs missing references them to the errorLogger
public void ResolveReferences(ILogger errorLogger, string shapeNameForLogging)
Parameters
StepParentShape(Shape, string, string, string, ILogger, Action<string, AssetLocation>, float)
Adds a step parented shape to this shape. If you plan to cache the childShape use the shorter argument method and call SubclassForStepParenting() only once on it
public bool StepParentShape(Shape childShape, string texturePrefixCode, string childLocationForLogging, string parentLocationForLogging, ILogger logger, Action<string, AssetLocation> onTexture, float damageEffect = 0)
Parameters
childShape
ShapetexturePrefixCode
stringchildLocationForLogging
stringparentLocationForLogging
stringlogger
ILoggeronTexture
Action<string, AssetLocation>damageEffect
float
Returns
StepParentShape(Shape, string, string, ILogger, Action<string, AssetLocation>)
Adds a step parented shape to this shape, does not call the required pre-step SubclassForStepParenting()
public bool StepParentShape(Shape childShape, string childLocationForLogging, string parentLocationForLogging, ILogger logger, Action<string, AssetLocation> onTexture)
Parameters
childShape
ShapechildLocationForLogging
stringparentLocationForLogging
stringlogger
ILoggeronTexture
Action<string, AssetLocation>
Returns
SubclassForStepParenting(string, float)
Prefixes texturePrefixCode to all textures in this shape. Required pre-step for stepparenting. The long arguments StepParentShape() calls this method.
public bool SubclassForStepParenting(string texturePrefixCode, float damageEffect = 0)
Parameters
Returns
TrimTextureNamesAndResolveFaces(StreamingContext)
[OnDeserialized]
public void TrimTextureNamesAndResolveFaces(StreamingContext context)
Parameters
context
StreamingContext
TryGet(ICoreAPI, string)
Tries to load the shape from the specified JSON file, with error logging
Returns null if the file could not be found, or if there was an error
public static Shape TryGet(ICoreAPI api, string shapePath)
Parameters
Returns
TryGet(ICoreAPI, AssetLocation)
Tries to load the shape from the specified JSON file, with error logging
Returns null if the file could not be found, or if there was an error
public static Shape TryGet(ICoreAPI api, AssetLocation shapePath)
Parameters
api
ICoreAPIshapePath
AssetLocation
Returns
WalkElements(string, Action<ShapeElement>)
public void WalkElements(string wildcardpath, Action<ShapeElement> onElement)
Parameters
wildcardpath
stringonElement
Action<ShapeElement>