Rogue: Savage Rats, a retro-themed dungeon crawler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
rogue-savage-rats/src/mightypork/utils/math/constraints/Constraint.java

58 lines
898 B

package mightypork.utils.math.constraints;
import mightypork.utils.math.coord.Coord;
/**
* A constraint based on a given {@link ConstraintContext}
*
* @author MightyPork
*/
public abstract class Constraint implements SettableContext {
private ConstraintContext context = null;
public Constraint(ConstraintContext context) {
this.context = context;
}
@Override
public void setContext(ConstraintContext context)
{
this.context = context;
}
/**
* @return the context
*/
public ConstraintContext getContext()
{
return context;
}
/**
* @return context rect origin
*/
protected Coord getOrigin()
{
if (context == null) return Coord.zero();
return context.getRect().getOrigin();
}
/**
* @return context rect size
*/
protected Coord getSize()
{
if (context == null) return Coord.zero();
return context.getRect().size();
}
}