public override void OnInit()
		{
			//Tworzymy zamek.
			var pObj = new PhysicalObject();
			this.Components.Add(pObj);
			this.Components.Add(new BoundingBox(Settings.CastleSize));
			pObj.Body.SetCollisionCategories(FarseerPhysics.Dynamics.Category.Cat20);
			pObj.Body.UserData = this;
#if !SERVER
			Sprite s = new Sprite("CastleImage", this.GameInfo.Content.Load<Texture>(this.Player.Nation.CastleImage));
			this.Components.Add(s);
			if (this.Player.Type == PlayerType.Second)
			{
				s.Effect = ClashEngine.NET.Interfaces.Graphics.Objects.SpriteEffect.FlipHorizontally;
				this.Attributes.Get<Vector2>("Position").Value = this.GameState.Map.SecondCastle;
			}
			else
			{
				this.Attributes.Get<Vector2>("Position").Value = this.GameState.Map.FirstCastle;
			}

			this.Attributes.Get<Vector2>("Size").Value = Settings.CastleSize;
#endif
		}
		public override void OnInit()
		{
			//Najpierw komponenty fizyczne, by dało się pobrać prawidłowy atrybut prędkości.
			var pObj = new PhysicalObject(true);
			var bBox = new BoundingBox(new OpenTK.Vector2(this.Description.Width, this.Description.Height), 10f);
			this.Components.Add(pObj);
			this.Components.Add(bBox);

			this.Health_ = this.Attributes.GetOrCreate<int>("Health");
			this.Position_ = this.Attributes.GetOrCreate<Vector2>("Position");

			this.Health = (int)this.Description.Health;

			//Ustawiamy właściwości ciała tak, by poruszało się po naszej myśli
			pObj.Body.Mass = 10;
			pObj.Body.LinearDamping = 0.2f;
			//pObj.Body.FixedRotation = true;

			pObj.Body.UserData = this;

			//Ustawiamy maskę kolizji tak by kolidowało tylko z innymi graczami
			pObj.Body.SetCollisionCategories((Category)((int)Category.Cat1 << (int)this.Owner.Type));

			//Koliduje ze wszystkim z wyłączeniem jednostek tego samego gracza i zasobami.
			pObj.Body.SetCollidesWith(Category.All & ~pObj.Body.GetCollisionCategories() &
				~Category.Cat10 & ~((Category)((int)Category.Cat11 << (int)this.Owner.Type)));

			//Ustawianie stałego konta jednostek
			this.FixedAngle = new FixedAngleJoint(pObj.Body);
			this.FixedAngle.BiasFactor = 0.08f;
			ClashEngine.NET.PhysicsManager.Instance.World.AddJoint(this.FixedAngle);

			var velMult = this.Attributes.GetOrCreate<float>("VelocityMultiplier");
			//I zdarzenia kolizji pomiędzy jednostkami
			pObj.Body.SetCollisionEvent((fixtureA, fixtureB, contact) =>
			{
				if (fixtureB.Body.UserData is IUnit && this.CollisionWithUnit != null)
				{
					this.CollisionWithUnit(this, fixtureB.Body.UserData as IUnit);
					return false;
				}
				else if (fixtureB.Body.UserData is IPlayerEntity && this.CollisionWithPlayer != null)
				{
					this.CollisionWithPlayer(this, (fixtureB.Body.UserData as IPlayerEntity).Player);
				}
				else if (fixtureB.Body.UserData is IResourceOnMap && this.CollisionWithResource != null)
				{
					//Taka iteracja zapobiega zbieraniu już zebranych zasobów
					var delegates = this.CollisionWithResource.GetInvocationList();
					foreach (CollisionWithResourceEventHandler d in delegates)
					{
						if (d(this, fixtureB.Body.UserData as IResourceOnMap))
						{
							(fixtureB.Body.UserData as IResourceOnMap).Gather();
							break;
						}
					}
				}
				else if (fixtureB.Body.UserData is IMap) //Ustawiamy kąt nachylenia dla postaci
				{
					if (fixtureA.UserData == null ||
						(velMult.Value >= 0.0 && (int)fixtureA.UserData < (int)fixtureB.UserData) ||
						(velMult.Value < 0.0 && (int)fixtureA.UserData > (int)fixtureB.UserData))
					{
						FarseerPhysics.Common.FixedArray2<Microsoft.Xna.Framework.Vector2> points;
						Microsoft.Xna.Framework.Vector2 normal;
						contact.GetWorldManifold(out normal, out points);
						var dot = Microsoft.Xna.Framework.Vector2.Dot(new Microsoft.Xna.Framework.Vector2(0, -1), normal);
						var angle = (float)Math.Acos(dot) * Math.Sign(normal.X);
						this.FixedAngle.TargetAngle = (float)angle;

						fixtureA.UserData = fixtureB.UserData;
					}
				}
				return true;
			});

			foreach (var component in this.Description.Components)
			{
				this.Components.Add(component.Create());
			}
		}