private void ApplyEntityTypePatch(EntityTypeAttributes entityType, EntityTypePatch entityTypePatch) { applyUnnamedCPatch <ExperienceAttributes, ExperienceAttributesWrapper>(entityType, entityTypePatch.ExperienceAttributes, x => new ExperienceAttributesWrapper(x)); applyUnnamedCPatch <HarvesterAttributes, HarvesterAttributesWrapper>(entityType, entityTypePatch.HarvesterAttributes, x => new HarvesterAttributesWrapper(x)); applyUnnamedCPatch <UnitAttributes, UnitAttributesWrapper>(entityType, entityTypePatch.UnitAttributes, x => new UnitAttributesWrapper(x)); applyUnnamedCPatch <ResearchItemAttributes, ResearchItemAttributesWrapper>(entityType, entityTypePatch.ResearchItemAttributes, x => new ResearchItemAttributesWrapper(x)); applyUnnamedCPatch <UnitHangarAttributes, UnitHangarAttributesWrapper>(entityType, entityTypePatch.UnitHangarAttributes, x => new UnitHangarAttributesWrapper(x)); applyUnnamedCPatch <DetectableAttributes, DetectableAttributesWrapper>(entityType, entityTypePatch.DetectableAttributes, x => new DetectableAttributesWrapper(x)); applyUnnamedCPatch <UnitMovementAttributes, UnitMovementAttributesWrapper>(entityType, entityTypePatch.UnitMovementAttributes, x => new UnitMovementAttributesWrapper(x)); applyUnnamedCPatch <StatusEffectAttributes, StatusEffectAttributesWrapper>(entityType, entityTypePatch.StatusEffectAttributes, x => new StatusEffectAttributesWrapper(x)); applyUnnamedCPatch <PowerShuntAttributes, PowerShuntAttributesWrapper>(entityType, entityTypePatch.PowerShuntAttributes, x => new PowerShuntAttributesWrapper(x)); applyUnnamedCPatch <ProjectileAttributes, ProjectileAttributesWrapper>(entityType, entityTypePatch.ProjectileAttributes, x => new ProjectileAttributesWrapper(x)); applyUnnamedCPatch <ResourceAttributes, ResourceAttributesWrapper>(entityType, entityTypePatch.ResourceAttributes, x => new ResourceAttributesWrapper(x)); applyUnnamedCPatch <RelicAttributes, RelicAttributesWrapper>(entityType, entityTypePatch.RelicAttributes, x => new RelicAttributesWrapper(x)); applyUnnamedCPatch <AbilityViewAttributes, AbilityViewAttributes>(entityType, entityTypePatch.AbilityViewAttributes, x => ViewCloneFunctions.CloneAbilityViewAttributes(x)); applyNamedCPatch <AbilityAttributes, AbilityAttributesWrapper, Patch.AbilityAttributesPatch>(entityType, entityTypePatch.AbilityAttributes, x => new AbilityAttributesWrapper(x)); applyNamedCPatch <StorageAttributes, StorageAttributesWrapper, Patch.StorageAttributesPatch>(entityType, entityTypePatch.StorageAttributes, x => new StorageAttributesWrapper(x)); applyNamedCPatch <WeaponAttributes, WeaponAttributesWrapper, Patch.WeaponAttributesPatch>(entityType, entityTypePatch.WeaponAttributes, x => new WeaponAttributesWrapper(x)); // Changing these doesn't seem to do anything, they are likely a special case, maybe are loaded before the game applyUnnamedCPatch <FactionAttributes, FactionAttributesWrapper>(entityType, entityTypePatch.FactionAttributes, x => new FactionAttributesWrapper(x)); applyUnnamedCPatch <TechTreeAttributes, TechTreeAttributesWrapper>(entityType, entityTypePatch.TechTreeAttributes, x => new TechTreeAttributesWrapper(x)); }
public void ApplyAttributesPatch(EntityTypeCollection entityTypeCollection, AttributesPatch attributesPatch) { logger.Log("[ APPLYING ENTITY TYPE ATTRIBUTES ]"); foreach (var kvp in attributesPatch.Entities) { string entityTypeName = kvp.Key; EntityTypePatch entityTypePatch = kvp.Value; EntityTypeAttributes entityType; if (!entityTypePatch.CloneFrom.IsNullOrEmpty()) { EntityTypeAttributes toClone = entityTypeCollection.GetEntityType(entityTypePatch.CloneFrom); if (toClone == null) { logger.Log($"ERROR: CloneFrom {entityTypePatch.CloneFrom} attributes not found"); continue; } entityType = new EntityTypeAttributes(entityTypeName) { Flags = toClone.Flags }; var attributes = toClone.GetAll <object>(); foreach (var w in attributes) { entityType.Add(w); } entityTypeCollection.Add(entityType); logger.BeginScope($"Cloned {entityTypeName} from {entityTypePatch.CloneFrom}").Dispose(); } else { entityType = entityTypeCollection.GetEntityType(entityTypeName); } using (logger.BeginScope($"EntityType: {entityTypeName}")) { if (entityType == null) { if (entityTypePatch.CloneFrom.IsNullOrEmpty()) { logger.Log("NOTICE: EntityType not found"); } else { logger.Log("ERROR: Entity cloning failed"); } continue; } ApplyEntityTypePatch(entityType, entityTypePatch); } } if (attributesPatch.Global != null) { logger.Log("[ APPLYING GLOBAL TYPE ATTRIBUTES ]"); //logger.enable = false; notFoundErrors = false; foreach (var kvp in entityTypeCollection.GetAllEntityTypeNames()) { using (logger.BeginScope($"{kvp}:")) { ApplyEntityTypePatch(entityTypeCollection.GetEntityType(kvp), attributesPatch.Global); } } //logger.enable = true; notFoundErrors = true; } Debug.Log($"[SUBSYSTEM] Applied attributes patch. See Subsystem.log for details."); }