Exemple #1
0
 public void OnCollide(object sender, CollisionEventArgs args)
 {
     if (args.Info.HitEnt != null)
     {
         PhysicsEntity physent = ((PhysicsEntity)args.Info.HitEnt.Tag);
         Vector3 loc = (GetPosition() - physent.GetPosition()).ToBVector();
         Vector3 impulse = GetVelocity().ToBVector() * Damage / 1000f;
         physent.Body.ApplyImpulse(ref loc, ref impulse);
         physent.Body.ActivityInformation.Activate();
         if (physent is EntityDamageable)
         {
             ((EntityDamageable)physent).Damage(Damage);
         }
     }
     if (SplashSize > 0 && SplashDamage > 0)
     {
         // TODO: Apply Splash Damage
         // TODO: Apply Splash Impulses
     }
     RemoveMe();
 }
Exemple #2
0
 public void OnCollide(object sender, CollisionEventArgs args)
 {
     if (Stuck)
     {
         return;
     }
     double len = GetVelocity().Length();
     SetPosition(args.Info.Position + (GetVelocity() / len) * 0.05f);
     SetVelocity(Location.Zero);
     Gravity = Location.Zero;
     if (HasHat)
     {
         SolidHat = new ModelEntity("invisbox", TheRegion);
         SolidHat.SetMass(0);
         SolidHat.SetPosition(GetPosition());
         SolidHat.SetOrientation(GetOrientation());
         SolidHat.scale = new Location(0.6, 1.5, 0.6);
         SolidHat.Visible = false;
         SolidHat.CanSave = false;
         TheRegion.SpawnEntity(SolidHat);
     }
     if (args.Info.HitEnt != null)
     {
         PhysicsEntity pe = (PhysicsEntity)args.Info.HitEnt.Tag;
         if (pe is EntityDamageable)
         {
             ((EntityDamageable)pe).Damage(Damage + DamageTimesVelocity * (double)len);
         }
         Vector3 loc = (args.Info.Position - pe.GetPosition()).ToBVector();
         Vector3 impulse = GetVelocity().ToBVector() * DamageTimesVelocity / 1000f;
         pe.Body.ApplyImpulse(ref loc, ref impulse);
         StuckTo = pe;
         if (HasHat)
         {
             CollisionRules.AddRule(pe.Body, SolidHat.Body, CollisionRule.NoBroadPhase); // TODO: Broadcast this info! Perhaps abuse the joint system?
         }
     }
     TheRegion.SendToAll(new PrimitiveEntityUpdatePacketOut(this));
     if (args.Info.HitEnt != null)
     {
         PhysicsEntity pe = (PhysicsEntity)args.Info.HitEnt.Tag;
         JointForceWeld jfw = new JointForceWeld(pe, this);
         TheRegion.AddJoint(jfw);
     }
 }