Esempio n. 1
0
        private void CreateRcs(EntityController entityController, Resolver <IComponentFactory> factories, Entity partEntity, RCSBluePrint rcsBluePrint, Content content)
        {
            var count = 4;
            var step  = MathHelper.TwoPi / count;

            for (var r = 0; r < count; r++)
            {
                var rcsEntity = entityController.CreateEntity("RCS_Root");
                factories.Get <PoseFactory>().Construct(rcsEntity, Vector3.Zero);
                factories.Get <OffsetFactory>().Construct(rcsEntity, Vector3.Zero, 0, 0, step * r, partEntity);
                factories.Get <OpaqueModelFactory>().Construct(rcsEntity, rcsBluePrint.Model);

                var emitters = new Entity[rcsBluePrint.Exhausts.Length];
                for (var i = 0; i < rcsBluePrint.Exhausts.Length; i++)
                {
                    var exhaust       = rcsBluePrint.Exhausts[i];
                    var exhaustEntity = entityController.CreateEntity($"RCS_Exhaust_{i}");
                    factories.Get <PoseFactory>().Construct(exhaustEntity, Vector3.Zero, 0.1f);
                    factories.Get <OffsetFactory>().Construct(exhaustEntity, exhaust.Offset, exhaust.Yaw, exhaust.Pitch, exhaust.Roll, rcsEntity);

                    var emitter = factories.Get <AdditiveEmitterFactory>().ConstructAdditiveEmitter(exhaustEntity, content.Explosion2, 1, 1);
                    emitter.SpawnInterval = 0.0f;
                    emitter.Spread        = 0.1f;
                    emitter.Speed         = 6.0f;
                    emitter.TimeToLive    = 0.15f;

                    emitters[i] = exhaustEntity;
                }

                factories.Get <ReactionControlFactory>().Construct(rcsEntity, emitters);
            }
        }
Esempio n. 2
0
        private void BuildParts(Content content, Resolver <IComponentFactory> factories, EntityController entityController, Entity root, Model connector, RCSBluePrint rcsBluePrint, int[] rcsPositions, params FuselageBluePrint[] bluePrints)
        {
            var totalHeight   = bluePrints.Sum(x => x.Height);
            var currentHeight = -(totalHeight / 2.0f);

            var children = new Entity[(bluePrints.Length * 2) - 1];
            var c        = 0;

            for (var i = 0; i < bluePrints.Length; i++)
            {
                var bluePrint = bluePrints[i];

                var toCenterOfMass = Vector3.Forward * bluePrint.Height * 0.5f;
                var offset         = (Vector3.Forward * currentHeight) + toCenterOfMass;

                currentHeight += bluePrint.Height;

                var entity = entityController.CreateEntity($"SpaceShip_Part_{i}");
                this.AddPart(factories, root, bluePrint.Model, offset, entity);
                children[c++] = entity;

                if (bluePrint.Exhausts.Length > 0)
                {
                    this.CreateExhausts(entityController, factories, root, entity, bluePrint, content);
                }

                if (rcsPositions.Contains(i))
                {
                    this.CreateRcs(entityController, factories, entity, rcsBluePrint, content);
                }

                if (i < bluePrints.Length - 1)
                {
                    offset += toCenterOfMass;
                    entity  = entityController.CreateEntity($"SpaceShip_Part_Cap_{i}");
                    this.AddPart(factories, root, connector, offset, entity);
                    children[c++] = entity;
                }
            }

            factories.Get <ParentFactory>().Construct(root, children);
        }