Пример #1
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary>
        protected override void OnPostCreate(bool loaded)
        {
            base.OnPostCreate(loaded);

            SetTurnToPosition(Position + Rotation.GetForward() * 100);
            if (PhysicsModel != null)
            {
                PhysicsModel.PopFromWorld();

                Damager_Ball        = PhysicsModel.GetBody("Damager_Ball");
                Damager_Ball_Player = PhysicsModel.GetBody("CT");

                //if (Damager_Ball_Player != null)
                //{
                //    //this.Type.BallRadius = .5f;//((Damager_Ball_Player.Shapes[0].Volume * 3f) / (4f * (float)Math.PI) * .333333f);
                //    foreach (Body body in PhysicsModel.Bodies)
                //        body.Collision += new Body.CollisionDelegate(body_Collision);
                //}

                if (!EntitySystemWorld.Instance.IsEditor())
                {
                    Damager_Ball_Player.Shapes[0].Density              = PhysicsDensity;
                    Damager_Ball_Player.Shapes[0].DynamicFriction      = PhysicsDynamicFriction;
                    Damager_Ball_Player.Shapes[0].Restitution          = PhysicsBounciness; //Bounciness
                    Damager_Ball_Player.Shapes[0].StaticFriction       = PhysicsStaticFriction;
                    Damager_Ball_Player.Shapes[0].SpecialLiquidDensity = PhysicsLiquidDensity;
                    Damager_Ball_Player.Shapes[0].ContactGroup         = (int)ContactGroup.Dynamic;
                    Damager_Ball_Player.EnableGravity  = true;
                    Damager_Ball_Player.LinearVelocity = linearVelocityForSerialization;
                }

                if (!EntitySystemWorld.Instance.IsEditor())
                {
                    if (Damager_Ball_Player == null)
                    {
                        Log.Error("Damager_Ball.type: \"Damager_Ball\" body does not exist. The Physics Body is Named incorrectly?");
                    }
                }
                SubscribeToTickEvent();
                CheckPhysicsProperties();
                PhysicsModel.PushToWorld();
            }

            //Incin
            //if activeMaxTurrets turret was out from before RemoveMiniTurret it
            //if (turret != null)
            //{
            //    turret.SetForDeletion(false);
            //    turretTimer = 0; //reset remove timer
            //    activeturrets = 0;  //reset turret counts
            //}
        }
Пример #2
0
        protected void CheckPhysicsProperties()
        {
            if (Damager_Ball_Player != null)
            {
                PhysicsModel.PopFromWorld();
                Damager_Ball_Player.Shapes[0].Density              = PhysicsDensity;
                Damager_Ball_Player.Shapes[0].DynamicFriction      = PhysicsDynamicFriction;
                Damager_Ball_Player.Shapes[0].Restitution          = PhysicsBounciness;//Bounciness
                Damager_Ball_Player.Shapes[0].StaticFriction       = PhysicsStaticFriction;
                Damager_Ball_Player.Shapes[0].SpecialLiquidDensity = PhysicsLiquidDensity;
                Damager_Ball_Player.Shapes[0].ContactGroup         = (int)ContactGroup.Dynamic;
                Damager_Ball_Player.EnableGravity = true;

                PhysicsModel.PushToWorld();
                //GameEngineApp.Instance.AddScreenMessage("Physics Updated");
            }
        }