public static void FixEntityIdNumber(IEntityClass obj, Func<Type, int> iDCreator) { obj.GetType() .GetProperties() .Where(x => x.PropertyType.IsGenericType && x.PropertyType.GetInterfaces().Contains(typeof(IEnumerable))) .ToList().ForEach(x => UpdateCollection(obj.GetType().Name, obj.Id, x, obj, iDCreator)); }
public static void FixEntityIdNumber(IEntityClass obj, Func <Type, int> iDCreator) { obj.GetType() .GetProperties() .Where(x => x.PropertyType.IsGenericType && x.PropertyType.GetInterfaces().Contains(typeof(IEnumerable))) .ToList().ForEach(x => CollectionIdUpdater.UpdateCollectionIds(obj.GetType().Name, obj.Id, x, obj, iDCreator)); }
/// <summary> /// Only intended to be used by the EntityFramework itself! This constructor will setup the property handler, as well as the Editor 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 = ""; 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> /// Register the given entity prototype class. /// </summary> /// <param name="entityType">Entity class prototype.</param> public bool Register(Type entityType) { if (!typeof(BaseEntity).IsAssignableFrom(entityType)) { return(false); } EntityClass entry = new EntityClass(entityType); if (_registry.ContainsKey(entry.Description.sName)) { Log.Warning <EntityClassRegistry>("Managed entity class with name '{0}' already registered!", entry.Description.sName); return(false); } if (entityType.IsAbstract) { Log.Info <EntityClassRegistry>("Managed entity class with name '{0}' is abstract and will not be registered.", entry.Description.sName); return(false); } IEntityClass native = Global.gEnv.pEntitySystem.GetClassRegistry().FindClass(entry.Description.sName); if (native != null) { entry.Description.flags |= (int)EEntityClassFlags.ECLF_MODIFY_EXISTING; } entry.NativeClass = Global.gEnv.pEntitySystem.GetClassRegistry().RegisterStdClass(entry.Description); _registry [entry.Description.sName] = entry; Log.Info <EntityClassRegistry>("Registered managed entity class: {0}", entry.ProtoType.Name); return(true); }
private static void AddEntity(IEntityClass entity, IDictionary<Type, Dictionary<int, IEntityClass>> types) { Debug.Assert(entity != null); if (!types.ContainsKey(entity.GetType())) { types.Add(entity.GetType(), new Dictionary<int, IEntityClass>()); } if (!types[entity.GetType()].ContainsKey(entity.Id)) { types[entity.GetType()].Add(entity.Id, entity); } }
private static void AddEntity(IEntityClass entity, IDictionary <Type, Dictionary <int, IEntityClass> > types) { Debug.Assert(entity != null); if (!types.ContainsKey(entity.GetType())) { types.Add(entity.GetType(), new Dictionary <int, IEntityClass>()); } if (!types[entity.GetType()].ContainsKey(entity.Id)) { types[entity.GetType()].Add(entity.Id, entity); } }
/// <summary> /// Retrieve the managed entity class for a set of entity spawn parameters. /// </summary> /// <returns>'Null' if the intended entity class is not a managed entity class - otherwise the managed entity class.</returns> /// <param name="spawnParams">Entity spawn paramters.</param> public EntityClass GetEntityClass(IEntityClass pEntityClass) { if (pEntityClass == null) { return(null); } string className = pEntityClass.GetName(); EntityClass foundClass = null; _registry.TryGetValue(className, out foundClass); return(foundClass); }
/// <summary> /// Retrieve the managed entity class for a native CRYENGINE entity. /// </summary> /// <returns>'Null' if the native entity is not using a managed entity class - otherwise the managed entity class.</returns> /// <param name="pEntity">Native CRYENGINE entity.</param> public EntityClass GetEntityClass(IEntity pEntity) { if (pEntity == null || pEntity.IsGarbage()) { return(null); } IEntityClass pClass = pEntity.GetClass(); if (pClass == null) { return(null); } string className = pClass.GetName(); if (!_registry.ContainsKey(className)) { return(null); } return(_registry[className]); }
public void MarkUnchanged2(IEntityClass item) { _context.Entry(item).State = EntityState.Unchanged; }
public WebApiBusinessObjectsBase(RequestContext context, IEntityClass entity) : base(context.Zeus.Output) { this._context = context; this._entity = entity; }
public T EvalCommand <T>(string functionName, IEntityClass entity, object dataObject, T defaultValue = default(T)) { var entityName = entity != null ? "_" + entity.Name : ""; return(EvalCommand(functionName, entityName, dataObject, defaultValue)); }