/// <summary> /// this method requires that you are using a collision layer setup in the constructor. /// </summary> /// <returns>The tile at world position.</returns> /// <param name="worldPos">World position.</param> public TiledTile getTileAtWorldPosition(Vector2 worldPos) { Assert.isNotNull(collisionLayer, "collisionLayer must not be null!"); // offset the passed in world position to compensate for the entity position worldPos -= entity.transform.position + _localOffset; return(collisionLayer.getTileAtWorldPosition(worldPos)); }
/// <summary> /// gets all the non-empty tiles that intersect the passed in bounds for the collision layer. The returned List can be put back in the /// pool via ListPool.free. /// </summary> /// <returns>The tiles intersecting bounds.</returns> /// <param name="bounds">Bounds.</param> public List <TiledTile> getTilesIntersectingBounds(Rectangle bounds) { Assert.isNotNull(collisionLayer, "collisionLayer must not be null!"); // offset the passed in world position to compensate for the entity position bounds.Location -= (entity.transform.position + _localOffset).ToPoint(); return(collisionLayer.getTilesIntersectingBounds(bounds)); }
/// <summary> /// either returns a super fast Delegate to get the given property or null if it couldn't be found /// via reflection /// </summary> public static T getterForProperty <T>(System.Object targetObject, string propertyName) { // first get the property #if NETFX_CORE var propInfo = targetObject.GetType().GetRuntimeProperty(propertyName); #else var propInfo = targetObject.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); #endif Assert.isNotNull(propInfo, "could not find property with name: " + propertyName); #if NETFX_CORE // Windows Phone/Store new API return((T)(object)propInfo.GetMethod.CreateDelegate(typeof(T), targetObject)); #else return((T)(object)Delegate.CreateDelegate(typeof(T), targetObject, propInfo.GetGetMethod(true))); #endif }
public override void onAddedToEntity() { _collider = entity.getComponent <Collider>(); Assert.isNotNull(_collider, "null Collider. ProjectilMover requires a Collider!"); }