コード例 #1
0
 public bool RemoveEntity(Entity entity)
 {
     if (!entityTable.ContainsKey(entity.Name))
     {
         LogConsole.Warning(Self, "Attempted to remove a non-existing entity '{0}'", entity.Name);
         return false;
     }
     entityTable.Remove(entity.Name);
     if(entity.ActiveScene == this)
         entity.ActiveScene = null;
     return true;
 }
コード例 #2
0
 public void StepUpdate(Entity entityA)
 {
     if (!entityA.IsGhost)
     {
         foreach (var entityB in entityTable.Values)
         {
             if (entityB.Name == entityA.Name
                 || entityB.IsGhost) continue;
             Vector3d realVelocity = entityA.RealVelocity;
             Vector3d direction = realVelocity.Normalized();
             double realVelocityLength = realVelocity.Length();
             Ray3d pred = new Ray3d(entityA.Position, direction);
             double movement;
             if (pred.Intersects(entityB.Bounds, out movement))
             {
                 if (double.IsNaN(movement)) continue;
                 double diff = realVelocityLength - movement;
                 if (movement <= realVelocityLength)
                 {
                     Vector3d point = direction * movement;
                     entityA.OnCollision(entityB, point);
                     entityB.OnCollision(entityA, point);
                     entityA.Position -= direction * diff * 1.001;
                     entityA.Velocity = entityA.RealVelocity;
                 }
             }
         }
     }
 }
コード例 #3
0
 public bool AddEntity(Entity entity)
 {
     if (entityTable.ContainsKey(entity.Name))
     {
         LogConsole.Warning(Self, "Attempted to add a duplicate entity '{0}'", entity.Name);
         return false;
     }
     entityTable.Add(entity.Name, entity);
     entity.ActiveScene = this;
     return true;
 }