Example #1
0
        private IEnumerable Intro(Story story, EntityWorld world)
        {
            var bgGenerator = ServiceLocator.Instance.GetService<SpaceBackgroundGeneratorService>();
            bgGenerator.GenerateBackground(world, 12345);

            var entity = world.CreateStoryOverlay(Properties.Resources.String_ActOne_Intro01);

            yield return Coroutine.WaitFor(TimeSpan.FromSeconds(2));
            entity.FadeGuiElement(TimeSpan.FromSeconds(1.5), 0)
                .OnDone = () => entity.Delete();
            yield return Coroutine.WaitFor(TimeSpan.FromSeconds(2));

            var variant = new ShipVariant
            {
                HullId = "Jormugand",
                TrimDecalColor = Color.Cyan,
                BaseDecalColor = new Color(212, 113, 108),
            };
            _playerEntity = world.CreateShip(variant, new Vector2(500,0),0, physics:true);
            _playerEntity.Tag = "PlayerShip";
            _playerEntity.Refresh();
            var cameraControl = world.SystemManager.GetSystem<Systems.CameraControlSystem>();
            cameraControl.Mode = Systems.CameraMode.FollowEntity;
            cameraControl.FollowedEntity = _playerEntity;

            var test = world.CreateShip("mobius", new Vector2(0, 0), MathHelper.Pi * 1.5f, physics:true);
            test.GetComponent<ShipModelComponent>().BaseDecalColor = Color.Khaki;

            story.State.Fire(Story.Triggers.NextScene);
            yield return null;
        }
Example #2
0
 public static Entity CreateShip(this EntityWorld world, ShipVariant variant, Vector2 position, float rotation = 0, Vector2? scale = null, bool physics = true)
 {
     var entity = CreateShip(world, variant.HullId, position, rotation, scale, physics);
     var ship = entity.GetComponent<ShipComponent>();
     ship.Variant = variant;
     variant.ApplyVariant(world, entity);
     // Todo: install weapons
     return entity;
 }
Example #3
0
 private ShipVariant CreateVariantFromEntity(Entity entity)
 {
     var shipComponent = entity.GetComponent<ShipComponent>();
     var variant = new ShipVariant();
     variant.HullId = shipComponent.Ship.Id;
     variant.Weapons = shipComponent.Hardpoints.Select(h =>
     {
         var hpc = h.GetComponent<HardpointComponent>();
         if (hpc == null) return null;
         return new
         {
             HardpointId = hpc.Hardpoint.Id,
             Weapon = hpc.InstalledEntity?.GetComponent<WeaponComponent>()?.Weapon.Id
         };
     }).ToDictionary(k => k.HardpointId, v => v.Weapon);
     //Modules=      // TODO
     variant.BaseDecalColor = entity.GetComponent<ShipModelComponent>().BaseDecalColor;
     variant.TrimDecalColor = entity.GetComponent<ShipModelComponent>().TrimDecalColor;
     variant.VariantName = $"{shipComponent.Ship.HullClass} Custom";
     return variant;
 }