public Train(Vector2 v2Position, Vector2 v2Direction, float fSpeed, ToyFactoryTrainStuffBagman.Train.GraphicType enType)
 {
     this.xTransform = new TransformComponent(v2Position);
     this.v2Direction = v2Direction;
     this.fSpeed = fSpeed;
     this.enGraphicType = enType;
     this.LoadGraphics(enType);
     this.xRenderComponent.SwitchAnimation((ushort)(Utility.ConvertV2DirectionToClosestByteDirection(v2Direction) * 2));
     this.xAttackPhase = new AttackPhase(this);
     SphereCollider col = new SphereCollider(10f, Vector2.Zero, this.xTransform, 0f, this);
     col.xAttackPhase = this.xAttackPhase;
     this.xAttackPhase.lxCurrentColliders.Add(col);
     this.xAttackPhase.RegisterCurrent();
     this.xAttackPhase.lenLayers.Add(Collider.ColliderLayers.Players);
     this.xAttackPhase.lenLayers.Add(Collider.ColliderLayers.Neutrals);
     this.xAttackPhase.xStats.iBaseDamage = 50;
     this.xAttackPhase.xStats.fKnockBack = 25f;
 }
 public void LoadGraphics(ToyFactoryTrainStuffBagman.Train.GraphicType enType)
 {
     ContentManager Content = CAS.RegionContent;
     this.xRenderComponent = new AnimatedRenderComponent(this);
     this.xRenderComponent.xTransform = this.xTransform;
     bool bIsEngine = true;
     string sCartMos = "Train";
     if (enType == ToyFactoryTrainStuffBagman.Train.GraphicType.Cart01)
     {
         sCartMos = "Cart";
         bIsEngine = false;
     }
     if (bIsEngine)
     {
         this.xRenderComponent.dixAnimations.Add(0, new Animation(0, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Up"), new Vector2(11f, 16f), 4, 4, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(1, new Animation(1, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/UpRight"), new Vector2(13f, 15f), 4, 1, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(2, new Animation(2, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Right"), new Vector2(12f, 17f), 4, 4, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(3, new Animation(3, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/DownRight"), new Vector2(10f, 16f), 4, 1, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(4, new Animation(4, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Down"), new Vector2(11f, 16f), 4, 4, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(5, new Animation(5, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/DownRight"), new Vector2(10f, 16f), 4, 1, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations[5].enSpriteEffect = SpriteEffects.FlipHorizontally;
         this.xRenderComponent.dixAnimations.Add(6, new Animation(6, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Right"), new Vector2(10f, 17f), 4, 4, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations[6].enSpriteEffect = SpriteEffects.FlipHorizontally;
         this.xRenderComponent.dixAnimations.Add(7, new Animation(7, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/UpRight"), new Vector2(9f, 15f), 4, 1, 23, 30, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations[7].enSpriteEffect = SpriteEffects.FlipHorizontally;
     }
     else
     {
         this.xRenderComponent.dixAnimations.Add(0, new Animation(0, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Down"), new Vector2(9f, 12f), 4, 4, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(1, new Animation(1, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/UpRight"), new Vector2(10f, 12f), 4, 1, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(2, new Animation(2, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Right"), new Vector2(9f, 12f), 4, 4, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(3, new Animation(3, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/DownRight"), new Vector2(10f, 12f), 4, 1, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(4, new Animation(4, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Down"), new Vector2(9f, 12f), 4, 4, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations.Add(5, new Animation(5, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/DownRight"), new Vector2(10f, 12f), 4, 1, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations[5].enSpriteEffect = SpriteEffects.FlipHorizontally;
         this.xRenderComponent.dixAnimations.Add(6, new Animation(6, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/Right"), new Vector2(9f, 12f), 4, 4, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations[6].enSpriteEffect = SpriteEffects.FlipHorizontally;
         this.xRenderComponent.dixAnimations.Add(7, new Animation(7, 0, Content.Load<Texture2D>("Sprites/Monster/Winterland/Toy Machine/" + sCartMos + "/Idle/UpRight"), new Vector2(10f, 12f), 4, 1, 19, 23, 0, 0, 20, Animation.LoopSettings.Looping, Animation.CancelOptions.IgnoreIfPlaying, true, true, new AnimationInstruction[0]));
         this.xRenderComponent.dixAnimations[7].enSpriteEffect = SpriteEffects.FlipHorizontally;
     }
     Program.game.xRenderMaster.RegisterSortedRenderComponent(this.xRenderComponent);
 }
 public void ManipulateTrain(ToyFactoryTrainStuffBagman.Train xTrain)
 {
     if (xTrain.iInTurn >= 0)
     {
         return;
     }
     int iInverseDir = this.iDirection + ((!this.bSwitchedState) ? -1 : 1);
     iInverseDir = (iInverseDir + 4) % 4;
     float fTurnDistance = new Vector2(4f, 3f).Length();
     if ((int)Utility.ConvertV2DirectionToClosestByteDirection(xTrain.v2Direction) == this.iDirection)
     {
         if (Vector2.Distance(xTrain.xTransform.v2Pos, this.GetEntryPoint()) < xTrain.fSpeed)
         {
             int iOutDir = (this.iDirection + ((!this.bSwitchedState) ? 1 : -1) + 4) % 4;
             xTrain.xTransform.v2Pos = this.GetEntryPoint();
             xTrain.iInTurn = (int)(fTurnDistance / xTrain.fSpeed);
             xTrain.v2EndTurnDirection = Utility.AnimationDirectionToVector2(iOutDir);
             xTrain.v2EndTurnPosition = this.GetInverseEntryPoint();
             xTrain.v2Direction = Utility.Normalize(Utility.AnimationDirectionToVector2(this.iDirection) + Utility.AnimationDirectionToVector2(iOutDir));
             xTrain.xRenderComponent.SwitchAnimation((ushort)((this.iDirection * 2 + ((!this.bSwitchedState) ? 1 : -1)) % 8));
         }
     }
     else if ((int)Utility.ConvertV2DirectionToClosestByteDirection(xTrain.v2Direction) == iInverseDir && Vector2.Distance(xTrain.xTransform.v2Pos, this.GetInverseEntryPoint()) < xTrain.fSpeed)
     {
         int iOutDir2 = (iInverseDir + (this.bSwitchedState ? 1 : -1) + 4) % 4;
         xTrain.xTransform.v2Pos = this.GetInverseEntryPoint();
         xTrain.iInTurn = (int)(fTurnDistance / xTrain.fSpeed);
         xTrain.v2EndTurnDirection = Utility.AnimationDirectionToVector2(iOutDir2);
         xTrain.v2EndTurnPosition = this.GetEntryPoint();
         xTrain.v2Direction = Utility.Normalize(Utility.AnimationDirectionToVector2(iInverseDir) + Utility.AnimationDirectionToVector2(iOutDir2));
         xTrain.xRenderComponent.SwitchAnimation((ushort)((iInverseDir * 2 + (this.bSwitchedState ? 1 : -1)) % 8));
     }
     Vector2 v2MidMos = this.v2Position + new Vector2(7f, 7f);
     if (xTrain.iInTurn < 0 && Vector2.Distance(xTrain.xTransform.v2Pos, v2MidMos) < xTrain.fSpeed + 1f)
     {
         xTrain.bToBeDestroyed = true;
     }
 }