Exemple #1
0
        static public BaseComponent LoadComponent(BaseEntity parent, ComponentType type, ContentManager contentManager, string XMLDefinitionPath)
        {
            // This is a factory for creating any component based on a ComponentType
            switch (type)
            {
            case ComponentType.RenderComponent:
            {
                BaseComponent newComponent = RenderComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CameraComponent:
            {
                BaseComponent newComponent = CameraComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ConstantMovementComponent:
            {
                BaseComponent newComponent = ConstantMovementComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ConstantRotationComponent:
            {
                BaseComponent newComponent = ConstantRotationComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.FreeCameraInputComponent:
            {
                BaseComponent newComponent = FreeCameraInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.LightEmitterComponent:
            {
                BaseComponent newComponent = LightEmitterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.PhysicsComponent:
            {
                BaseComponent newComponent = PhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.PhantomPhysicsComponent:
            {
                BaseComponent newComponent = PhantomPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CharacterPhysicsComponent:
            {
                BaseComponent newComponent = CharacterPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CharacterInputComponent:
            {
                BaseComponent newComponent = CharacterInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.WaterComponent:
            {
                BaseComponent newComponent = WaterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ArcBallCameraInputComponent:
            {
                BaseComponent newComponent = ArcBallCameraInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ParticleEmitterComponent:
            {
                BaseComponent newComponent = ParticleEmitterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.SkyDomeComponent:
            {
                BaseComponent newComponent = SkyDomeComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CollisionTriggerComponent:
            {
                BaseComponent newComponent = CollisionTriggerComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.TerrainComponent:
            {
                BaseComponent newComponent = TerrainComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.TerrainPhysicsComponent:
            {
                BaseComponent newComponent = TerrainPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.WaterVolumePhysicsComponent:
            {
                BaseComponent newComponent = WaterVolumePhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.Invalid:
            {
                throw new ArgumentException(String.Format("Invalid component type passed, type {0} is not valid", type));
            }

            default:
            {
                throw new ArgumentException(String.Format("Invalid component type passed, type {0} is not valid", type));
            }
            }
        }