Exemplo n.º 1
0
    public void RegisterEntity(WorldEntity2D e)
    {
        List <IntVector2D> all = e.AbsoluteLocations(e.Location);

        _worldEntities2D.Add(e);
        AddEntityTo2DLocations(all, e.Orientation, e);
    }
Exemplo n.º 2
0
    private bool IsEntity2DCovered(WorldEntity2D e)
    {
        List <IntVector2D> locations = e.AbsoluteLocations(e.Location);

        switch (e.Orientation)
        {
        case PlaneOrientation.XY:
            for (int i = 0; i < locations.Count; i++)
            {
                if (!PassableAtXY(locations[i]))
                {
                    return(false);
                }
            }
            break;

        case PlaneOrientation.ZY:
            for (int i = 0; i < locations.Count; i++)
            {
                if (!PassableAtZY(locations[i]))
                {
                    return(false);
                }
            }
            break;

        default:
            break;
        }
        return(true);
    }
Exemplo n.º 3
0
    public bool CanMoveByDelta(WorldEntity2D e, IntVector2D v)
    {
        IntVector2D        resLoc        = e.Location + v;
        List <IntVector2D> occupiedAfter = e.AbsoluteLocations(resLoc);

        // TODO(Julian): Take more than just shadows into account!

        int i;

        switch (e.Orientation)
        {
        case PlaneOrientation.XY:
            for (i = 0; i < occupiedAfter.Count; i++)
            {
                if (!PassableAtXY(occupiedAfter[i]))
                {
                    return(false);
                }
            }
            break;

        case PlaneOrientation.ZY:
            for (i = 0; i < occupiedAfter.Count; i++)
            {
                if (!PassableAtZY(occupiedAfter[i]))
                {
                    return(false);
                }
            }
            break;
        }

        return(true);
    }
Exemplo n.º 4
0
    void Update()
    {
        Profiler.BeginSample("2d sim");
        for (int i = 0; i < _worldEntities2D.Count; i++)
        {
            WorldEntity2D entity = _worldEntities2D[i];
            Profiler.BeginSample("Clear 2d loc");
            RemoveEntityFrom2DLocations(entity.AbsoluteLocations(entity.Location), entity.Orientation, entity);
            Profiler.EndSample();
            Profiler.BeginSample("Simulate 2d entity");
            entity.Simulate();
            Profiler.EndSample();
            Profiler.BeginSample("Fill 2d loc");
            AddEntityTo2DLocations(entity.AbsoluteLocations(entity.Location), entity.Orientation, entity);
            Profiler.EndSample();
        }
        Profiler.EndSample();

        Profiler.BeginSample("3d sim");
        for (int i = 0; i < _worldEntities.Count; i++)
        {
            WorldEntity entity = _worldEntities[i];
            Profiler.BeginSample("Clear 3d loc");
            List <IntVector> all = entity.AbsoluteLocations(entity.Location, entity.Rotation);
            Set3DLocationsToEntity(all, null);
            Profiler.EndSample();
            Profiler.BeginSample("Simulate 3d entity");
            entity.Simulate();
            Profiler.EndSample();
            Profiler.BeginSample("Fill 3d loc");
            all = entity.AbsoluteLocations(entity.Location, entity.Rotation);
            Set3DLocationsToEntity(all, entity);
            Profiler.EndSample();
        }
        Profiler.EndSample();
        Profiler.BeginSample("Shadow Sim");
        UpdateShadows();
        Profiler.EndSample();
    }
Exemplo n.º 5
0
 public List <IntVector2D> AbsoluteLocations(IntVector2D location)
 {
     return(_worldEntity.AbsoluteLocations(location));
 }