Skip to content

Commit

Permalink
Merge pull request AtomicGameEngine#1007 from LumaDigital/MB_PortCPPToCS
Browse files Browse the repository at this point in the history
Fix components in separate dlls being available
  • Loading branch information
JoshEngebretson authored Sep 13, 2016
2 parents 0d3ef23 + 793ea2c commit 64c3dd2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
54 changes: 38 additions & 16 deletions Script/AtomicNET/AtomicNET/Scene/CSComponentCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,21 @@ void HandleComponentLoad(uint eventType, ScriptVariantMap eventData)

}

void HandleComponentAssemblyReference(uint eventType, ScriptVariantMap eventData)
{
#if ATOMIC_DESKTOP || ATOMIC_ANDROID
string assemblyPath = eventData["AssemblyPath"];

string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath);
if (componentCache.ContainsKey(assemblyName))
return;

Assembly assembly = Assembly.LoadFrom(assemblyPath);

ParseAssembly(assembly);
#endif
}

void ParseComponents()
{
#if ATOMIC_DESKTOP || ATOMIC_ANDROID
Expand All @@ -340,27 +355,33 @@ void ParseComponents()

foreach (Assembly assembly in assemblies)
{
String assemblyPath = assembly.GetName().Name;
ParseAssembly(assembly);
}
#endif
}

void ParseAssembly(Assembly assembly)
{
#if ATOMIC_DESKTOP || ATOMIC_ANDROID
String assemblyPath = assembly.GetName().Name;

Dictionary<string, CSComponentInfo> assemblyTypes = null;
Dictionary<string, CSComponentInfo> assemblyTypes = null;

if (!componentCache.TryGetValue(assemblyPath, out assemblyTypes))
{
componentCache[assemblyPath] = assemblyTypes = new Dictionary<string, CSComponentInfo>();
}
if (!componentCache.TryGetValue(assemblyPath, out assemblyTypes))
{
componentCache[assemblyPath] = assemblyTypes = new Dictionary<string, CSComponentInfo>();
}

Type[] types = assembly.GetTypes();
Type[] types = assembly.GetTypes();

foreach (var type in types)
foreach (var type in types)
{
if (type.IsSubclassOf(typeof(CSComponent)))
{
if (type.IsSubclassOf(typeof(CSComponent)))
{
var csinfo = new CSComponentInfo(type);
csinfoLookup[csinfo.Type] = csinfo;
assemblyTypes[type.Name] = csinfo;
}
var csinfo = new CSComponentInfo(type);
csinfoLookup[csinfo.Type] = csinfo;
assemblyTypes[type.Name] = csinfo;
}

}
#endif
}
Expand All @@ -370,7 +391,8 @@ internal static void Initialize()

instance = new CSComponentCore();
instance.ParseComponents();


instance.SubscribeToEvent("CSComponentAssemblyReference", instance.HandleComponentAssemblyReference);
instance.SubscribeToEvent("CSComponentLoad", instance.HandleComponentLoad);
instance.SubscribeToEvent("Update", instance.HandleUpdate);

Expand Down
6 changes: 6 additions & 0 deletions Source/Atomic/Graphics/AnimatedModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@ void AnimatedModel::ResetMorphWeights()
MarkNetworkUpdate();
}

Node* AnimatedModel::GetSkeletonBoneNode(const String & boneName)
{
Bone* bone = skeleton_.GetBone(boneName);
return (bone) ? bone->node_ : NULL;
}

float AnimatedModel::GetMorphWeight(unsigned index) const
{
return index < morphs_.Size() ? morphs_[index].weight_ : 0.0f;
Expand Down
2 changes: 2 additions & 0 deletions Source/Atomic/Graphics/AnimatedModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class ATOMIC_API AnimatedModel : public StaticModel

/// Return skeleton.
Skeleton& GetSkeleton() { return skeleton_; }
/// Return the node of a skeleton bone (for script access)
Node* GetSkeletonBoneNode(const String& boneName);

/// Return all animation states.
const Vector<SharedPtr<AnimationState> >& GetAnimationStates() const { return animationStates_; }
Expand Down

0 comments on commit 64c3dd2

Please sign in to comment.