public override void Tick() { base.Tick(); if (World.Game.Editor) { return; } if (projectile.OrientateToTarget) { Rotation = new VAngle(0, 0, -(TargetPosition - GraphicPosition).FlatAngle); } if (projectile.FollowTarget) { TargetPosition = Target.Position; TargetHeight = Target.Height; calculateAngle(); calculateSpeed(); } Move(); if (projectile.TrailParticles != null) { World.Add(projectile.TrailParticles.Create(World, Position, Height)); } }
public Particle(World world, ParticleInit init) : base(init.Position, init.Type.GetRenderable()) { this.world = world; Type = init.Type; Height = init.Height; current = init.Convert("Duration", Type.Duration); dissolve = init.Convert("DissolveDuration", Type.DissolveDuration); velocity = init.Convert("Velocity", ParticleUtils.Variety(Type.RandomVelocity)); rotate_velocity = init.Convert("RotationVelocity", ParticleUtils.AngleVariety(Type.RandomRotation)); // Set invisible first and check later for visibility Visible = false; }
public BulletWeapon(World world, WeaponType type, Target target, Actor origin, uint id) : base(world, type, target, origin, id) { projectile = (BulletProjectile)type.Projectile; Angle = (Position - TargetPosition).FlatAngle; TargetPosition += getInaccuracy(projectile.Inaccuracy); calculateStartSpeed(); if (projectile.OrientateToTarget) { Rotation = new VAngle(0, 0, Angle); } rayPhysics = new RayPhysics(world); }
public BulletWeapon(World world, WeaponInit init) : base(world, init) { projectile = (BulletProjectile)Type.Projectile; speed = init.Convert("Speed", Vector.Zero); speedLeft = init.Convert("SpeedLeft", Vector.Zero); if (speed == Vector.Zero) { calculateStartSpeed(); } if (projectile.OrientateToTarget) { Rotation = new VAngle(0, 0, Angle); } rayPhysics = new RayPhysics(world); }
public StaticBatchRenderable(CPos position, VAngle rotation, Vertex[] vertices) { var color = Color.White; var vec = position.ToVector(); var matrix = Matrix4.CreateTranslation(vec.X, vec.Y, vec.Z); if (rotation != Vector3.Zero) { var r1 = Matrix4.CreateRotationX(rotation.X); var r2 = Matrix4.CreateRotationY(rotation.Y); var r3 = Matrix4.CreateRotationZ(rotation.Z); matrix = r1 * r2 * r3 * matrix; } this.vertices = new Vertex[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { this.vertices[i] = vertices[i].Apply(matrix, color); } }
public void AffectRotation(ParticleForce force, float ratio, CPos origin) { var random = ParticleUtils.Random; var angle = Angle.Cast((origin - Position).FlatAngle - Rotation.CastToAngleRange().Z); var zFloat = 0f; switch (force.Type) { case ParticleForceType.FORCE: zFloat = Math.Sign(-angle) * force.Strength * ratio * 0.1f; zFloat = Math.Min(0.628f, zFloat); break; case ParticleForceType.TURBULENCE: angle = Angle.RandomAngle(random); zFloat = Math.Sign(-angle) * force.Strength * ratio * 0.1f; zFloat = Math.Min(0.628f, zFloat); break; case ParticleForceType.DRAG: zFloat = -force.Strength * ratio * rotate_velocity.Z * 0.1f; if (Math.Abs(zFloat) > Math.Abs(rotate_velocity.Z)) { zFloat = -rotate_velocity.Z * ratio; } break; case ParticleForceType.VORTEX: zFloat = Math.Sign(-angle - MathF.PI / 2) * force.Strength * 0.1f; zFloat = Math.Min(0.628f, zFloat); break; } rotate_velocity = new VAngle(0, 0, zFloat); }
public StaticBatchRenderable(CPos position, VAngle rotation, Texture texture) : this(position, rotation, Mesh.Image(texture)) { }
public virtual void SetRotation(VAngle rotation) { SetRotation((Vector3)rotation); }
public void SetRotation(VAngle rotation) { charRenderable.SetRotation(rotation); }