/// <summary> /// Only intended to be used by the EntityFramework itself! This consutrctor will setup the property handler, as well as the sadnbox-relevant metadata description for the engine. /// </summary> /// <param name="t">Prototype the entity class should be created for.</param> internal EntityClass(Type t) { _nativeClass = null; _protoType = t; _description = new IEntityClassRegistry.SEntityClassDesc(); _description.editorClassInfo = new SEditorClassInfo(); _description.sScriptFile = ""; _propertyHandler = EntityPropertyHandler.CreateHandler(this); if (_propertyHandler != null) { _description.pPropertyHandler = _propertyHandler; } EntityClassAttribute attrib = (EntityClassAttribute)t.GetCustomAttributes(typeof(EntityClassAttribute), true).FirstOrDefault(); if (attrib == null) { _description.sName = t.Name; _description.editorClassInfo.sCategory = "Game"; } else { _description.sName = attrib.Name; _description.editorClassInfo.sCategory = attrib.EditorPath; _description.editorClassInfo.sHelper = attrib.Helper; _description.editorClassInfo.sIcon = attrib.Icon; if (attrib.Hide) { _description.flags |= (int)EEntityClassFlags.ECLF_INVISIBLE; } } }
/// <summary> /// Attempt to create a property handler for the given managed entity class. /// </summary> /// <returns>'Null' if the given entity class prototype doesn't expose any properties, that can be handled. Otherwise an instance of the PropertyHandler for the given managed entity class.</returns> /// <param name="parent">Parent.</param> internal static EntityPropertyHandler CreateHandler(EntityClass parent) { EntityPropertyHandler instance = new EntityPropertyHandler(parent); if (!instance.Init()) { instance.Dispose(); instance = null; } return(instance); }