Example #1
0
        private static void AddComponentInstanceToEntity(Entity parentEntity, ComponentInstance componentInstance)
        {
            componentInstance.ParentEntity = parentEntity;
            ComponentInstancesDB instancesDict = parentEntity.GetDataBlob <ComponentInstancesDB>();

            instancesDict.AddComponentInstance(componentInstance);
            foreach (var atbkvp in componentInstance.Design.AttributesByType)
            {
                atbkvp.Value.OnComponentInstallation(parentEntity, componentInstance);
            }
        }
Example #2
0
        /// <summary>
        /// This is for adding and exsisting component or installation *instance* to ships and colonies.
        /// doesn't force a Recalc. hence being private.
        /// </summary>
        /// <param name="instance">an exsisting componentInstance</param>
        /// <param name="parentEntity">entity that contains an ComponentInstancesDB ie a ship or colony</param>
        private static void AddComponentInstanceToEntity(Entity parentEntity, Entity instance)
        {
            Entity design = instance.GetDataBlob <ComponentInstanceInfoDB>().DesignEntity;

            foreach (IComponentDesignAttribute attribute in design.DataBlobs.Where(item => item is IComponentDesignAttribute))
            {
                attribute.OnComponentInstalation(parentEntity, instance);
            }
            instance.GetDataBlob <ComponentInstanceInfoDB>().ParentEntity = parentEntity;
            //AttributeToAbilityMap.AddAbility(parentEntity, design, instance);

            ComponentInstancesDB instancesDict = parentEntity.GetDataBlob <ComponentInstancesDB>();

            instancesDict.AddComponentInstance(instance);
        }