Ejemplo n.º 1
0
        public void Fire(ParticleAcceleratorPowerState state, Angle angle, EntityUid firer)
        {
            State = state;

            if (!_entMan.TryGetComponent <PhysicsComponent?>(Owner, out var physicsComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
                return;
            }
            physicsComponent.BodyStatus = BodyStatus.InAir;

            if (!_entMan.TryGetComponent <ProjectileComponent?>(Owner, out var projectileComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent");
                return;
            }
            projectileComponent.IgnoreEntity(firer);

            if (!_entMan.TryGetComponent <SinguloFoodComponent?>(Owner, out var singuloFoodComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
                return;
            }
            var multiplier = State switch
            {
                ParticleAcceleratorPowerState.Standby => 0,
                ParticleAcceleratorPowerState.Level0 => 1,
                ParticleAcceleratorPowerState.Level1 => 3,
                ParticleAcceleratorPowerState.Level2 => 6,
                ParticleAcceleratorPowerState.Level3 => 10,
                _ => 0
            };

            singuloFoodComponent.Energy = 10 * multiplier;

            var suffix = state switch
            {
                ParticleAcceleratorPowerState.Level0 => "0",
                ParticleAcceleratorPowerState.Level1 => "1",
                ParticleAcceleratorPowerState.Level2 => "2",
                ParticleAcceleratorPowerState.Level3 => "3",
                _ => "0"
            };

            if (!_entMan.TryGetComponent <SpriteComponent?>(Owner, out var spriteComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent");
                return;
            }
            spriteComponent.LayerSetState(0, $"particle{suffix}");

            physicsComponent
            .LinearVelocity = angle.ToWorldVec() * 20f;

            _entMan.GetComponent <TransformComponent>(Owner).LocalRotation = angle;
            Timer.Spawn(3000, () => _entMan.DeleteEntity(Owner));
        }
    }
}
        public void Fire(ParticleAcceleratorPowerState strength)
        {
            var projectile = _entityManager.SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);

            if (!projectile.TryGetComponent <ParticleProjectileComponent>(out var particleProjectileComponent))
            {
                Logger.Error("ParticleAcceleratorEmitter tried firing particles, but they was spawned without a ParticleProjectileComponent");
                return;
            }
            particleProjectileComponent.Fire(strength, Owner.Transform.WorldRotation, Owner);
        }
Ejemplo n.º 3
0
        public void Fire(ParticleAcceleratorPowerState strength)
        {
            var entities   = IoCManager.Resolve <IEntityManager>();
            var projectile = entities.SpawnEntity("ParticlesProjectile", entities.GetComponent <TransformComponent>(Owner).Coordinates);

            if (!entities.TryGetComponent <ParticleProjectileComponent?>(projectile, out var particleProjectileComponent))
            {
                Logger.Error("ParticleAcceleratorEmitter tried firing particles, but they was spawned without a ParticleProjectileComponent");
                return;
            }
            particleProjectileComponent.Fire(strength, entities.GetComponent <TransformComponent>(Owner).WorldRotation, Owner);
        }
Ejemplo n.º 4
0
 private int PowerDrawFor(ParticleAcceleratorPowerState strength)
 {
     return(strength switch
     {
         ParticleAcceleratorPowerState.Standby => 0,
         ParticleAcceleratorPowerState.Level0 => 1,
         ParticleAcceleratorPowerState.Level1 => 3,
         ParticleAcceleratorPowerState.Level2 => 4,
         ParticleAcceleratorPowerState.Level3 => 5,
         _ => 0
     } *_powerDrawMult + _powerDrawBase);
 }
        public void Fire(ParticleAcceleratorPowerState state, Angle angle, EntityUid firer)
        {
            State = state;

            if (!_entMan.TryGetComponent <PhysicsComponent?>(Owner, out var physicsComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
                return;
            }
            physicsComponent.BodyStatus = BodyStatus.InAir;

            if (!_entMan.TryGetComponent <ProjectileComponent?>(Owner, out var projectileComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent");
                return;
            }

            _entMan.EntitySysManager.GetEntitySystem <ProjectileSystem>().SetShooter(projectileComponent, firer);

            if (!_entMan.TryGetComponent <SinguloFoodComponent?>(Owner, out var singuloFoodComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
                return;
            }
            var multiplier = State switch
            {
                ParticleAcceleratorPowerState.Standby => 0,
                ParticleAcceleratorPowerState.Level0 => 1,
                ParticleAcceleratorPowerState.Level1 => 3,
                ParticleAcceleratorPowerState.Level2 => 6,
                ParticleAcceleratorPowerState.Level3 => 10,
                _ => 0
            };

            singuloFoodComponent.Energy = 10 * multiplier;

            if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance))
            {
                appearance.SetData(ParticleAcceleratorVisuals.VisualState, state);
            }

            physicsComponent.LinearVelocity = angle.ToWorldVec() * 20f;

            _entMan.GetComponent <TransformComponent>(Owner).LocalRotation = angle;
            Timer.Spawn(3000, () => _entMan.DeleteEntity(Owner));
        }
    }
 public ParticleAcceleratorUIState(bool assembled, bool enabled, ParticleAcceleratorPowerState state, int powerReceive, int powerDraw, bool emitterLeftExists, bool emitterCenterExists, bool emitterRightExists, bool powerBoxExists, bool fuelChamberExists, bool endCapExists, bool interfaceBlock, ParticleAcceleratorPowerState maxLevel, bool wirePowerBlock)
 {
     Assembled           = assembled;
     Enabled             = enabled;
     State               = state;
     PowerDraw           = powerDraw;
     PowerReceive        = powerReceive;
     EmitterLeftExists   = emitterLeftExists;
     EmitterCenterExists = emitterCenterExists;
     EmitterRightExists  = emitterRightExists;
     PowerBoxExists      = powerBoxExists;
     FuelChamberExists   = fuelChamberExists;
     EndCapExists        = endCapExists;
     InterfaceBlock      = interfaceBlock;
     MaxLevel            = maxLevel;
     WirePowerBlock      = wirePowerBlock;
 }
        public void Fire(ParticleAcceleratorPowerState state, Angle angle, IEntity firer)
        {
            _state = state;

            if (!Owner.TryGetComponent <PhysicsComponent>(out var physicsComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent");
                return;
            }
            physicsComponent.Status = BodyStatus.InAir;

            if (!Owner.TryGetComponent <ProjectileComponent>(out var projectileComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent");
                return;
            }
            projectileComponent.IgnoreEntity(firer);

            var suffix = state switch
            {
                ParticleAcceleratorPowerState.Level0 => "0",
                ParticleAcceleratorPowerState.Level1 => "1",
                ParticleAcceleratorPowerState.Level2 => "2",
                ParticleAcceleratorPowerState.Level3 => "3",
                _ => "0"
            };

            if (!Owner.TryGetComponent <SpriteComponent>(out var spriteComponent))
            {
                Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent");
                return;
            }
            spriteComponent.LayerSetState(0, $"particle{suffix}");

            physicsComponent
            .EnsureController <BulletController>()
            .LinearVelocity = angle.ToWorldVec() * 20f;

            Owner.Transform.LocalRotation = angle;
            Timer.Spawn(3000, () => Owner.Delete());
        }
    }
Ejemplo n.º 8
0
        public void SetStrength(ParticleAcceleratorPowerState state)
        {
            if (_wireStrengthCut)
            {
                return;
            }

            state = (ParticleAcceleratorPowerState)MathHelper.Clamp(
                (int)state,
                (int)ParticleAcceleratorPowerState.Standby,
                (int)MaxPower);

            _selectedStrength = state;
            UpdateAppearance();
            UpdatePartVisualStates();

            if (_isEnabled)
            {
                UpdatePowerDraw();
                UpdateFiring();
            }
        }
 public ParticleAcceleratorSetPowerStateMessage(ParticleAcceleratorPowerState state)
 {
     State = state;
 }
Ejemplo n.º 10
0
 public void SendPowerStateMessage(ParticleAcceleratorPowerState state)
 {
     SendMessage(new ParticleAcceleratorSetPowerStateMessage(state));
 }