Skip to content

Commit

Permalink
ICompositeParent: Added some generic methods for getting concrete-t…
Browse files Browse the repository at this point in the history
…yped children.
  • Loading branch information
cocodrilodog committed May 28, 2024
1 parent 13f43cf commit 05df56b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Scripts/MotionKitBlocks/Motion3DBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace CocodriloDog.MotionKit {
/// Block for <see cref="Vector3"/> motions.
/// </summary>
[Serializable]
public class Motion3DBlock : MotionBaseBlock<Vector3, Motion3D, Motion2DValues> {
public class Motion3DBlock : MotionBaseBlock<Vector3, Motion3D, Motion3DValues> {


#region Public Methods
Expand Down
2 changes: 1 addition & 1 deletion Scripts/MotionKitBlocks/MotionKitComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public MotionKitBlock GetChild(string name) {

public T GetChild<T>(string name) where T : MotionKitBlock {
TryInitialize();
return Blocks.FirstOrDefault(b => b != null && b.Name == name) as T;
return GetChild(name) as T;
}

public MotionKitBlock GetChildAtPath(string path) {
Expand Down
4 changes: 4 additions & 0 deletions Scripts/MotionKitBlocks/ParallelBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ public override void Dispose() {

public MotionKitBlock GetChild(string name) => Items.FirstOrDefault(b => b != null && b.Name == name);

public T GetChild<T>(string name) where T : MotionKitBlock => GetChild(name) as T;

public MotionKitBlock GetChildAtPath(string path) => CompositeObjectUtility.GetChildAtPath(this, path);

public T GetChildAtPath<T>(string path) where T : MotionKitBlock => GetChildAtPath(path) as T;

public MotionKitBlock[] GetChildren() => Items.ToArray();

public override void SetItem(int index, MotionKitBlock block) => m_ParallelItems[index] = block;
Expand Down
8 changes: 8 additions & 0 deletions Scripts/MotionKitBlocks/SequenceBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@ public override void Dispose() {

public MotionKitBlock GetChild(string name) => Items.FirstOrDefault(b => b != null && b.Name == name);

public T GetChild<T>(string name) where T : MotionKitBlock {
return GetChild(name) as T;
}

public MotionKitBlock GetChildAtPath(string path) => CompositeObjectUtility.GetChildAtPath(this, path);

public T GetChildAtPath<T>(string path) where T : MotionKitBlock {
return GetChildAtPath(path) as T;
}

public MotionKitBlock[] GetChildren() => Items.ToArray();

public override void SetItem(int index, MotionKitBlock block) => m_SequenceItems[index] = block;
Expand Down

0 comments on commit 05df56b

Please sign in to comment.