Beispiel #1
0
        /// <summary>
        /// This is for adding components and installations to ships and colonies.
        /// </summary>
        /// <param name="parentEntity">entity that contains an ComponentInstancesDB</param>
        /// <param name="componentEntity">Can be either a design or instance entity</param>
        internal static void AddComponentToEntity(Entity parentEntity, Entity componentEntity, Entity ownerFaction, FactionOwnerDB ownerDB)
        {
            Entity instance;

            if (parentEntity.HasDataBlob <ComponentInstancesDB>())
            {
                if (!componentEntity.HasDataBlob <ComponentInstanceInfoDB>())
                {
                    if (componentEntity.HasDataBlob <ComponentInfoDB>())
                    {
                        instance = ComponentInstanceFactory.NewInstanceFromDesignEntity(componentEntity, ownerFaction, ownerDB, parentEntity.Manager);
                    }
                    else
                    {
                        throw new Exception("componentEntity does not contain either a ComponentInfoDB or a ComponentInstanceInfoDB. Entity Not a ComponentDesign or ComponentInstance");
                    }
                }
                else
                {
                    instance = componentEntity;
                }

                AddComponentInstanceToEntity(parentEntity, instance);
            }
            else
            {
                throw new Exception("parentEntiy does not contain a ComponentInstanceDB");
            }
            ObjectOwnershipDB parentOwner;

            if (!parentEntity.HasDataBlob <ObjectOwnershipDB>())
            {
                //StarSystem starSys = parentEntity.GetDataBlob<PositionDB>().SystemGuid
                parentOwner = new ObjectOwnershipDB();
                parentEntity.SetDataBlob(parentOwner);
            }
            else
            {
                parentOwner = parentEntity.GetDataBlob <ObjectOwnershipDB>();
            }
            parentOwner.Children.Add(instance);
            ReCalcProcessor.ReCalcAbilities(parentEntity);
        }
Beispiel #2
0
 ObjectOwnershipDB(ObjectOwnershipDB toClone) : base(toClone.Parent)
 {
     //ParentStarSystem = toClone.ParentStarSystem;
     //OwnedEntities = new Dictionary<Guid, Entity>(toClone.OwnedEntities);
 }