internal void _updateMap() { var tempList = new EudiStructList <Type>(0); // Get all components (SPAGHETTI CODE!!!) var components = Wrapper.GetComponents <Component>(); for (int i = 0; i < components.Length; i++) { var component = components[i]; tempList.Add(component.GetType()); } if (ComponentMap == null) { ComponentMap = new EudiMap(); } ComponentMap.TuplesItems = new EudiMap.TupleItem[tempList.Length]; for (int i = 0; i < tempList.Length; i++) { ComponentMap.TuplesItems[i] = new EudiMap.TupleItem() { Type = tempList[i], Attribute = null }; } tempList.Dispose(); }
protected internal override void InternalSystemAwake() { List <EudiMap.TupleItem> tempItems = new List <EudiMap.TupleItem>(); List <FieldInfo> tempCorrectFields = new List <FieldInfo>(); var type = GetType(); var fields = type.GetFields(); var fieldsCount = fields.Length; for (int i = 0; i < fieldsCount; i++) { var field = fields[i]; var hasTupleAttribute = Attribute.IsDefined(field, typeof(InjectTuplesAttribute)); if (hasTupleAttribute) { var item = new EudiMap.TupleItem(); item.Attribute = (InjectTuplesAttribute)Attribute.GetCustomAttribute(field, typeof(InjectTuplesAttribute)); item.Type = field.FieldType; tempItems.Add(item); tempCorrectFields.Add(field); } } _linkedMap = Eudi.EntitiesManager.MapManager.GetMap(tempItems.ToArray()); MatchEntities = Eudi.EntitiesManager.MapManager.GetEntities(_linkedMap); // Set fields value from the map foreach (var field in tempCorrectFields) { var isGeneric = field.FieldType.IsGenericType; var wantedType = field.FieldType; var obj = _linkedMap.GetAssignedObject(wantedType); if (obj == null) { Debug.LogError(new Exception($"Field {field.Name} (c:{field.DeclaringType?.Name}) was set to null!")); } field.SetValue(this, obj); } if (_linkedMap == null || tempItems.Count == 0) { Debug.LogWarning($"!!! System {GetType().FullName} got no `InjectTuple` attribute."); tempItems?.Clear(); tempItems = null; //< remove reference } }