//--------------------------------------------------------------------- public EntityDef getEntityDef(string entity_type) { EntityDef entity_def = null; mMapEntityDef.TryGetValue(entity_type, out entity_def); if (entity_def == null) { EbLog.Error("EntityMgr.getEntityDef() Error! 不存在entity_type=" + entity_type); } return(entity_def); }
//--------------------------------------------------------------------- public void _reset(EntityData entity_data) { SignDestroy = false; Type = entity_data.entity_type; Guid = entity_data.entity_guid; mMapCacheData = entity_data.cache_data; mPublisher = new EntityEventPublisher(EntityMgr); mPublisher.addHandler(this); EntityDef entity_def = EntityMgr.getEntityDef(entity_data.entity_type); if (entity_def == null) { return; } foreach (var i in entity_def.ListComponentDef) { IComponentFactory component_factory = EntityMgr.getComponentFactory(i); if (component_factory == null) { EbLog.Error("Entity.addComponent() failed! can't find component_factory, component=" + i); continue; } Dictionary <string, string> def_propset = null; if (entity_data.map_component != null) { entity_data.map_component.TryGetValue(i, out def_propset); } var component = component_factory.createComponent(this, def_propset); mMapComponent[i] = component; mListComponent.Add(component); component.awake(); } }